import java.io.*;
import java.util.StringTokenizer;

public class Main {
    FastScanner in;
    PrintWriter out;

    public static void main(String[] args) throws Exception {
        (new Main()).run();
    }

    private void run() throws Exception {
        in = new FastScanner(System.in);
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }

    private void solve() throws Exception {
        int n = in.nextInt();
        int[] cards = new int[n];
        for (int i = 0; i < n; i++) {
            cards[i] = getCardNumber(in.next());
        }
        out.println(getAnswer(cards) ? "YES" : "NO");
    }

    private boolean getAnswer(int[] cards) {
        int n = cards.length;
        if (n == 1) {
            return true;
        }
        if (n == 2) {
            return canMove(cards[0], cards[1]);
        }
        Boolean[][][][] dp = new Boolean[n + 1][52][52][52];
        int last = cards[n - 1];
        int prelast = cards[n - 2];
        int preprelast = cards[n - 3];
        return getAnswer(cards, dp, n, last, prelast, preprelast);
    }

    private boolean getAnswer(int[] cards, Boolean[][][][] dp, int n, int last, int prelast, int preprelast) {
        if (dp[n][last][prelast][preprelast] != null) {
            return dp[n][last][prelast][preprelast];
        }
        if (n == 3) {
            return dp[n][last][prelast][preprelast] = canMove(last, prelast) && canMove(last, preprelast);
        }
        return dp[n][last][prelast][preprelast] = (canMove(last, prelast) && getAnswer(cards, dp, n - 1, last, preprelast, cards[n - 4]))
                || (canMove(last, cards[n - 4]) && getAnswer(cards, dp, n - 1, prelast, preprelast, last));
    }

    private boolean canMove(int card1Number, int card2Number) {
        return (card1Number / 13) == (card2Number / 13) || (card1Number % 13) == (card2Number % 13);
    }

    private int getCardNumber(String cardName) {
        char rank = cardName.charAt(0);
        char suit = cardName.charAt(1);
        int rankNumber = 12;
        if (Character.isDigit(rank)) {
            rankNumber = rank - '0' - 2;
        } else {
            switch (rank) {
                case 'T':
                    rankNumber = 8;
                    break;
                case 'J':
                    rankNumber = 9;
                    break;
                case 'Q':
                    rankNumber = 10;
                    break;
                case 'K':
                    rankNumber = 11;
                    break;
            }
        }
        int suitNumber = 0;
        switch (suit) {
            case 'D':
                suitNumber = 1;
                break;
            case 'H':
                suitNumber = 2;
                break;
            case 'C':
                suitNumber = 3;
                break;
        }
        return suitNumber * 13 + rankNumber;
    }

    private class FastScanner {
        BufferedReader bufferedReader;
        StringTokenizer stringTokenizer;

        public FastScanner(InputStream inputStream) {
            this.bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
        }

        public String next() throws IOException {
            while (stringTokenizer == null || !stringTokenizer.hasMoreTokens()) {
                String line = bufferedReader.readLine();
                if (line == null) {
                    throw new EOFException("End of input stream is reached.");
                }
                stringTokenizer = new StringTokenizer(line);
            }
            return stringTokenizer.nextToken();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }
    }
}

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Round130_B {
    static int N;
    static String[] a;
    static Boolean dp[][][][];

    public static boolean go(int cur, int a, int b, int c) {
        if (cur == 1)
            return (ch(c, b));

        if (dp[cur][a][b][c] != null)
            return dp[cur][a][b][c];

        boolean ret = false;
        if (cur > 2 && ch(cur - 3, c))
            ret = go(cur - 1, c, a, b);
        if (ret)
            return dp[cur][a][b][c] = ret;

        if (ch(c, b))
            ret = go(cur - 1, cur - 3, a, c);

        return dp[cur][a][b][c] = ret;

    }

    private static boolean ch(int i, int j) {
        return a[i].charAt(0) == a[j].charAt(0)
                || a[i].charAt(1) == a[j].charAt(1);

    }

    public static void main(String[] args) throws Exception {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

        N = Integer.parseInt(in.readLine());
        a = in.readLine().split(" ");
        if (N == 1)
            System.out.println("YES");
        else {
            dp = new Boolean[N + 2][N + 2][N + 2][N + 2];

            System.out.println((go(N - 1, N - 3, N - 2, N - 1) ? "YES" : "NO"));
        }

    }
}

import sun.reflect.generics.tree.Tree;

import java.util.Scanner;
import java.util.*;

public class Main
{
    static Scanner in = new Scanner( System.in );

    static class State
    {
        int size;
        String first;
        String second;
        String third;
        State( int arg1, String arg2, String arg3, String arg4 )
        {
            size = arg1;
            first = arg2;
            second = arg3;
            third = arg4;
        }
    }

    static boolean equals( String arg1, String arg2 )
    {
        if ( arg1.charAt( 0 ) == arg2.charAt( 0 ) || arg1.charAt( 1 ) == arg2.charAt( 1 ) ) return true;
        else return false;
    }

    static class StateComparator implements Comparator < State >
    {
        public int compare( State arg1, State arg2 )
        {
            if ( arg1.size != arg2.size ) return arg1.size - arg2.size;
            else if ( arg1.first.compareTo( arg2.first ) != 0 ) return arg1.first.compareTo( arg2.first );
            else if ( arg1.second.compareTo( arg2.second ) != 0 ) return arg1.second.compareTo( arg2.second );
            else return arg1.third.compareTo( arg2.third );
        }
    }

    public static void main( String[] args )
    {
        int cardsN = Integer.parseInt(in.nextLine());
        List < String > cards = new ArrayList();
        StringTokenizer input = new StringTokenizer( in.nextLine() );
        for ( int i = 0; i < cardsN; i++ )
        {
            cards.add( input.nextToken() );
        }

        Queue < List < String > > workQ = new LinkedList();
        Map < State, Boolean > states = new TreeMap( new StateComparator() );
        workQ.offer( cards );

        if ( cards.size() < 4 ) if ( equals(cards.get(0), cards.get(cards.size() - 1)) ) { System.out.println( "YES" ); return; }
        else { System.out.println( "NO" ); return; }

        states.put( new State( cardsN, cards.get( cardsN - 3 ), cards.get( cardsN - 2 ), cards.get( cardsN - 1 ) ), true );

        while ( !workQ.isEmpty() )
        {
            List < String > curList1 = new LinkedList < String > ();
            List < String > curList2 = new LinkedList < String > ();
            for ( String element : workQ.poll() )
            {
                curList1.add( new String( element ) );
                curList2.add( new String( element ) );
            }
            if ( curList1.size() == 1 ) { System.out.println( "YES" ); return; }

            if ( curList1.size() - 2 >= 0 && curList1.size() > 3 && equals( curList1.get( curList1.size() - 1 ), curList1.get( curList1.size() - 2 ) ) )
            {
                int s = curList1.size();
                curList1.add( s - 2, curList1.get(s - 1) );
                curList1.remove( s - 1 );
                curList1.remove( s - 1 ); s--;
                State curState = new State( s, curList1.get( s - 3 ), curList1.get( s - 2 ), curList1.get( s - 1 ) );
                if ( states.get( curState ) == null )
                {
                    states.put( curState, true );
                    workQ.offer( curList1 );
                }
            }
            if ( curList2.size() - 4 >= 0 && curList2.size() > 3 && equals( curList2.get( curList2.size() - 1 ), curList2.get( curList2.size() - 4 ) ) )
            {
                int s = curList2.size();
                curList2.add( s - 4, curList2.get(s - 1) );
                curList2.remove( s - 3 );
                curList2.remove( s - 1 ); s--;
                State curState = new State( s, curList2.get( s - 3 ), curList2.get( s - 2 ), curList2.get( s - 1 ) );
                if ( states.get( curState ) == null )
                {
                    states.put( curState, true );
                    workQ.offer( curList2 );
                }
            }
            if ( curList1.size() < 4 ) if ( equals( curList1.get( 0 ), curList1.get( 2 ) ) && equals( curList1.get( 2 ), curList1.get( 1 ) ) ) { System.out.println( "YES" ); return; }
            if ( curList2.size() < 4 ) if ( equals( curList2.get( 0 ), curList2.get( 2 ) ) && equals( curList1.get( 2 ), curList1.get( 1 ) ) ) { System.out.println( "YES" ); return; }
        }
        System.out.println("NO");
    }
}

import java.util.Map;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.BufferedWriter;
import java.util.Locale;
import java.util.InputMismatchException;
import java.util.HashMap;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Jacob Jiang
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		OutputWriter out = new OutputWriter(outputStream);
		TaskB solver = new TaskB();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskB {

    private String[] cards;
    Map<State, Boolean> map;

    public void solve(int testNumber, InputReader in, OutputWriter out) {
        int n = in.nextInt();
        cards = in.nextStringArray(n);
        if (n == 1) {
            out.println("YES");
            return;
        }
        if (n == 2) {
            out.println(match(cards[0], cards[1]) ? "YES" : "NO");
            return;
        }
        map = new HashMap<State, Boolean>();
        out.println(dp(cards[n - 1], cards[n - 2], cards[n - 3], n - 3) ? "YES" : "NO");
    }

    private boolean dp(String card, String preCard, String prePreCard, int remaining) {
        State currentState = new State(card, preCard, prePreCard, remaining);
        if (map.containsKey(currentState)) {
            return map.get(currentState);
        }
        if (remaining == 0) {
            boolean result = match(card, preCard) && match(card, prePreCard);
            map.put(currentState, result);
            return result;
        }
        boolean result = (match(card, preCard) && dp(card, prePreCard, cards[remaining - 1], remaining - 1))
                || (match(card, cards[remaining - 1]) && dp(preCard, prePreCard, card, remaining - 1));
        map.put(currentState, result);
        return result;
    }

    private static class State {
        private String card;
        private String preCard;
        private String prePreCard;
        private int remaining;

        private State(String card, String preCard, String prePreCard, int remaining) {
            this.card = card;
            this.preCard = preCard;
            this.prePreCard = prePreCard;
            this.remaining = remaining;
        }

        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;

            State state = (State) o;

            if (remaining != state.remaining) return false;
            if (card != null ? !card.equals(state.card) : state.card != null) return false;
            if (preCard != null ? !preCard.equals(state.preCard) : state.preCard != null) return false;
            if (prePreCard != null ? !prePreCard.equals(state.prePreCard) : state.prePreCard != null) return false;

            return true;
        }

        public int hashCode() {
            int result = card != null ? card.hashCode() : 0;
            result = 31 * result + (preCard != null ? preCard.hashCode() : 0);
            result = 31 * result + (prePreCard != null ? prePreCard.hashCode() : 0);
            result = 31 * result + remaining;
            return result;
        }

        public String toString() {
            return "State{" +
                    "card='" + card + '\'' +
                    ", preCard='" + preCard + '\'' +
                    ", prePreCard='" + prePreCard + '\'' +
                    ", remaining=" + remaining +
                    '}';
        }
    }

    private boolean match(String s1, String s2) {
        return s1.charAt(0) == s2.charAt(0) || s1.charAt(1) == s2.charAt(1);
    }

}

class InputReader {

    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;

    public InputReader(InputStream stream) {
        this.stream = stream;
    }

    public int read() {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    public int nextInt() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        int res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c & 15;
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public String next() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        StringBuilder res = new StringBuilder();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isSpaceChar(c));
        return res.toString();
    }

    public static boolean isSpaceChar(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    public String[] nextStringArray(int count) {
        String[] result = new String[count];
        for (int i = 0; i < count; i++) {
            result[i] = next();
        }
        return result;
    }

    }

class OutputWriter {
    private PrintWriter writer;

    public OutputWriter(OutputStream stream) {
        writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(stream)));
    }

    public OutputWriter(Writer writer) {
        this.writer = new PrintWriter(writer);
    }

    public void println(String x) {
        writer.println(x);
    }

    public void close() {
        writer.close();
    }

    }

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class CodeD
{
	static class Scanner
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		public String nextLine()
		{
			try
			{
				return br.readLine();
			}
			catch(Exception e)
			{
				throw(new RuntimeException());
			}
		}

		public String next()
		{
			while(!st.hasMoreTokens())
			{
				String l = nextLine();
				if(l == null)
					return null;
				st = new StringTokenizer(l);
			}
			return st.nextToken();
		}

		public int nextInt()
		{
			return Integer.parseInt(next());
		}

		public long nextLong()
		{
			return Long.parseLong(next());
		}

		public double nextDouble()
		{
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n)
		{
			int[] res = new int[n];
			for(int i = 0; i < res.length; i++)
				res[i] = nextInt();
			return res;
		}

		public long[] nextLongArray(int n)
		{
			long[] res = new long[n];
			for(int i = 0; i < res.length; i++)
				res[i] = nextLong();
			return res;
		}

		public double[] nextDoubleArray(int n)
		{
			double[] res = new double[n];
			for(int i = 0; i < res.length; i++)
				res[i] = nextLong();
			return res;
		}
		public void sortIntArray(int[] array)
		{
			Integer[] vals = new Integer[array.length];
			for(int i = 0; i < array.length; i++)
				vals[i] = array[i];
			Arrays.sort(vals);
			for(int i = 0; i < array.length; i++)
				array[i] = vals[i];
		}

		public void sortLongArray(long[] array)
		{
			Long[] vals = new Long[array.length];
			for(int i = 0; i < array.length; i++)
				vals[i] = array[i];
			Arrays.sort(vals);
			for(int i = 0; i < array.length; i++)
				array[i] = vals[i];
		}

		public void sortDoubleArray(double[] array)
		{
			Double[] vals = new Double[array.length];
			for(int i = 0; i < array.length; i++)
				vals[i] = array[i];
			Arrays.sort(vals);
			for(int i = 0; i < array.length; i++)
				array[i] = vals[i];
		}

		public String[] nextStringArray(int n)
		{
			String[] vals = new String[n];
			for(int i = 0; i < n; i++)
				vals[i] = next();
			return vals;
		}
	}

	static String valores = "23456789TJQKA";
	static String pintas = "SDHC";

	static class Carta
	{
		int pinta;
		int valor;

		Carta(String s)
		{
			valor = valores.indexOf(s.charAt(0));
			pinta = pintas.indexOf(s.charAt(1));
		}
	}

	static Carta[] cartas;
	static Boolean[][][][] dp = new Boolean[52][52][52][52];

	static boolean dp(int n, int primera, int segunda, int tercera)
	{
		if(dp[n][primera][segunda][tercera] != null)
			return dp[n][primera][segunda][tercera];
		if(n == 2)
			return dp[n][primera][segunda][tercera] = esPosible(primera, segunda, tercera);
		if(compatibles(primera, segunda) && dp(n - 1, primera, tercera, n - 3))
			return dp[n][primera][segunda][tercera] = true;
		if(compatibles(primera, n - 3) && dp(n - 1, segunda, tercera, primera))
			return dp[n][primera][segunda][tercera] = true;
		return dp[n][primera][segunda][tercera] = false;
	}

	private static boolean compatibles(int primera, int segunda)
	{
		return (cartas[primera].pinta == cartas[segunda].pinta) || (cartas[primera].valor == cartas[segunda].valor);
	}

	private static boolean esPosible(int primera, int segunda, int tercera)
	{
		return compatibles(primera, segunda) && compatibles(primera, tercera);
	}

	public static void main(String[] args)
	{
		Scanner sc = new Scanner();
		int n = sc.nextInt();
		cartas = new Carta[n];
		for(int i = 0; i < n; i++)
			cartas[i] = new Carta(sc.next());
		boolean resultado = n <= 3 ? chequearEspecial(n) : dp(n - 1, n - 1, n - 2, n - 3);
		System.out.println(resultado ? "YES" : "NO");
	}

	private static boolean chequearEspecial(int n)
	{
		if(n == 3)
			return esPosible(n - 1, n - 2, n - 3);
		else if(n == 2)
			return compatibles(n - 1, n - 2);
		else
			return true;
	}

}

import java.util.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

public class  Main  {

	//ArrayList<Integer> lis = new ArrayList<Integer>();
	//ArrayList<String> lis = new ArrayList<String>();
	//ArrayList<test> lis = new ArrayList<test>();
//	static long sum=0;
//	static boolean f=false;
	//static String s[],r="";
//	static int dx[]={1,-1,0,0,1,1,-1,-1};
  //  static int dy[]={0,0,1,-1,1,-1,1,-1},n,m,w=0;
	//static int dp[][][][],co,r=0;
	//throws IOException
	//static char c[][];
	static boolean b=false;
	static HashMap<String,Boolean> map = new HashMap<String,Boolean>();
public  static void main(String[] args)  {
   //googlein.txt C-small-attempt0.in
//	Scanner sc =new Scanner(new File("file.txt"));
	 Scanner sc =new Scanner(System.in);
	  //File file = new File("file.txt");
	//	PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter(file)));
	//	sc.useDelimiter("(\\s)+|[,]");

	  while(sc.hasNext()){
		   //long sum=0;
	//	  int n=sc.nextInt(),m=sc.nextInt(),k=sc.nextInt();
		int   n=sc.nextInt();
		b=false;
	//	db((int)sc.next().charAt(0));
      char  c[][]=new char[2][n];

		 for(int i=0;i<n;i++){
			 String s=sc.next();
			 c[0][i]=s.charAt(0);
			 c[1][i]=s.charAt(1);
		 }

		 if( n==1 ){ System.out.println("YES");return;}

		 rep(c);

	  System.out.println(b? "YES":"NO");

		 }

}
	// db("Case #"+(k)+": "+c);
	 //	pw.println("Case #"+(k)+": "+c);

	 	//pw.flush();
	 	//pw.close();

   static void rep(char p[][]){
	   int a=p[0].length-1;
	   if( b )return;
	   if(a==0){ b=true; return; }
	  // db(p[0],p[1]);
	   String k="";
	   for(int i=0 ;i<=a;i++)k+=p[0][i]+p[1][i];

	   if( map.containsKey(k) && map.get(k) ) {return;}

	   if(  p[0][a]==p[0][a-1]   ||  p[1][a]==p[1][a-1]   ){
	   char np[][]=new char[2][a];
	   for(int i=0;i<a;i++){np[0][i]=p[0][i]; np[1][i]=p[1][i];}  np[0][a-1]=p[0][a];np[1][a-1]=p[1][a];
	     rep(np ); }

	   if(  0<=a-3 && (  p[0][a]==p[0][a-3]  || p[1][a]==p[1][a-3] ) ){
	   char np[][]=new char[2][a];
	   for(int i=0;i<a;i++){np[0][i]=p[0][i]; np[1][i]=p[1][i];}  np[0][a-3]=p[0][a];np[1][a-3]=p[1][a];
	     rep(np ); }

	   map.put(k, true);

   }

    static void db(Object... os){
	         System.err.println(Arrays.deepToString(os));

	}

}

/*class P implements Comparable<P>{
    int v,vv,t;
	P(int v,int vv,int t){
		this.v=v;
	    this.vv=vv;
	    this.t=t;
	}
	  public int compareTo(P x){
          return t-x.t;
	   }

}*/

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.StringTokenizer;

public class Solver {

    StringTokenizer st;
    BufferedReader in;
    PrintWriter out;

    public static void main(String[] args) throws NumberFormatException, IOException {
        Solver solver = new Solver();
        solver.open();
        long time = System.currentTimeMillis();
        solver.solve();
        if (!"true".equals(System.getProperty("ONLINE_JUDGE"))) {
            System.out.println("Spent time: " + (System.currentTimeMillis() - time));
        }
        solver.close();
    }

    public void open() throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
    }

    public String nextToken() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
    }

    public int nextInt() throws NumberFormatException, IOException {
        return Integer.parseInt(nextToken());
    }

    public long nextLong() throws NumberFormatException, IOException {
        return Long.parseLong(nextToken());
    }

    public double nextDouble() throws NumberFormatException, IOException {
        return Double.parseDouble(nextToken());
    }

    Card[] allCards;

    class Card {
        char d;
        char m;

        public Card(String s) {
            super();
            this.d = s.charAt(0);
            this.m = s.charAt(1);
        }

        public boolean check(Card card){
            return d==card.d || m==card.m;
        }

        @Override
        public String toString() {
            return d+""+m;
        }
    }

    class State {
        private String toStr = null;
        int last;
        Card[] cards = new Card[4];

        public State(int last) {
            this.last = last;
        }

        void generateNext(Queue<State> wherePlace){
            if (last>=1 && cards[3].check(cards[2])){
                State newState = new State(last-1);

                newState.cards[3] = cards[3];
                newState.cards[2] = cards[1];
                newState.cards[1] = cards[0];
                newState.cards[0] = last-4>=0 ? allCards[last-4] : null;

                wherePlace.offer(newState);
            }
            if (last>=3 && cards[3].check(cards[0])){
                State newState = new State(last-1);

                newState.cards[3] = cards[2];
                newState.cards[2] = cards[1];
                newState.cards[1] = cards[3];
                newState.cards[0] = last-4>=0 ? allCards[last-4] : null;

                wherePlace.offer(newState);
            }
        }

        @Override
        public String toString() {
            if (toStr==null) toStr = Arrays.toString(cards);
            return toStr;
        }
    }

    public void solve() throws NumberFormatException, IOException {
        Map<Integer,Map<String,State>> map = new HashMap<Integer, Map<String,State>>();

        int n = nextInt();

        allCards = new Card[n];
        for(int i=0;i<n;i++){
            allCards[i] = new Card(nextToken());
            map.put(i+1, new HashMap<String,State>());
        }

        Queue<State> queue = new LinkedList<Solver.State>();
        State firstState = new State(n-1);
        for(int i=n-1,j=3;i>=0 && i>=n-4;i--,j--){
            firstState.cards[j] = allCards[i];
        }
        queue.offer(firstState);
        while (!queue.isEmpty()){
            State next = queue.remove();
            if (next.last==0){
                out.println("YES");
                return;
            }else if (!map.get(next.last).containsKey(next.toString())){
                map.get(next.last).put(next.toString(), next);
                next.generateNext(queue);
            }
        }

        out.println("NO");
    }

    public void close() {
        out.flush();
        out.close();
    }

}

import java.util.HashSet;
import java.util.Scanner;

public class Main {

    /**
     * @param args
     */
    static int n;
    static String[] strs;
    static HashSet<String> hs=new HashSet<String>();
    static boolean ok(int x,int y)
    {
        return strs[x].charAt(0)==strs[y].charAt(0)
                || strs[x].charAt(1)==strs[y].charAt(1);
    }

    static boolean dfs(int x){
        if(x==0)return true;
        if(x>1){
            if(hs.contains(x+strs[x]+strs[x-1]+strs[x-2]))return false;
            if(x>2&&ok(x,x-3)){
                String t=strs[x-3];
                strs[x-3]=strs[x];
                if(dfs(x-1))return true;
                strs[x-3]=t;
            }
        }
        if(ok(x,x-1)){
            String t=strs[x-1];
            strs[x-1]=strs[x];
            if(dfs(x-1))return true;
            strs[x-1]=t;
        }
        if(x>1)hs.add(x+strs[x]+strs[x-1]+strs[x-2]);
        return false;
    }
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner in = new Scanner(System.in);
        n=in.nextInt();strs=new String[n];
        for(int i=0;i<n;i++)strs[i]=in.next();
        System.out.println(dfs(n-1)?"YES":"NO");
    }

}

import java.util.HashSet;
import java.util.Scanner;

public class Main {

    /**
     * @param args
     */
    static int n;
    static StringBuilder[] strs;
    static HashSet<String> hs=new HashSet<String>();
    static boolean ok(int x,int y)
    {
        return strs[x].charAt(0)==strs[y].charAt(0)
                || strs[x].charAt(1)==strs[y].charAt(1);
    }

    static boolean dfs(int x){
        if(x==0)return true;
        StringBuilder tmp=new StringBuilder(strs[x]);
//      System.out.println(tmp);
        if(x>1){
            if(hs.contains(tmp.append(strs[x-1]).append(strs[x-2]).append(x).toString()))return false;
            if(x>2&&ok(x,x-3)){
                StringBuilder t=strs[x-3];
                strs[x-3]=strs[x];
                if(dfs(x-1))return true;
                strs[x-3]=t;
            }
        }
        if(ok(x,x-1)){
            StringBuilder t=strs[x-1];
            strs[x-1]=strs[x];
            if(dfs(x-1))return true;
            strs[x-1]=t;
        }
        tmp=new StringBuilder(strs[x]);
        if(x>1)hs.add(tmp.append(strs[x-1]).append(strs[x-2]).append(x).toString());
        return false;
    }
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner in = new Scanner(System.in);
        n=in.nextInt();strs=new StringBuilder[n];
        for(int i=0;i<n;i++)strs[i]=new StringBuilder(in.next());
        System.out.println(dfs(n-1)?"YES":"NO");
    }

}

import java.util.*;

public class B {

	private static int n;
	private static String[] piles;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		piles = new String[n];
		for (int i = 0; i < n; i++) {
			piles[i] = sc.next();
		}
		sc.close();

		if (piles.length == 1) {
			System.out.println("YES");
		} else if (piles.length == 2) {
			if (canPile(piles[0], piles[1])) {
				System.out.println("YES");
			} else {
				System.out.println("NO");
			}
		} else {
			if (solve(piles[piles.length - 1], piles[piles.length - 2], piles[piles.length - 3], piles.length - 3)) {
				System.out.println("YES");
			} else {
				System.out.println("NO");
			}
		}

	}

	private static HashMap<Trio, Boolean> map = new HashMap<>();

	private static boolean solve(String last, String secondLast, String thirdLast, int remaining) {
		Trio key = new Trio(last, secondLast, thirdLast, remaining);
		if (map.containsKey(key))
			return map.get(key);

		if (remaining == 0) {
			if (canPile(last, secondLast) && canPile(last, thirdLast)) {
				map.put(key, true);
				return true;
			} else {
				map.put(key, false);
				return false;
			}
		}
		if (canPile(last, secondLast) && solve(last, thirdLast, piles[remaining - 1], remaining - 1)) {
			map.put(key, true);
			return true;
		}
		if (canPile(last, piles[remaining - 1]) && solve(secondLast, thirdLast, last, remaining - 1)) {
			map.put(key, true);
			return true;
		}
		map.put(key, false);
		return false;
	}

	private static boolean canPile(String a, String b) {
		return a.charAt(0) == b.charAt(0) || a.charAt(1) == b.charAt(1);
	}

	private static class Trio {
		String last;
		String secondLast;
		String thirdLast;
		int remaining;

		public Trio(String a, String b, String c, int left) {
			this.last = a;
			this.secondLast = b;
			this.thirdLast = c;
			this.remaining = left;
		}

		public boolean equals(Object o) {
			if (this == o)
				return true;
			if (o == null || getClass() != o.getClass())
				return false;

			Trio o2 = (Trio) o;

			if (remaining != o2.remaining)
				return false;
			if (!last.equals(o2.last))
				return false;
			if (!secondLast.equals(o2.secondLast))
				return false;
			if (!thirdLast.equals(o2.thirdLast))
				return false;

			return true;

		}

		public int hashCode() {
			int result = last.hashCode();
			result = 17 * result + secondLast.hashCode();
			result = 17 * result + thirdLast.hashCode();
			result = 17 * result + remaining;
			return result;
		}
	}

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Scanner;
import java.util.TreeMap;
import java.util.TreeSet;

import sun.reflect.generics.tree.Tree;

import static java.lang.Math.*;

public class A {

    HashMap<Deck, Boolean> decs = new HashMap<Deck, Boolean>();

    boolean can(List<Card> deck) {
        if (deck.size() == 1)
            return true;
        Deck ddeck = new Deck(deck);
        if (decs.containsKey(ddeck))
            return decs.get(ddeck);

        Card last = deck.get(deck.size() - 1);

        boolean cc = false;
        if (deck.get(deck.size() - 2).can(last)) {
            List<Card> deck2 = new ArrayList<Card>();
            deck2.addAll(deck);
            deck2.set(deck.size() - 2, last);
            deck2.remove(deck.size()-1);
            cc |= can(deck2);
        }
        if (!cc && deck.size() > 3 && deck.get(deck.size() - 4).can(last)) {
            List<Card> deck2 = new ArrayList<Card>();
            deck2.addAll(deck);
            deck2.set(deck.size() - 4, last);
            deck2.remove(deck.size()-1);
            cc |= can(deck2);
        }

        decs.put(ddeck, cc);
        return cc;

    }

    public void run() throws IOException {

        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));

        int n = Integer.parseInt(bf.readLine());

        String[] s = bf.readLine().split(" ");
        List<Card> cards = new ArrayList<Card>();
        for (int i = 0; i < s.length; i++)
            cards.add(new Card(s[i]));
        System.out.println(can(cards) ? "YES" : "NO");

    }

    public static void main(String[] args) throws IOException {
        A a = new A();
        a.run();
    }
}

class Card {
    char[] c;
    String s;

    public Card(String s) {
        this.s = s;
        c = s.toCharArray();
    }

    public boolean can(Card d) {
        return d.c[0] == c[0] || d.c[1] == c[1];
    }

    @Override
    public String toString() {
        return s;
    }

    @Override
    public boolean equals(Object obj) {
        return s.equals(((Card) obj).s);
    }

    @Override
    public int hashCode() {
        return new String(c).hashCode();
    }
}

class Deck {
    List<Card> cards;

    public Deck(List<Card> cards_) {
        this.cards = new ArrayList<Card>();
        this.cards.addAll(cards_);
    }

    @Override
    public boolean equals(Object arg0) {
        return toString().equals(arg0.toString());
    }

    @Override
    public int hashCode() {
        return toString().hashCode();
    }

    @Override
    public String toString() {

        return cards.toString();
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws IOException {
		new Thread(null, new Runnable() {
			public void run() {
				try {
					long prevTime = System.currentTimeMillis();
					new Main().run();
					System.err.println("Total time: "
							+ (System.currentTimeMillis() - prevTime) + " ms");
					System.err.println("Memory status: " + memoryStatus());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}, "1", 1L << 24).start();
	}

	void run() throws IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		Object o = solve();
		if (o != null)
			out.println(o);
		out.close();
		in.close();
	}

	private Object solve() throws IOException {
		int n = ni();
		String[] cards = in.readLine().split(" ");
		boolean[][] matrix = new boolean[n][n];
		for (int i = 0; i < n; i++)
			for (int j = 0; j < n; j++)
				matrix[i][j] = cards[i].charAt(0) == cards[j].charAt(0)
						|| cards[i].charAt(1) == cards[j].charAt(1);

		List<Integer> lasts = new LinkedList<Integer>();
		for (int i = Math.max(n - 3, 0); i < n; i++)
			lasts.add(i);
		if (n <= 3) {
			if (base(matrix, lasts))
				return "YES";
			return "NO";
		}
		Map<State, Boolean> dp = new HashMap<State, Boolean>(55 * 55 * 55 * 55);
		State s = new State(n - 4, lasts);
		boolean ret = go(matrix, dp, s);
		return (ret ? "YES" : "NO");
	}

	private boolean go(boolean[][] matrix, Map<State, Boolean> dp, State s) {
		if (s.index == -1)
			return base(matrix, s.last);
		if (dp.containsKey(s))
			return dp.get(s);

		boolean ret = false;
		if (matrix[s.last.get(2)][s.last.get(1)]) {
			List<Integer> list1 = new LinkedList<Integer>(s.last);
			list1.remove(1);
			list1.add(0, s.index);
			State s1 = new State(s.index - 1, list1);
			ret = go(matrix, dp, s1);
		}
		if (matrix[s.last.get(2)][s.index]) {
			List<Integer> list2 = new LinkedList<Integer>(s.last);
			list2.add(0, list2.remove(2));
			State s2 = new State(s.index - 1, list2);
			ret |= go(matrix, dp, s2);
		}
		dp.put(s, ret);
		return ret;
	}

	private boolean base(boolean[][] matrix, List<Integer> list) {
		while (list.size() > 1) {
			if (!matrix[list.get(list.size() - 1)][list.get(list.size() - 2)])
				return false;
			list.remove(list.size() - 2);
		}
		return true;
	}

	private static class State {
		public final int index;
		public final List<Integer> last;
		private int hash;

		public State(int index, List<Integer> last) {
			super();
			this.index = index;
			this.last = last;
			hash += index;
			int base = 52;
			for (int a : last) {
				hash += a * base;
				base *= 52;
			}
		}

		@Override
		public int hashCode() {
			return hash;
		}

		@Override
		public boolean equals(Object obj) {
			if (this == obj)
				return true;
			if (obj == null)
				return false;
			if (getClass() != obj.getClass())
				return false;
			State other = (State) obj;

			return hash == other.hash;
		}

	}

	BufferedReader in;
	PrintWriter out;
	StringTokenizer st = new StringTokenizer("");

	String nextToken() throws IOException {
		while (!st.hasMoreTokens())
			st = new StringTokenizer(in.readLine());
		return st.nextToken();
	}

	int ni() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nl() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nd() throws IOException {
		return Double.parseDouble(nextToken());
	}

	int[] nia(int size) throws IOException {
		int[] ret = new int[size];
		for (int i = 0; i < size; i++)
			ret[i] = ni();
		return ret;
	}

	long[] nla(int size) throws IOException {
		long[] ret = new long[size];
		for (int i = 0; i < size; i++)
			ret[i] = nl();
		return ret;
	}

	double[] nda(int size) throws IOException {
		double[] ret = new double[size];
		for (int i = 0; i < size; i++)
			ret[i] = nd();
		return ret;
	}

	String nextLine() throws IOException {
		st = new StringTokenizer("");
		return in.readLine();
	}

	boolean EOF() throws IOException {
		while (!st.hasMoreTokens()) {
			String s = in.readLine();
			if (s == null)
				return true;
			st = new StringTokenizer(s);
		}
		return false;
	}

	void printRepeat(String s, int count) {
		for (int i = 0; i < count; i++)
			out.print(s);
	}

	void printArray(int[] array) {
		for (int i = 0; i < array.length; i++) {
			if (i > 0)
				out.print(' ');
			out.print(array[i]);
		}
		out.println();
	}

	void printArray(long[] array) {
		for (int i = 0; i < array.length; i++) {
			if (i > 0)
				out.print(' ');
			out.print(array[i]);
		}
		out.println();
	}

	void printArray(double[] array) {
		for (int i = 0; i < array.length; i++) {
			if (i > 0)
				out.print(' ');
			out.print(array[i]);
		}
		out.println();
	}

	void printArray(double[] array, String spec) {
		for (int i = 0; i < array.length; i++) {
			if (i > 0)
				out.print(' ');
			out.printf(Locale.US, spec, array[i]);
		}
		out.println();
	}

	void printArray(Object[] array) {
		boolean blank = false;
		for (Object x : array) {
			if (blank)
				out.print(' ');
			else
				blank = true;
			out.print(x);
		}
		out.println();
	}

	@SuppressWarnings("rawtypes")
	void printCollection(Collection collection) {
		boolean blank = false;
		for (Object x : collection) {
			if (blank)
				out.print(' ');
			else
				blank = true;
			out.print(x);
		}
		out.println();
	}

	static String memoryStatus() {
		return (Runtime.getRuntime().totalMemory()
				- Runtime.getRuntime().freeMemory() >> 20)
				+ "/" + (Runtime.getRuntime().totalMemory() >> 20) + " MB";
	}
}

import java.io.*;
import java.util.*;
import java.math.*;

public class B implements Runnable {
	BufferedReader in;
	PrintWriter out;
	StringTokenizer st;
	Random rnd;

	String[] cards;
	HashMap<String, Boolean> cache = new HashMap<String, Boolean>();

	boolean rec(String remain, String lasts) {
		//out.println(remain + " " + lasts);

		if(remain.length() == 0 && lasts.length() == 2) {
			return true;
		} else if(cache.containsKey(remain + lasts)) {
			return cache.get(remain + lasts);
		}

		boolean res = false;

		if(lasts.charAt(0) == lasts.charAt(2) || lasts.charAt(1) == lasts.charAt(3)) {
			String newLasts = lasts.substring(0, 2) + lasts.substring(4);
			String newRemain = "";

			if(remain.length() > 0) {
				newLasts += remain.substring(0, 2);
				newRemain = remain.substring(2);
			}

			res |= rec(newRemain, newLasts);
		}

		if(lasts.length() == 8 && (lasts.charAt(0) == lasts.charAt(6) || lasts.charAt(1) == lasts.charAt(7))) {
			String newLasts = lasts.substring(2, 6) + lasts.substring(0, 2);
String newRemain = "";

			if(remain.length() > 0) {
				newLasts += remain.substring(0, 2);
				newRemain = remain.substring(2);
			}

			res |= rec(newRemain, newLasts);
		}

		cache.put(remain + lasts, res);

		return res;
	}

	void solve() throws IOException {
		int n = nextInt();

		if (n == 1) {
			out.println("YES");
			return;
		}

		cards = new String[n];
		String allCards = "";

		for (int i = 0; i < n; i++) {
			cards[i] = nextToken();
		}

		for(int i = n - 1; i >= 0; i--) {
			allCards += cards[i];
		}

		int cutPos = Math.min(allCards.length(), 8);
		String remain = allCards.substring(cutPos);
		String lasts = allCards.substring(0, cutPos);

		out.println(rec(remain, lasts) ? "YES" : "NO");

	}

	public static void main(String[] args) {
		final boolean oldChecker = false;

		if (oldChecker) {
			new Thread(null, new B(), "yarrr", 1 << 24).start();
		} else {
			new B().run();
		}
	}

	public void run() {
		try {
			final String className = this.getClass().getName().toLowerCase();

			try {
				in = new BufferedReader(new FileReader(className + ".in"));
				out = new PrintWriter(new FileWriter(className + ".out"));
			} catch (FileNotFoundException e) {
				in = new BufferedReader(new InputStreamReader(System.in));
				out = new PrintWriter(System.out);
			}

			rnd = new Random();

			solve();

			out.close();
		} catch (IOException e) {
			e.printStackTrace();
			System.exit(42);
		}
	}

	String nextToken() throws IOException {
		while (st == null || !st.hasMoreTokens()) {
			String line = in.readLine();

			if (line == null) {
				return null;
			}

			st = new StringTokenizer(line);
		}

		return st.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
}

import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import java.io.*;
import java.math.*;
import java.text.*;
import java.util.*;

/*
br = new BufferedReader(new FileReader("input.txt"));
pw = new PrintWriter(new BufferedWriter(new FileWriter("output.txt")));
br = new BufferedReader(new InputStreamReader(System.in));
pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
 */

public class Main {
  private static BufferedReader br;
  private static StringTokenizer st;
  private static PrintWriter pw;

  static String[] list;

  public static void main(String[] args) throws IOException {
    br = new BufferedReader(new InputStreamReader(System.in));
    pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    //int qq = 1;
    int qq = Integer.MAX_VALUE;
    //int qq = readInt();
    for(int casenum = 1; casenum <= qq; casenum++)  {
      int n = readInt();
      seen = new Set[n];
      for(int i = 0; i < n; i++) {
        seen[i] = new HashSet<Integer>();
      }
      list = new String[n];
      for(int i = 0; i < n; i++) {
        list[i] = nextToken();
      }
      pw.println(can(n-1) ? "YES" : "NO");
    }
    pw.close();
  }

  public static boolean can(int n) {
    if(n==0) {
      return true;
    }
    int hash = hash(n);
    if(!seen[n].add(hash)) return false;
    if(list[n].charAt(0) == list[n-1].charAt(0) || list[n].charAt(1) == list[n-1].charAt(1)) {
      String save = list[n-1];
      list[n-1] = list[n];
      if(can(n-1)) {
        return true;
      }
      list[n-1] = save;
    }
    if(n-3 >= 0 && (list[n].charAt(0) == list[n-3].charAt(0) || list[n].charAt(1) == list[n-3].charAt(1))) {
      String save = list[n-3];
      list[n-3] = list[n];
      if(can(n-1)) {
        return true;
      }
      list[n-3] = save;
    }
    return false;
  }

  static Set<Integer>[] seen;

  public static int hash(int n) {
    int ret = 0;
    for(int i = 0; i <= n; i++) {
      ret *= 3137;
      ret += list[i].hashCode();
    }
    return ret;
  }

  private static void exitImmediately() {
    pw.close();
    System.exit(0);
  }

  private static long readLong() throws IOException {
    return Long.parseLong(nextToken());
  }

  private static double readDouble() throws IOException {
    return Double.parseDouble(nextToken());
  }

  private static int readInt() throws IOException {
    return Integer.parseInt(nextToken());
  }

  private static String nextToken() throws IOException  {
    while(st == null || !st.hasMoreTokens())  {
      if(!br.ready()) {
        exitImmediately();
      }
      st = new StringTokenizer(br.readLine().trim());
    }
    return st.nextToken();
  }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;

public class CF130B {

	class Card {
		private final static String vs = "23456789TJQKA";
		private final static String ss = "SDHC";
		int v, s;
		String str;

		Card(String str) {
			this.str = str;
			v = vs.indexOf(str.charAt(0));
			s = ss.indexOf(str.charAt(1));
		}

		public int hashCode() {
			return (v << 2) | s;
		}

		public boolean equals(Object o) {
			Card c = (Card) o;
			return v == c.v || s == c.s;
		}

		public String toString() {
			return str;
		}
	}

	private void work() throws IOException {
		Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(
				System.in)));
		while (sc.hasNextInt()) {
			int n = sc.nextInt();
			Card[] c = new Card[n];
			for (int i = 0; i < n; i++) {
				c[i] = new Card(sc.next());
			}
			List<Card> list = Arrays.asList(c);
			Set<List<Card>> seen = new HashSet<List<Card>>();
			seen.add(list);
			Queue<List<Card>> q = new LinkedList<List<Card>>();
			q.add(list);
			boolean ok = false;
			while (!q.isEmpty()) {
				list = q.poll();
				if (list.size() == 1) {
					ok = true;
					break;
				}
				if (list.get(list.size() - 1).equals(list.get(list.size() - 2))) {
					List<Card> newList = new ArrayList<Card>(list);
					newList.set(list.size() - 2, list.get(list.size() - 1));
					newList.remove(list.size() - 1);
					if (!seen.contains(newList)) {
						seen.add(newList);
						q.add(newList);
					}
				}
				if (list.size() > 3
						&& list.get(list.size() - 1).equals(
								list.get(list.size() - 4))) {
					List<Card> newList = new ArrayList<Card>(list);
					newList.set(list.size() - 4, list.get(list.size() - 1));
					newList.remove(list.size() - 1);
					if (!seen.contains(newList)) {
						seen.add(newList);
						q.add(newList);
					}
				}
			}
//			System.out.println(seen);
			System.out.println(ok ? "YES" : "NO");
		}
		System.out.close();
	}

	public static void main(String[] args) throws IOException {
		new CF130B().work();
	}

}

import java.util.*;
import java.io.*;

public class Main{

	int n;
	String s[];
	int dp[][][][];
	public void run(){
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		if (n==1){
			System.out.println("YES");
			return;
		}
		s = new String[n];
		for(int i=0;i<n;i++) s[i] = in.next();
		dp = new int[n+1][n+1][n+1][n+1];
		for(int i=0;i<=n;i++)
			for(int j=0;j<=n;j++)
				for(int k=0;k<=n;k++)
					Arrays.fill(dp[i][j][k], -1);

		if (dfs(n-1, n-3, n-2, n-1) == 1){
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}
	}

	private int dfs(int at, int a, int b, int c){
		if (at == 1){
			if (isOk(b, c))
				return 1;
			return 0;
		}
		if (a < 0 || b < 0 || c < 0)
			return 0;
		if (dp[at][a][b][c] != -1)
			return dp[at][a][b][c];
		int ret = 0;
		if (isOk(b, c)){
			ret = Math.max(ret, dfs(at-1, at-3,a,c));
		}

		if (isOk(c, at-3)){
			ret = Math.max(ret, dfs(at-1, c, a, b));
		}
		return dp[at][a][b][c] = ret;
	}

	private boolean isOk(int a, int b){
		if (a < 0 || b < 0)
			return false;
		return s[a].charAt(0) == s[b].charAt(0) || s[a].charAt(1) == s[b].charAt(1);
	}

	public static void main(String[] args){
		new Main().run();
	}
}

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.SortedSet;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

/**
 * #
 *
 * @author pttrung
 */
public class B_Round_130_Div2 {

	public static long MOD = 1000000007;
	static HashSet<String> set = new HashSet();

	public static void main(String[] args) throws FileNotFoundException {
		// PrintWriter out = new PrintWriter(new FileOutputStream(new File(
		// "output.txt")));
		PrintWriter out = new PrintWriter(System.out);
		Scanner in = new Scanner();
		int n = in.nextInt();
		String[] data = new String[n];
		for (int i = 0; i < n; i++) {
			data[i] = in.next();
		}
		boolean v = cal(n - 1, data);
		if (v) {
			out.println("YES");
		} else {
			out.println("NO");
		}
		out.close();
	}

	static boolean cal(int index, String[] data) {

		if (index == 0) {
			return true;
		}
		StringBuilder builder = new StringBuilder();
		for(int i = 0; i <= index; i++){
			builder.append(data[i]);
		}
		String v = builder.toString();
		if (set.contains(v)) {
			return false;
		}
		boolean result = false;

		if (index >= 3 && isMatch(data[index], data[index - 3])) {
			String tmp = data[index - 3];
			data[index - 3] = data[index];
			result = cal(index - 1, data);
			if (result) {
				return true;
			}
			data[index - 3] = tmp;
		}
		if (isMatch(data[index], data[index - 1])) {
			String tmp = data[index - 1];
			data[index - 1] = data[index];
			result = cal(index - 1, data);
			if (result) {
				return true;
			}
			data[index - 1] = tmp;
		}

		set.add(v);
		return false;
	}

	static boolean isMatch(String a, String b) {
		if (a.charAt(0) == b.charAt(0)) {
			return true;
		}
		return a.charAt(1) == b.charAt(1);
	}

	public static int[] KMP(String val) {
		int i = 0;
		int j = -1;
		int[] result = new int[val.length() + 1];
		result[0] = -1;
		while (i < val.length()) {
			while (j >= 0 && val.charAt(j) != val.charAt(i)) {
				j = result[j];
			}
			j++;
			i++;
			result[i] = j;
		}
		return result;

	}

	public static boolean nextPer(int[] data) {
		int i = data.length - 1;
		while (i > 0 && data[i] < data[i - 1]) {
			i--;
		}
		if (i == 0) {
			return false;
		}
		int j = data.length - 1;
		while (data[j] < data[i - 1]) {
			j--;
		}
		int temp = data[i - 1];
		data[i - 1] = data[j];
		data[j] = temp;
		Arrays.sort(data, i, data.length);
		return true;
	}

	public static int digit(long n) {
		int result = 0;
		while (n > 0) {
			n /= 10;
			result++;
		}
		return result;
	}

	public static double dist(long a, long b, long x, long y) {
		double val = (b - a) * (b - a) + (x - y) * (x - y);
		val = Math.sqrt(val);
		double other = x * x + a * a;
		other = Math.sqrt(other);
		return val + other;

	}

	public static class Point implements Comparable<Point> {

		int x, y;

		public Point(int start, int end) {
			this.x = start;
			this.y = end;
		}

		@Override
		public int hashCode() {
			int hash = 5;
			hash = 47 * hash + this.x;
			hash = 47 * hash + this.y;
			return hash;
		}

		@Override
		public boolean equals(Object obj) {
			if (obj == null) {
				return false;
			}
			if (getClass() != obj.getClass()) {
				return false;
			}
			final Point other = (Point) obj;
			if (this.x != other.x) {
				return false;
			}
			if (this.y != other.y) {
				return false;
			}
			return true;
		}

		@Override
		public int compareTo(Point o) {
			return x - o.x;
		}
	}

	public static class FT {

		long[] data;

		FT(int n) {
			data = new long[n];
		}

		public void update(int index, long value) {
			while (index < data.length) {
				data[index] += value;
				index += (index & (-index));
			}
		}

		public long get(int index) {
			long result = 0;
			while (index > 0) {
				result += data[index];
				index -= (index & (-index));
			}
			return result;

		}
	}

	public static long gcd(long a, long b) {
		if (b == 0) {
			return a;
		}
		return gcd(b, a % b);
	}

	public static long pow(long a, long b) {
		if (b == 0) {
			return 1;
		}
		if (b == 1) {
			return a;
		}
		long val = pow(a, b / 2);
		if (b % 2 == 0) {
			return val * val % MOD;
		} else {
			return val * (val * a % MOD) % MOD;

		}
	}

	static class Scanner {

		BufferedReader br;
		StringTokenizer st;

		public Scanner() throws FileNotFoundException {
			// System.setOut(new PrintStream(new
			// BufferedOutputStream(System.out), true));
			br = new BufferedReader(new InputStreamReader(System.in));
			// br = new BufferedReader(new InputStreamReader(new
			// FileInputStream(new File("input.txt"))));
		}

		public String next() {

			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception e) {
					throw new RuntimeException();
				}
			}
			return st.nextToken();
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public String nextLine() {
			st = null;
			try {
				return br.readLine();
			} catch (Exception e) {
				throw new RuntimeException();
			}
		}

		public boolean endLine() {
			try {
				String next = br.readLine();
				while (next != null && next.trim().isEmpty()) {
					next = br.readLine();
				}
				if (next == null) {
					return true;
				}
				st = new StringTokenizer(next);
				return st.hasMoreTokens();
			} catch (Exception e) {
				throw new RuntimeException();
			}
		}
	}
}

import java.io.*;

public class B {
	int map[];
	int dp[][][][];
	int n;
	String[] cards;

	boolean isValid(int s1, int s2){
		if(s2 < 0) return false;
		return (cards[s1].charAt(0)==cards[s2].charAt(0) || cards[s1].charAt(1)==cards[s2].charAt(1));
	}

	boolean solve(int pos, int a, int b, int c, int d){
		if(pos==1) return true;

		if(dp[a][b][c][d] != 0)
			return dp[a][b][c][d] == 1;

		int aa = pos-4>=0? pos-4:0;
		if(isValid(d-1, a-1)){
			dp[a][b][c][d] = solve(pos-1, aa, d, b, c)? 1:2;
		}

		if(dp[a][b][c][d]!=1 && isValid(d-1, c-1)){
			dp[a][b][c][d] = solve(pos-1, aa, a, b, d)? 1:2;
		}

		if(dp[a][b][c][d]==0) dp[a][b][c][d]=2;

		return dp[a][b][c][d]==1;
	}

	void run() throws IOException{
		dp = new int[70][70][70][70];

		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		n = Integer.parseInt(bf.readLine());
		cards = bf.readLine().trim().split("[ ]+");

		int a, b, c, d;
		a = n<4? 0:n-3;
		b = n<3? 0:n-2;
		c = n<2? 0:n-1;
		d = n;
		System.out.println(solve(n, a, b, c, d)? "YES" : "NO");

	}

	public static void main(String[] args) throws IOException{
		new B().run();
	}
}

import java.util.*;
import java.io.*;

public class Main{

	int n;
	String a[];
	HashSet<String> hs;
	public void run(){
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		a = new String[n];
		for(int i=0;i<n;i++) a[i] = in.next();
		hs = new HashSet<String>();

		if (dfs(n-1)){
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}
	}

	private boolean dfs(int x){
		if (x == 0) return true;
		if (x > 1)
			if (hs.contains(x + a[x] + a[x-1] + a[x-2]))
				return false;
		if (isOk(a[x], a[x-1])){
			String t = a[x-1];
			a[x-1] = a[x];
			if (dfs(x-1)) return true;
			a[x-1] = t;
		}

		if (x - 3 >= 0 && isOk(a[x], a[x-3])){
			String t = a[x-3];
			a[x-3] = a[x];
			if (dfs(x-1)) return true;
			a[x-3] = t;
		}
		if (x > 1) hs.add(x + a[x] + a[x-1] + a[x-2]);
		return false;
	}

	private boolean isOk(String a, String b){
		return a.charAt(0) == b.charAt(0) || a.charAt(1) == b.charAt(1);
	}

	public static void main(String[] args){
		new Main().run();
	}
}

import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class B208 {
    static boolean[][] isok;
    static int[] index;
    Boolean visited[][][][];

    boolean search(int depth , int a , int b , int c) {
        if (depth == 0) {
            return true;
        }
        if( depth == 1){
            return isok[a][b];
        }
        if( visited[depth][a][b][c] != null){
            return visited[depth][a][b][c];
        }
        boolean res = false;
        if (depth >= 3 && isok[depth - 3][a]) {
            res = search(depth - 1,b,c,a);
        }
        if( res ) return visited[depth][a][b][c] = true;

        if (isok[a][b]) {
            res = search(depth - 1,a,c,depth-3);
        }
        return visited[depth][a][b][c] = res;
    }

    public void solve(Scanner cin, PrintWriter cout) {
        int n = cin.nextInt();
        String[] cards = new String[n];
        Map<String, Integer> count = new HashMap<String, Integer>();
        for (int i = 0; i < n; i++) {
            cards[i] = cin.next();
            String key = "0" + cards[i].charAt(0);
            int cnt = 0;
            if (count.containsKey(key)) {
                cnt = count.get(key);
            }
            count.put(key, cnt + 1);
            key = "1" + cards[i].charAt(1);
            cnt = 0;
            if (count.containsKey(key)) {
                cnt = count.get(key);
            }
            count.put(key, cnt + 1);

        }
        isok = new boolean[n][n];
        visited = new Boolean[n][n][n][n];
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                if (cards[i].charAt(0) == cards[j].charAt(0)
                        || cards[i].charAt(1) == cards[j].charAt(1)) {
                    isok[i][j] = isok[j][i] = true;
                }
            }
            isok[i][i] = true;
        }
        boolean ok = true;
        if( n > 1) {
            for (int i = 0; ok && i < n; i++) {
                if (count.get("0" + cards[i].charAt(0)) == 1
                        && count.get("1" + cards[i].charAt(1)) == 1) {
                    ok = false;
                }
            }
        }
        cout.println(ok ? search(n-1, n-1,n-2,n-3) ? "YES" : "NO" : "NO");
    }

    public static void main(String[] args) {
        B208 solution = new B208();
        Scanner cin = new Scanner(System.in);
        PrintWriter cout = new PrintWriter(System.out);
        solution.solve(cin, cout);
        cin.close();
        cout.close();
    }
}

import java.util.Scanner;

public class B {

    static String[]s;
    static boolean[][][][]calculated, f;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        s = new String[n+1];
        for (int i = 1; i <= n; i++) {
            s[i] = sc.next();
        }
        calculated = new boolean[n+1][n+1][n+1][n+1];
        f = new boolean[n+1][n+1][n+1][n+1];
        if (possible(n, n, n-1, n-2))
            System.out.println("YES");
        else
            System.out.println("NO");
    }

    private static boolean possible(int pos, int a, int b, int c) {
        if (c < 0)
            return true;
        if (calculated[pos][a][b][c])
            return f[pos][a][b][c];
        calculated[pos][a][b][c] = true;
        if (pos==1) {
            return f[pos][a][b][c] = true;
        }
        boolean res = false;
        if (check(a, b))
            res = possible(pos-1, a, c, pos-3);
        if (!res && pos-3 > 0 && check(a, pos-3))
            res = possible(pos-1, b, c, a);
        return f[pos][a][b][c] = res;
    }

    private static boolean check(int a, int b) {
        return s[a].charAt(0)==s[b].charAt(0) || s[a].charAt(1)==s[b].charAt(1);
    }
}

//package cbr131;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Set;

public class B {

	private class State {
		@Override
		public int hashCode() {
			final int prime = 31;
			int result = 1;
			result = prime * result + getOuterType().hashCode();
			result = prime * result + ((A == null) ? 0 : A.hashCode());
			result = prime * result + ((B == null) ? 0 : B.hashCode());
			result = prime * result + ((C == null) ? 0 : C.hashCode());
			result = prime * result + pilesLeft;
			return result;
		}
		@Override
		public boolean equals(Object obj) {
			if (this == obj)
				return true;
			if (obj == null)
				return false;
			if (getClass() != obj.getClass())
				return false;
			State other = (State) obj;
			if (!getOuterType().equals(other.getOuterType()))
				return false;
			if (A == null) {
				if (other.A != null)
					return false;
			} else if (!A.equals(other.A))
				return false;
			if (B == null) {
				if (other.B != null)
					return false;
			} else if (!B.equals(other.B))
				return false;
			if (C == null) {
				if (other.C != null)
					return false;
			} else if (!C.equals(other.C))
				return false;
			if (pilesLeft != other.pilesLeft)
				return false;
			return true;
		}
		public int pilesLeft;
		public String A, B, C;

		private B getOuterType() {
			return B.this;
		}

		public State(int pilesLeft, String a, String b, String c) {
			super();
			this.pilesLeft = pilesLeft;
			A = a;
			B = b;
			C = c;
		}
	}

	private boolean canPutOnTop(String pile1, String pile2) {
		if (pile1.length() != 2 || pile2.length() != 2) {
			return false;
		}

		return pile1.charAt(0) == pile2.charAt(0) || pile1.charAt(1) == pile2.charAt(1);
	}

	private boolean doBfs(int n, String[] piles) {
		Queue<State> queue = new LinkedList<State>();
		Set<State> used = new HashSet<State>();

		if (n <= 1) {
			return true;
		}

		if (n == 2) {
			return canPutOnTop(piles[0], piles[1]);
		}

		queue.add(new State(n, piles[n - 3], piles[n - 2], piles[n - 1]));
		used.add(new State(n, piles[n - 3], piles[n - 2], piles[n - 1]));

		while(!queue.isEmpty()) {
			State situation = queue.poll();
			if (situation.pilesLeft == 3) {
				if (canPutOnTop(situation.A, situation.C) && canPutOnTop(situation.B, situation.C)) {
					return true;
				}

				continue;
			}

			if (canPutOnTop(piles[situation.pilesLeft - 4], situation.C)) {
				State next = new State(situation.pilesLeft - 1, situation.C, situation.A, situation.B);
				if (!used.contains(next)) {
					queue.add(next);
					used.add(next);
				}
			}

			if (canPutOnTop(situation.B, situation.C)) {
				State next = new State(situation.pilesLeft - 1, piles[situation.pilesLeft - 4], situation.A, situation.C);
				if (!used.contains(next)) {
					queue.add(next);
					used.add(next);
				}
			}
		}

		return false;
	}

	public void solve() {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

		String[] piles = null;
		int n = 0;
		try {
			n = Integer.parseInt(in.readLine());
			piles = in.readLine().split(" ");
		} catch (IOException e) {
			e.printStackTrace();
		}

		boolean answ = doBfs(n, piles);
		if (answ) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}

	public static void main(String[] args) {
		B solver = new B();
		solver.solve();
	}
}

import java.util.*;

public class LittleElephantInterval {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);

		int N = Integer.parseInt(in.nextLine());
		int x = N - 1;
		Queue<String[]> allCards = new LinkedList<String[]>();
		HashSet<String> lineup = new HashSet<String>();
		String l = in.nextLine();
		lineup.add(l);
		allCards.add(l.split(" "));
		while (!allCards.isEmpty()) {

			String[] cards = allCards.poll();
			x = cards.length - 1;
			if (x == 0) {
				break;
			}

			if (x - 1 > -1 && valid(cards[x], cards[x - 1])) {
				String[] c = put(Arrays.copyOf(cards, x + 1), x, x - 1);
				String[] d= Arrays.copyOf(c, c.length - 1);
				String l1  = Arrays.toString(d);
				if(!lineup.contains(l1)){
					allCards.add(d);
					lineup.add(l1);
				}
			}
			if (x - 3 > -1 && valid(cards[x], cards[x - 3])) {
				String[] c = put(Arrays.copyOf(cards, x + 1), x, x - 3);
				String [] d =  Arrays.copyOf(c, c.length - 1);
				String l1  = Arrays.toString(d);
				if(!lineup.contains(l1)){
					allCards.add(d);
					lineup.add(l1);
				}
			}
		}

		System.out.println(x == 0 ? "YES" : "NO");
	}

	private static String[] put(String[] cards, int x, int i) {
		cards[i] = cards[x];
		cards[x] = "EMPTY";
		return cards;
	}

	private static boolean valid(String l, String r) {
		return l.charAt(0) == r.charAt(0) || l.charAt(1) == r.charAt(1);
	}
}

import java.lang.*;
import java.math.BigInteger;
import java.io.*;
import java.util.*;

public class Solution implements Runnable{
    public static BufferedReader br;
    public static PrintWriter out;
    public static StringTokenizer stk;
    public static boolean isStream = true;

    public static void main(String[] args) throws IOException {
    	if (isStream) {
            br = new BufferedReader(new InputStreamReader(System.in));
        } else {
            br = new BufferedReader(new FileReader("in.txt"));
        }
        out = new PrintWriter(System.out);
        new Thread(new Solution()).start();
    }

    public void loadLine() {
        try {
            stk = new StringTokenizer(br.readLine());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public String nextLine() {
        try {
            return br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
            return "";
        }
    }

    public String nextWord() {
        while (stk==null||!stk.hasMoreTokens()) loadLine();
        return stk.nextToken();
    }

    public Integer nextInt() {
        while (stk==null||!stk.hasMoreTokens()) loadLine();
        return Integer.valueOf(stk.nextToken());
    }

    public Long nextLong() {
        while (stk==null||!stk.hasMoreTokens()) loadLine();
        return Long.valueOf(stk.nextToken());
    }

    public Double nextDouble() {
        while (stk==null||!stk.hasMoreTokens()) loadLine();
        return Double.valueOf(stk.nextToken());
    }

    public Float nextFloat() {
        while (stk==null||!stk.hasMoreTokens()) loadLine();
        return Float.valueOf(stk.nextToken());
    }

    public void run() {
    	int n = nextInt();
    	String[] ss = new String[n];
    	for (int i = 0; i< n; i++) {
    		ss[i] = nextWord();
    	}
    	boolean ans = false;
    	if (n >= 3) {
			HashSet<String> used = new HashSet<String>();
			LinkedList<String> list = new LinkedList<String>();
			used.add(n+" "+ss[n-3]+" "+ss[n-2]+" "+ss[n-1]);
			list.addFirst(n+" "+ss[n-3]+" "+ss[n-2]+" "+ss[n-1]);
			while (list.size() > 0) {
				String[] c = list.removeLast().split(" ");
				int k = Integer.parseInt(c[0]);
				if (k == 3) {
					if (c[2].charAt(0) == c[3].charAt(0) || c[2].charAt(1) == c[3].charAt(1)) {
						if (c[1].charAt(0) == c[3].charAt(0) || c[1].charAt(1) == c[3].charAt(1)) {
							ans = true;
						}
					}
					continue;
				}
				if (c[2].charAt(0) == c[3].charAt(0) || c[2].charAt(1) == c[3].charAt(1)) {
					String next = (k-1)+" "+ss[k-4]+" "+c[1]+" "+c[3];
					if (!used.contains(next)) {
						list.addFirst(next);
						used.add(next);
					}
				}
				if (ss[k-4].charAt(0) == c[3].charAt(0) || ss[k-4].charAt(1) == c[3].charAt(1)) {
					String next = (k-1)+" "+c[3]+" "+c[1]+" "+c[2];
					if (!used.contains(next)) {
						list.addFirst(next);
						used.add(next);
					}
				}
			}
    	} else {
    		if (n==1) ans = true;
    		else {
    			if (ss[0].charAt(0) == ss[1].charAt(0) || ss[0].charAt(1) == ss[1].charAt(1)) {
    				ans = true;
    			}
    		}
    	}
    	out.println(ans ? "YES" : "NO");
    	out.flush();
    }
}

import java.util.Arrays;
import java.util.Scanner;

public class Main {
    static int N;
    static char[][] a;
    static int[][][][] DP;
    public static void main(String[] args) {
        Scanner r = new Scanner(System.in);

        N = r.nextInt();

        a = new char[N][];
        for(int i = 0; i < N; i++)
            a[i] = r.next().toCharArray();

        if(N == 1)System.out.println("YES");
        else if(N == 2)System.out.println(c(a[0], a[1]) ? "YES" : "NO");
        else{
            DP = new int[N + 1][N + 1][N + 1][N + 1];
            for(int[][][] i : DP)
            for(int[][] j : i)
            for(int[] k : j)
                Arrays.fill(k, -1);

            int ret = go(N - 3, N - 2, N - 1, N - 3);

            System.out.println(ret == 1? "YES" : "NO");
        }
    }
    private static int go(int i, int j, int k, int rem) {
        if(rem == 0){
            return c(a[j], a[k]) && c(a[i], a[k]) ? 1 : 0;
        }else{
            if(DP[i][j][k][rem] != -1)return DP[i][j][k][rem];

            return DP[i][j][k][rem] = (c(a[j], a[k])? go(rem - 1, i, k, rem - 1) : 0) == 1 || (c(a[rem - 1], a[k]) ? go(k, i, j, rem - 1) : 0) == 1 ? 1 : 0;
        }
    }
    private static boolean c(char[] a, char[] b) {
        return a[0] == b[0] || a[1] == b[1];
    }
}

import java.io.OutputStreamWriter;
import java.io.BufferedWriter;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Random;
import java.io.Writer;
import java.util.Map;
import java.io.IOException;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.AbstractSet;
import java.util.Iterator;
import java.util.Set;
import java.util.AbstractMap;
import java.util.NoSuchElementException;
import java.math.BigInteger;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Egor Kulikov (egor@egork.net)
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		OutputWriter out = new OutputWriter(outputStream);
		TaskB solver = new TaskB();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskB {
	private String[] cards;
	Map<State, Boolean> map = new EHashMap<State, Boolean>();

	public void solve(int testNumber, InputReader in, OutputWriter out) {
		int count = in.readInt();
		if (count == 1) {
			out.printLine("YES");
			return;
		}
		cards = IOUtils.readStringArray(in, count);
		if (count == 2) {
			if (compatible(cards[0], cards[1]))
				out.printLine("YES");
			else
				out.printLine("NO");
			return;
		}
		if (go(cards[count - 1], cards[count - 2], cards[count - 3], cards.length - 3))
			out.printLine("YES");
		else
			out.printLine("NO");
	}

	private boolean go(String last, String preLast, String prePreLast, int remaining) {
		State key = new State(last, preLast, prePreLast, remaining);
		if (map.containsKey(key))
			return map.get(key);
		if (remaining == 0) {
			if (compatible(last, preLast) && compatible(last, prePreLast)) {
				map.put(key, true);
				return true;
			} else {
				map.put(key, false);
				return false;
			}
		}
		if (compatible(last, preLast) && go(last, prePreLast, cards[remaining - 1], remaining - 1)) {
			map.put(key, true);
			return true;
		}
		if (compatible(last, cards[remaining - 1]) && go(preLast, prePreLast, last, remaining - 1)) {
			map.put(key, true);
			return true;
		}
		map.put(key, false);
		return false;
	}

	private boolean compatible(String last, String preLast) {
		return last.charAt(0) == preLast.charAt(0) || last.charAt(1) == preLast.charAt(1);
	}

	static class State {
		String last;
		String preLast;
		String prePreLast;
		int remaining;

		State(String last, String preLast, String prePreLast, int remaining) {
			this.last = last;
			this.preLast = preLast;
			this.prePreLast = prePreLast;
			this.remaining = remaining;
		}

		public boolean equals(Object o) {
			if (this == o) return true;
			if (o == null || getClass() != o.getClass()) return false;

			State state = (State) o;

			if (remaining != state.remaining) return false;
			if (!last.equals(state.last)) return false;
			if (!preLast.equals(state.preLast)) return false;
			if (!prePreLast.equals(state.prePreLast)) return false;

			return true;
		}

		public int hashCode() {
			int result = last.hashCode();
			result = 31 * result + preLast.hashCode();
			result = 31 * result + prePreLast.hashCode();
			result = 31 * result + remaining;
			return result;
		}
	}
}

class EHashMap<E, V> extends AbstractMap<E, V> {
	private static final int[] shifts = new int[10];

	private int size;
	private Object[] keys;
	private Object[] values;
	private int capacity;
	private int shift;
	private int[] indices;
	private Set<Entry<E, V>> entrySet;

	static {
		Random random = new Random(System.currentTimeMillis());
		for (int i = 0; i < 10; i++)
			shifts[i] = 1 + 3 * i + random.nextInt(3);
	}

	public EHashMap() {
		this(4);
	}

	private void setCapacity(int size) {
		capacity = Integer.highestOneBit(10 * size);
		keys = new Object[capacity];
		values = new Object[capacity];
		shift = capacity / 3 - 1;
		shift -= 1 - (shift & 1);
		indices = new int[capacity];
	}

	public EHashMap(int maxSize) {
		setCapacity(maxSize);
		entrySet = new AbstractSet<Entry<E, V>>() {
			@Override
			public Iterator<Entry<E, V>> iterator() {
				return new Iterator<Entry<E, V>>() {
					private HashEntry entry = new HashEntry();
					int index = 0;

					public boolean hasNext() {
						while (index < size && keys[index] == null)
							index++;
						return index < size;
					}

					public Entry<E, V> next() {
						if (!hasNext())
							throw new NoSuchElementException();
						entry.key = (E) keys[index];
						entry.value = (V) values[index++];
						return entry;
					}

					public void remove() {
						if (entry.key == null)
							throw new IllegalStateException();
						EHashMap.this.remove(entry.key);
						entry.key = null;
						entry.value = null;
					}
				};
			}

			@Override
			public int size() {
				return size;
			}
		};
	}

	public EHashMap(Map<E, V> map) {
		this(map.size());
		putAll(map);
	}

	public Set<Entry<E, V>> entrySet() {
		return entrySet;
	}

	public void clear() {
		Arrays.fill(keys, null);
		Arrays.fill(values, null);
		size = 0;
	}

	private int index(Object o) {
		return getHash(o.hashCode()) & (capacity - 1);
	}

	private int getHash(int h) {
		int result = h;
		for (int i : shifts)
			result ^= h >>> i;
		return result;
	}

	public V remove(Object o) {
		if (o == null)
			return null;
		int index = index(o);
		int indicesSize = 0;
		while (keys[index] != null && !keys[index].equals(o)) {
			indices[indicesSize++] = index;
			index = (index + shift) & (capacity - 1);
		}
		if (keys[index] == null)
			return null;
		size--;
		int lastIndex = indicesSize;
		indices[indicesSize++] = index;
		keys[index] = null;
		V result = (V) values[index];
		values[index] = null;
		index = (index + shift) & (capacity - 1);
		while (keys[index] != null) {
			int curKey = index(keys[index]);
			for (int i = 0; i <= lastIndex; i++) {
				if (indices[i] == curKey) {
					keys[indices[lastIndex]] = keys[index];
					values[indices[lastIndex]] = values[index];
					keys[index] = null;
					values[index] = null;
					lastIndex = indicesSize;
				}
			}
			indices[indicesSize++] = index;
			index = (index + shift) & (capacity - 1);
		}
		return result;
	}

	public V put(E e, V value) {
		if (e == null)
			return null;
		int index = index(e);
		while (keys[index] != null && !keys[index].equals(e))
			index = (index + shift) & (capacity - 1);
		if (keys[index] == null)
			size++;
		keys[index] = e;
		values[index] = value;
		if (size * 2 > capacity) {
			Object[] oldKeys = keys;
			Object[] oldValues = values;
			setCapacity(size);
			size = 0;
			for (int i = 0; i < oldKeys.length; i++) {
				if (oldKeys[i] != null)
					put((E) oldKeys[i], (V) oldValues[i]);
			}
		}
		return value;
	}

	public V get(Object o) {
		if (o == null)
			return null;
		int index = index(o);
		while (keys[index] != null && !keys[index].equals(o))
			index = (index + shift) & (capacity - 1);
		return (V) values[index];
	}

	public boolean containsKey(Object o) {
		if (o == null)
			return false;
		int index = index(o);
		while (keys[index] != null && !keys[index].equals(o))
			index = (index + shift) & (capacity - 1);
		return keys[index] != null;
	}

	public int size() {
		return size;
	}

	private class HashEntry implements Entry<E, V> {
		private E key;
		private V value;

		public E getKey() {
			return key;
		}

		public V getValue() {
			return value;
		}

		public V setValue(V value) {
			put(key, value);
			return this.value = value;
		}
	}
}

class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuffer res = new StringBuffer();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public static boolean isSpaceChar(int c) {
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	}

class OutputWriter {
	private final PrintWriter writer;

	public OutputWriter(OutputStream outputStream) {
		writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
	}

	public OutputWriter(Writer writer) {
		this.writer = new PrintWriter(writer);
	}

	public void print(Object...objects) {
		for (int i = 0; i < objects.length; i++) {
			if (i != 0)
				writer.print(' ');
			writer.print(objects[i]);
		}
	}

	public void printLine(Object...objects) {
		print(objects);
		writer.println();
	}

	public void close() {
		writer.close();
	}

	}

class IOUtils {

	public static String[] readStringArray(InputReader in, int size) {
		String[] array = new String[size];
		for (int i = 0; i < size; i++)
			array[i] = in.readString();
		return array;
	}

	}

import java.io.*;
import java.util.*;

import static java.lang.Math.max;
import static java.lang.Math.min;

public class Code implements Runnable {

    public static void main(String[] args) throws IOException {
        new Thread(new Code()).start();
    }

    HashSet<ArrayList<String>> used;

    boolean dfs(ArrayList<String> rem) {
        if(used.contains(rem))   return false;
        if(rem.size() == 1) return true;

        used.add(rem);
        ArrayList<String> rem1 = (ArrayList)rem.clone();
        if(rem.get(rem.size() - 1).charAt(0) == rem.get(rem.size() - 2).charAt(0) || rem.get(rem.size() - 1).charAt(1) == rem.get(rem.size() - 2).charAt(1)) {
            rem1.set(rem1.size() - 2, rem1.get(rem1.size() - 1));
            rem1.remove(rem1.size() - 1);
            if(dfs(rem1))   return true;
        }
        if(rem.size() > 3 && (rem.get(rem.size() - 1).charAt(0) == rem.get(rem.size() - 4).charAt(0) || rem.get(rem.size() - 1).charAt(1) == rem.get(rem.size() - 4).charAt(1))) {
            rem1 = (ArrayList)rem.clone();
            rem1.set(rem1.size() - 4, rem1.get(rem1.size() - 1));
            rem1.remove(rem1.size() - 1);
            return dfs(rem1);
        }
        return false;
    }

    private void solve() throws IOException {
        int n = nextInt();

        ArrayList<String> cards = new ArrayList<String>();
        for(int i = 0; i < n; ++i)  cards.add(nextToken());

        used = new HashSet<ArrayList<String>>();
        writer.println(dfs(cards) ? "YES" : "NO");
    }

    private class Pair<E extends Comparable, V extends Comparable> implements Comparable<Pair<E, V>> {
        public Pair(E first, V second) {
            this.first = first;
            this.second = second;
        }

        @Override
        public int compareTo(Pair<E, V> obj) {
            if(first == obj.first)  return second.compareTo(obj.second);
            return first.compareTo(obj.first);
        }

        @Override
        public boolean equals(Object obj) {
            Pair other = (Pair)obj;
            return first.equals(other.first) && second.equals(other.second);
        }

        public E first;
        public V second;
    }

    @Override
    public void run() {
        try {
            if(in.equals(""))   reader = new BufferedReader(new InputStreamReader(System.in));
            else    reader = new BufferedReader(new FileReader(in));

            if(out.equals(""))  writer = new PrintWriter(new OutputStreamWriter(System.out));
            else    writer = new PrintWriter(new FileWriter(out));
            solve();
        } catch(IOException e) {
            e.printStackTrace();
        } finally {
            try {
                reader.close();
                writer.close();
            } catch(IOException e) {
                e.printStackTrace();
            }
        }
    }

    private int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    private long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    private double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    private float nextFloat() throws IOException {
        return Float.parseFloat(nextToken());
    }

    private String nextToken() throws IOException {
        while(st == null || !st.hasMoreTokens())    st = new StringTokenizer(reader.readLine());
        return st.nextToken();
    }

    private String in = "", out = "";
    private BufferedReader reader;
    private PrintWriter writer;
    private StringTokenizer st;
}

import java.util.*;
import java.io.*;

public class b {
   static Map<String, Boolean> dp = new HashMap<String, Boolean>();
   static boolean[][] vi = new boolean[55][55];

   static String make(String[] pa) {
      String s = "";
      for(String t : pa)
         s += t + " ";
      return s.trim();
   }

   static boolean is(String s, String t) {
      return s.charAt(0) == t.charAt(0) || s.charAt(1) == t.charAt(1);
   }

   static boolean doit(String s, int k) {
      if(k == 0) return true;
      if(dp.get(s) != null) return dp.get(s);
      boolean r = false;
      String[] pa = s.split(" ");
      if(k - 1 > 0 && is(pa[k], pa[k - 1])) {
         pa[k - 1] = pa[k];
         r = r | doit(make(pa), k - 1);
      }
      if(k - 3 > 0 && is(pa[k], pa[k - 3])) {
         pa[k - 3] = pa[k];
         r = r | doit(make(pa), k - 3);
      }
      dp.put(s, r);
      return r;
   }

   static boolean stack(String s) {
      Stack<String[]> sa = new Stack<String[]>();
      Set<String> ma = new HashSet<String>();
      sa.push(s.split(" "));

      while(!sa.isEmpty()) {
         String[] top = sa.pop();
         if(ma.contains(make(top))) continue;
         ma.add(make(top));
         int k = top.length;
         if(k == 1) return true;
         if(k > 1 && is(top[k - 1], top[k - 2])) {
            String[] ne = new String[k - 1];
            System.arraycopy(top, 0, ne, 0, k - 1);
            ne[k - 2] = top[k - 1];
            sa.push(ne);
         }
         if(k > 3 && is(top[k - 1], top[k - 4])) {
            String[] ne = new String[k - 1];
            System.arraycopy(top, 0, ne, 0, k - 1);
            ne[k - 4] = top[k - 1];
            sa.push(ne);
         }
      }

      return false;
   }

   public static void main(String[] args) throws IOException {
      //BufferedReader br = new BufferedReader(new FileReader("b.in"));
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      String line = br.readLine();
      int n = Integer.parseInt(line);
      line = br.readLine();
      //debug(line);
      //boolean r = doit(line, n - 1);
      boolean r = stack(line);
      System.out.println((r ? "YES" : "NO"));
   }

   static void debug(Object...o) {
      System.err.println(Arrays.deepToString(o));
   }
}

import java.util.*;
import java.io.*;

public class b {
   static Map<String, Boolean> dp = new HashMap<String, Boolean>();

   static String make(String[] pa) {
      String s = "";
      for(String t : pa)
         s += t + " ";
      return s.trim();
   }

   static boolean is(String s, String t) {
      return s.charAt(0) == t.charAt(0) || s.charAt(1) == t.charAt(1);
   }

   static boolean doit(String[] pa) {
      if(pa.length == 1) return true;
      String s = make(pa);
      if(dp.get(s) != null) return dp.get(s);
      boolean r = false;
      int k = pa.length - 1;
      if(k > 0 && is(pa[k], pa[k - 1])) {
         String[] ne = new String[k];
         System.arraycopy(pa, 0, ne, 0, k);
         ne[k - 1] = pa[k];
         r = r | doit(ne);
      }
      if(k - 2 > 0 && is(pa[k], pa[k - 3])) {
         String[] ne = new String[k];
         System.arraycopy(pa, 0, ne, 0, k);
         ne[k - 3] = pa[k];
         r = r | doit(ne);
      }
      dp.put(s, r);
      return r;
   }

   public static void main(String[] args) throws IOException {
      //BufferedReader br = new BufferedReader(new FileReader("b.in"));
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      String line = br.readLine();
      int n = Integer.parseInt(line);
      line = br.readLine();
      boolean r = doit(line.split(" "));
      System.out.println((r ? "YES" : "NO"));
   }

   static void debug(Object...o) {
      System.err.println(Arrays.deepToString(o));
   }
}

import java.util.HashSet;
import java.util.Scanner;

public class Main {

    private static String[] cards;
    private static boolean flag = false;
    private static HashSet <Dyn> dyn;
    private static int n;

    private static class Dyn {
        int n;
        String s1,s2,s3;
        Dyn (int n, String s1, String s2, String s3) {
            this.n = n;
            this.s1 = s1;
            this.s2 = s2;
            this.s3 = s3;
        }

        @Override
        public boolean equals(Object obj) {
            if (obj == null) {
                return false;
            }
            if (getClass() != obj.getClass()) {
                return false;
            }
            final Dyn other = (Dyn) obj;
            if (this.n != other.n) {
                return false;
            }
            if (!this.s1.equals(other.s1)) {
                return false;
            }
            if (!this.s2.equals(other.s2)) {
                return false;
            }
            if (!this.s3.equals(other.s3)) {
                return false;
            }
            return true;
        }

        @Override
        public int hashCode() {
            int hash = 7;
            hash = 83 * hash + this.n;
            hash = 83 * hash + this.s1.hashCode();
            hash = 83 * hash + this.s2.hashCode();
            hash = 83 * hash + this.s3.hashCode();
            return hash;
        }

    }

    public static void main(String[] args) {
        Scanner sc = new Scanner (System.in);
        n = sc.nextInt();
        dyn = new HashSet <Dyn>();

        cards = new String[n];
        for (int i = 0; i < n; ++i)
            cards[i] = sc.next();

        dfs(n-1, cards);

        System.out.print(flag == true ? "YES":"NO");
    }

    private static void dfs(int a, String[] cards) {

        if (a==0)
        {
            flag = true;
            return;
        }

        Dyn temp2 = new Dyn (a,cards[a], a>0 ? cards[a-1] : "xxx", a>1 ? cards[a-2] : "xxx");
        if (!dyn.contains(temp2))
        {
            dyn.add(temp2);

            if (cards[a].charAt(0) == cards[a-1].charAt(0) || cards[a].charAt(1) == cards[a-1].charAt(1))
            {
                String[] temp = cards.clone();
                temp[a-1] = temp[a];
                dfs(a-1, temp);
            }

            if (a > 2)
                if (cards[a].charAt(0) == cards[a-3].charAt(0) || cards[a].charAt(1) == cards[a-3].charAt(1))
                {
                    String[] temp = cards.clone();
                    temp[a-3] = temp[a];
                    dfs(a-1, temp);
                }
        }
    }
}

import java.util.Scanner;
import java.util.regex.Pattern;

public class B {

	public static int convert(String card) {
		int id = 0;
		if (card.length() == 2) {
			switch (card.charAt(1)) {
			case 'S':
				id += 13;
			case 'D':
				id += 13;
			case 'H':
				id += 13;
			case 'C':
			}
			if (card.charAt(0) >= '2' && card.charAt(0) <= '9') {
				id += card.charAt(0) - '0';
			} else {
				switch (card.charAt(0)) {
				case 'T':
					id += 10;
					break;
				case 'J':
					id += 11;
					break;
				case 'Q':
					id += 12;
					break;
				case 'K':
					id += 13;
					break;
				case 'A':
					id += 1;
					break;
				}
			}
		}
		return id-1;
	}
	public static boolean canBeOnTop(int id1, int id2) {
		if (Math.abs(id1-id2) % 13 == 0) {
			return true;
		}
		if (id1 / 13 == id2 / 13) {
			return true;
		}
		return false;
	}
	public static int[] cards;
	public static int n;
	public static int memo[][][][];
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Pattern pat = Pattern.compile("\\w\\w");
		n = sc.nextInt();
		cards = new int[n];
		for (int i=0; i<n; i++) {
			cards[i] = convert(sc.next(pat));
		}
		memo = new int[52][52][52][52];
		if (recurSolvable()) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
	public static boolean recurSolvable() {
		if (n < 4) {
			return recurSolvable(n-1, cards);
		} else {
			int[] cx = new int[3];
			for (int i=0; i<3; i++) {
				cx[i] = cards[n-3+i];
			}
			return recurSolvable(n-1, cx);
		}
	}
	public static boolean recurSolvable(int x, int[] cx) {
		if (x < 3) {
			for (int i=0; i<x; i++) {
				if (!canBeOnTop(cx[x], cx[i])) {
					return false;
				}
			}
			return true;
		}
		if (memo[x][cx[0]][cx[1]][cx[2]] != 0) {
			return memo[x][cx[0]][cx[1]][cx[2]] > 0;
		}
		if (canBeOnTop(cx[2], cx[1])) {
			int[] ncx = new int[]{cards[x-3], cx[0], cx[2]};
			if (recurSolvable(x-1, ncx)) {
				memo[x][cx[0]][cx[1]][cx[2]] = 1;
				return true;
			}
		}
		if (canBeOnTop(cx[2], cards[x-3])) {
			int[] ncx = new int[]{cx[2], cx[0], cx[1]};
			if (recurSolvable(x-1, ncx)) {
				memo[x][cx[0]][cx[1]][cx[2]] = 1;
				return true;
			}
		}
		memo[x][cx[0]][cx[1]][cx[2]] = -1;
		return false;
	}

}

import java.util.Scanner;
import java.io.OutputStream;
import java.io.IOException;
import java.util.Arrays;
import java.io.PrintWriter;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author George Marcus
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		Scanner in = new Scanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskB solver = new TaskB();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskB {
    public static final int MAXC = 4 * 14 + 4;
    public int[][][][] mem;
    public int[] cards;

    public void solve(int testNumber, Scanner in, PrintWriter out) {
        int N = in.nextInt();
        cards = new int[N];
        for(int i = 0; i < N; i++) {
            String aux = in.next();
            cards[i] = convert(aux);
        }

        if(N == 1) {
            out.print("YES");
            return;
        }
        if(N == 2) {
            if(match(cards[0], cards[1]))
                out.print("YES");
            else
                out.print("NO");
            return;
        }

        mem = new int[N + 1][MAXC][MAXC][MAXC];
        for(int i = 0; i < N + 1; i++)
            for(int j = 0; j < MAXC; j++)
                for(int k = 0; k < MAXC; k++)
                    Arrays.fill(mem[i][j][k], -1);

        int res = doit(N, cards[N - 3], cards[N - 2], cards[N - 1]);
        if(res == 1)
            out.print("YES");
        else
            out.print("NO");
	}

    private int doit(int numLeft, int a, int b, int c) {
        if(mem[numLeft][a][b][c] > -1)
            return mem[numLeft][a][b][c];
        if(numLeft == 1)
            return 1;

        int ret = 0;
        if(match(b, c))
            ret = doit(numLeft - 1, numLeft > 3 ? cards[numLeft - 4] : 0, a, c);
        if(numLeft > 3 && ret == 0)
            if(match(c, cards[numLeft - 4])) ret = doit(numLeft - 1, c, a, b);

        return mem[numLeft][a][b][c] = ret;
    }

    private boolean match(int a, int b) {
        if(a == 0 || b == 0) return false;
        return suit(a) == suit(b) || value(a) == value(b);
    }

    private int value(int card) {
        return card / 4;
    }

    private int suit(int card) {
        return card % 4;
    }

    private int convert(String c) {
        int r1 = 0;
        int r2 = 0;
        if(Character.isDigit(c.charAt(0)))
            r1 = c.charAt(0) - '0';
        else {
            char ch = c.charAt(0);
            if(ch == 'T') r1 = 10;
            if(ch == 'J') r1 = 11;
            if(ch == 'Q') r1 = 12;
            if(ch == 'K') r1 = 13;
            if(ch == 'A') r1 = 14;
        }
        r1 = 4 * r1;

        char ch = c.charAt(1);
        if(ch == 'D') r2 = 1;
        if(ch == 'H') r2 = 2;
        if(ch == 'C') r2 = 3;

        return r1 + r2;
    }
}

import java.util.Map;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.HashMap;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author RiaD
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Reader in = new Reader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }
}

class TaskB {
    String[] a;

    Map<Integer, Boolean> mem = new HashMap<Integer, Boolean>();
    boolean ans(int n, int n1, int n2, int n3){
        if(n == 1)
            return true;
        int hash = n * 1000000 + n1 * 10000 + n2 * 100 + n3;
        if(mem.containsKey(hash))
            return mem.get(hash);

        boolean to3 = (n >= 4 && good(a[n3], a[n - 4])) ?  ans(n - 1,n3, n1,n2): false;

        if(to3){
            mem.put(hash, true);
            return true;
        }

        boolean  res = good(a[n2], a[n3]) ? ans(n - 1, n - 4, n1, n3) : false;

        mem.put(hash, res);
        return res;

    }

    private boolean good(String s, String s1) {
        return s.charAt(0) == s1.charAt(0) || s1.charAt(1) == s.charAt(1);
    }

    public void solve(int testNumber, Reader in, PrintWriter out) {
        int n = in.nextInt();
        a = new String[n];
        for(int i = 0; i < n; ++i){
            a[i] = in.nextString();
        }

        out.print(ans(n, n-3,n-2, n-1)?"YES":"NO");
    }

}

class Reader {
    private BufferedReader reader;
    private StringTokenizer tokenizer;

    public Reader(BufferedReader reader) {
        this.reader = reader;
    }

    public Reader(InputStream stream) {
        this(new BufferedReader(new InputStreamReader(stream)));
    }

    public String nextString() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(readLine());
        }
        return tokenizer.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(nextString());
    }

    private String readLine() {
        try {
            return reader.readLine();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}

import java.io.*;
import java.util.*;

public class B implements Runnable {
    void preCalc() {

    }
    String[] a;

    Map<Integer, Boolean> mem = new HashMap<Integer, Boolean>();
    boolean ans(int n, int n1, int n2, int n3){
        if(n == 1)
            return true;
        int hash = n * 1000000 + n1 * 10000 + n2 * 100 + n3;
        if(mem.containsKey(hash))
            return mem.get(hash);

        boolean to3 = (n >= 4 && good(a[n3], a[n - 4])) ?  ans(n - 1,n3, n1,n2): false;

        if(to3){
            mem.put(hash, true);
            return true;
        }

        boolean  res = good(a[n2], a[n3]) ? ans(n - 1, n - 4, n1, n3) : false;

        mem.put(hash, res);
        return res;

    }

    private boolean good(String s, String s1) {
        return s.charAt(0) == s1.charAt(0) || s1.charAt(1) == s.charAt(1);
    }

    void solve() throws IOException {
        int n = nextInt();
        a = new String[n];
        for(int i = 0; i < n; ++i){
            a[i] = nextString();
        }

        out.print(ans(n, n-3,n-2, n-1)?"YES":"NO");
    }

    public static void main(String[] args) {
        debugMode = args.length > 0 && args[0].equals("debug");
        new Thread(null, new B(), "", 1 << 25).start();
    }

    private void multiTest() throws IOException {
        int t = 1;
        preCalc();
        for (int i = 0; i < t; ++i) {
            solve();
        }
    }

    PrintWriter out;
    StringTokenizer st;
    BufferedReader br;

    public void run() {
        try {
            initFiles();
            long startTime = System.currentTimeMillis();
            if (debugMode) {
                out.println("Output:");
            }

            multiTest();
            if (debugMode) {
                double time = (System.currentTimeMillis() - startTime) / 1000.0;
                out.println("\n\n\nTime: " + time);
            }
            out.flush();
        } catch (IOException e) {
            out.println("IOException:");
            out.println(e.getStackTrace());
        }

    }

    private void initFiles() throws IOException {
        if (debugMode) {
            out = new PrintWriter(System.out);
            br = new BufferedReader(new FileReader("input.txt"));
        } else {
            out = new PrintWriter(System.out);
            br = new BufferedReader(new InputStreamReader(System.in));
        }
    }

    public String nextString() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }

    public int nextInt() throws IOException {
        return Integer.parseInt(nextString());
    }

    public double nextDouble() throws IOException {
        return Double.parseDouble(nextString());
    }

    public long nextLong() throws IOException {
        return Long.parseLong(nextString());
    }

    static boolean debugMode = false;

}

/* Codeforces Template */

import java.io.*;
import java.util.*;

import static java.lang.Math.*;
import static java.util.Arrays.fill;
import static java.util.Arrays.binarySearch;
import static java.util.Arrays.sort;

public class Main {

	static long initTime;
	static final Random rnd = new Random(7777L);

	public static void main(String[] args) throws IOException {
		initTime = System.currentTimeMillis();
		new Thread(null, new Runnable() {
			public void run() {
				try {
					try {
						if (new File("input.txt").exists())
							System.setIn(new FileInputStream("input.txt"));
					} catch (SecurityException e) {}
//					long prevTime = System.currentTimeMillis();
					new Main().run();
//					System.err.println("Total time: " + (System.currentTimeMillis() - prevTime) + " ms");
//					System.err.println("Memory status: " + memoryStatus());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}, "1", 1L << 24).start();
	}

	void run() throws IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		solve();
		out.close();
		in.close();
	}

	/***************************************************************
	 * Solution
	 **************************************************************/

	int n;
	int[] cards;
	Set<Integer> was = new TreeSet<Integer>();

	void solve() throws IOException  {

		n = nextInt();
		cards = new int [n];

		for (int i = 0; i < n; i++) {
			cards[i] = code(nextToken());
		}

		boolean ok = false;

		if (n <= 3) {
			ok = solveSmall(cards, n);
		} else {
			ok = dfs(n - 4, cards[n - 3], cards[n - 2], cards[n - 1]);
		}

		out.println(ok ? "YES" : "NO");
	}

	int[] tmp = new int [3];

	boolean dfs(int pos, int c1, int c2, int c3) {

//		System.err.println(pos + " " + c1 +" " + c2 + " " +c3);

		if (pos < 0) {
			tmp[0] = c1;
			tmp[1] = c2;
			tmp[2] = c3;
			return solveSmall(tmp, 3);
		}

		int state = codeState(pos, c1, c2, c3);

		if (was.contains(state)) {
			return false;
		}

		was.add(state);

		if (can(c2, c3) && dfs(pos - 1, cards[pos], c1, c3)) {
			return true;
		}

		if (can(cards[pos], c3) && dfs(pos - 1, c3, c1, c2)) {
			return true;
		}

		return false;
	}

	boolean can(int c1, int c2) {
		return s(c1) == s(c2) || v(c1) == v(c2);
	}

	int codeState(int pos, int c1, int c2, int c3) {
		return ((pos * 52 + c1) * 52 + c2) * 52 + c3;
	}

	boolean solveSmall(int[] cards, int cnt) {
		if (cnt <= 1) return true;
		if (cnt == 2) return can(cards[0], cards[1]);
		return can(cards[2], cards[1]) && can(cards[2], cards[0]);
	}

	int s(int c) {
		return c / 13;
	}

	int v(int c) {
		return c % 13;
	}

	int code(String s) {
		return vn(s.charAt(0)) + 13 * sn(s.charAt(1));
	}

	int sn(char c) {
		if (c == 'S') return 0;
		if (c == 'D') return 1;
		if (c == 'H') return 2;
		if (c == 'C') return 3;
		return -1;
	}

	int vn(char c) {
		if ('2' <= c && c <= '9') return (c - '2');
		if (c == 'A') return 8;
		if (c == 'J') return 9;
		if (c == 'Q') return 10;
		if (c == 'K') return 11;
		if (c == 'T') return 12;
		return -1;
	}

	/***************************************************************
	 * Input
	 **************************************************************/
	BufferedReader in;
	PrintWriter out;
	StringTokenizer st = new StringTokenizer("");

	String nextToken() throws IOException {
		while (!st.hasMoreTokens())
			st = new StringTokenizer(in.readLine());
		return st.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	int[] nextIntArray(int size) throws IOException {
		int[] ret = new int [size];
		for (int i = 0; i < size; i++)
			ret[i] = nextInt();
		return ret;
	}

	long[] nextLongArray(int size) throws IOException {
		long[] ret = new long [size];
		for (int i = 0; i < size; i++)
			ret[i] = nextLong();
		return ret;
	}

	double[] nextDoubleArray(int size) throws IOException {
		double[] ret = new double [size];
		for (int i = 0; i < size; i++)
			ret[i] = nextDouble();
		return ret;
	}

	String nextLine() throws IOException {
		st = new StringTokenizer("");
		return in.readLine();
	}

	boolean EOF() throws IOException {
		while (!st.hasMoreTokens()) {
			String s = in.readLine();
			if (s == null)
				return true;
			st = new StringTokenizer(s);
		}
		return false;
	}

	/***************************************************************
	 * Output
	 **************************************************************/
	void printRepeat(String s, int count) {
		for (int i = 0; i < count; i++)
			out.print(s);
	}

	void printArray(int[] array) {
		if (array == null || array.length == 0)
			return;
		for (int i = 0; i < array.length; i++) {
			if (i > 0) out.print(' ');
			out.print(array[i]);
		}
		out.println();
	}

	void printArray(long[] array) {
		if (array == null || array.length == 0)
			return;
		for (int i = 0; i < array.length; i++) {
			if (i > 0) out.print(' ');
			out.print(array[i]);
		}
		out.println();
	}

	void printArray(double[] array) {
		if (array == null || array.length == 0)
			return;
		for (int i = 0; i < array.length; i++) {
			if (i > 0) out.print(' ');
			out.print(array[i]);
		}
		out.println();
	}

	void printArray(double[] array, String spec) {
		if (array == null || array.length == 0)
			return;
		for (int i = 0; i < array.length; i++) {
			if (i > 0) out.print(' ');
			out.printf(Locale.US, spec, array[i]);
		}
		out.println();
	}

	void printArray(Object[] array) {
		if (array == null || array.length == 0)
			return;
		boolean blank = false;
		for (Object x : array) {
			if (blank) out.print(' '); else blank = true;
			out.print(x);
		}
		out.println();
	}

	@SuppressWarnings("rawtypes")
	void printCollection(Collection collection) {
		if (collection == null || collection.isEmpty())
			return;
		boolean blank = false;
		for (Object x : collection) {
			if (blank) out.print(' '); else blank = true;
			out.print(x);
		}
		out.println();
	}

	/***************************************************************
	 * Utility
	 **************************************************************/
	static String memoryStatus() {
		return (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory() >> 20) + "/" + (Runtime.getRuntime().totalMemory() >> 20) + " MB";
	}

	static void checkMemory() {
		System.err.println(memoryStatus());
	}

	static long prevTimeStamp = Long.MIN_VALUE;

	static void updateTimer() {
		prevTimeStamp = System.currentTimeMillis();
	}

	static long elapsedTime() {
		return (System.currentTimeMillis() - prevTimeStamp);
	}

	static void checkTimer() {
		System.err.println(elapsedTime() + " ms");
	}
}

import java.util.*;
import java.io.*;
public class a {
  static long mod  = 1000000007;
public static void main(String[] args) throws IOException
{
  input.init(System.in);
  PrintWriter out = new PrintWriter(new PrintStream(System.out));
  //input.init(new FileInputStream(new File("input.txt")));
  //PrintWriter out = new PrintWriter(new File("output.txt"));
  int n = input.nextInt();
  char[] nums = new char[n];
  char[] suits = new char[n];
  for(int i = 0; i<n; i++)
  {
    String s = input.next();
    nums[i] = s.charAt(0);
    suits[i] = s.charAt(1);
  }
  dp = new short[n][n][n][n];
  for(short[][][] A:dp)
    for(short[][] B:A)
      for(short[]C:B)
        Arrays.fill(C, (short)-1);
  out.println(go(n, n-1, n-2, n-3, suits, nums) > 0 ? "YES" : "NO");

  out.close();
}
static short[][][][] dp;
static short go(int num, int top, int second, int third, char[] suits, char[] nums)
{
  if(num==1) return 1;
  if(num == 2)
    return (short) ((nums[top] == nums[second] || suits[top] == suits[second]) ? 1 : 0);
  if(num==3)
    return (short) (((nums[top] == nums[second] || suits[top] == suits[second])
        && (nums[top] == nums[third] || suits[top] == suits[third])) ? 1 : 0);
  if(dp[num-1][top][second][third] != -1) return dp[num-1][top][second][third];
  if((nums[top] == nums[second] || suits[top] == suits[second]) && go(num-1,top,third, num-4, suits, nums)>0)
    return dp[num-1][top][second][third]=1;
  if(num >= 3)
    if((nums[top] == nums[num-4] || suits[top] == suits[num-4]) && go(num-1,second,third, top, suits, nums)>0)
      return dp[num-1][top][second][third]=1;
  return dp[num-1][top][second][third]=0;
}
static long[][] comb(int n)
{
  long[][] res = new long[n+1][n+1];
  Arrays.fill(res[0], 0);
  for(int i = 0; i<=n; i++) res[i][0] = 1;
  for(int i = 1; i<=n; i++)
    for(int j = 1; j<=n; j++)
      res[i][j] = (res[i-1][j-1] + res[i-1][j])%mod;
  return res;
}
static long gcd(long a, long b)
{
  if(b==0) return a;
  return gcd(b, a%b);
}
static long pow(long a, long p)
{
  if(p<=0) return 1;
  if((p&1) == 0)
  {
    long sqrt = pow(a, p/2);
    return (sqrt*sqrt)%mod;
  }
  else
    return (a*pow(a,p-1))%mod;
}
static class input {
  static BufferedReader reader;
  static StringTokenizer tokenizer;

  /** call this method to initialize reader for InputStream */
  static void init(InputStream input) {
      reader = new BufferedReader(
                   new InputStreamReader(input) );
      tokenizer = new StringTokenizer("");
  }
  public static boolean hasNext() {
    // TODO(mkirsche): Auto-generated method stub
    return tokenizer.hasMoreTokens();
  }

  /** get next word */
  static String next() throws IOException {
      while ( ! tokenizer.hasMoreTokens() ) {
          //TODO add check for eof if necessary
          tokenizer = new StringTokenizer(
                 reader.readLine() );
      }
      return tokenizer.nextToken();
  }

  static int nextInt() throws IOException {
      return Integer.parseInt( next() );
  }
  static long nextLong() throws IOException {
    return Long.parseLong( next() );
}

  static double nextDouble() throws IOException {
      return Double.parseDouble( next() );
  }
  static String nextLine() throws IOException {
    return reader.readLine();
  }
}
}

/**
 * Created by ckboss on 14-9-5.
 */
import java.util.*;

public class Solitaire {

    static int[][][][] dp = new int[60][60][60][60];
    static boolean[][][][] vis = new boolean[60][60][60][60];
    static char[] c1=new char[60];
    static char[] c2=new char[60];

    static boolean check(int a,int b){
        if((c1[a]==c1[b])||(c2[a]==c2[b]))
            return true;
        else return false;
    }

    static int dfs(int cur,int a,int b,int c){
        if(vis[cur][a][b][c]==true)
            return dp[cur][a][b][c];
        vis[cur][a][b][c]=true;
        if(cur==1)
            return dp[cur][a][b][c] = 1;
        if(cur==2){
            if(check(a,b)==true){
                return dp[cur][a][b][c] = 1;
            }
            else{
                return dp[cur][a][b][c] = 0;
            }
        }
        int ret=0;
        if(check(a,b)==true){
            ret=dfs(cur-1,a,c,cur-3);
        }
        if(ret==1){
            return dp[cur][a][b][c] = 1;
        }
        if(check(a,cur-3)==true){
            ret=dfs(cur-1,b,c,a);
        }
        return dp[cur][a][b][c]=ret;
    }

    public static void main(String[] args){
        Scanner in=new Scanner(System.in);

        int n=in.nextInt();

        for(int i=1;i<=n;i++){
            String temp=in.next().trim();
            c1[i]=temp.charAt(0);
            c2[i]=temp.charAt(1);
        }

        if(n==1){
            System.out.println("YES");
        }
        else if(dfs(n,n,n-1,n-2)==1){
            System.out.println("YES");
        }
        else{
            System.out.println("NO");
        }
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;

public class C {
    private static Map<String, Boolean> map = new HashMap<String, Boolean>();

    public static void main(String args[]) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        String[] ss = br.readLine().split(" ");
        boolean r = solve(ss);
        if (r) System.out.println("YES");
        else System.out.println("NO");
    }

    private static boolean solve(String[] ss) {
        if (ss.length == 1) {
            return true;
        }
        boolean res = false;
        String k = getKey(ss);
        if (map.containsKey(k)) return map.get(k);
        int l = ss.length;
        String s1 = ss[l-1];
        String s2 = ss[l-2];
        if (s2.charAt(0) == s1.charAt(0) || s2.charAt(1) == s1.charAt(1)) {
            String[] s = new String[ss.length-1];
            for (int i =0 ; i < s.length; i ++) {
                s[i] = ss[i];
            }
            s[l-2] = s1;
            if (solve(s)) res = true;
        }
        if (!res) {
            if (l - 4 >= 0) {
                s2 = ss[l-4];
                if (s2.charAt(0) == s1.charAt(0) || s2.charAt(1) == s1.charAt(1)) {
                    String[] s = new String[ss.length-1];
                    for (int i =0 ; i < s.length; i ++) {
                        s[i] = ss[i];
                    }
                    s[l-4] = s1;
                    if (solve(s)) res = true;
                }
            }
        }
        map.put(k, res);
        return res;
    }

    private static String getKey(String[] ss) {
        String res = "";
        for (String s: ss) {
            res += " " + s;
        }
        return res;
    }
}

import java.io.*;
import java.util.*;
import static java.lang.Math.*;

public class B {

	boolean fl = false;

	boolean take(String s1, String s2) {
		return (s1.charAt(0) == s2.charAt(0) || s1.charAt(1) == s2.charAt(1));
	}

	String[] a;
	HashSet<String> pos;

	void find(int n, String l1, String l2, String l3) {
		String indpos = n + "" + l1 + l2 + l3;
		if (pos.contains(indpos)) {
			return;
		}
		pos.add(indpos);
		if (n == 3) {
			fl = fl || (take(l3, l2) && take(l3, l1));
			return;
		}
		if (!fl && take(l3, a[n - 4])) {
			find(n - 1, l3, l1, l2);
		}
		if (!fl && take(l3, l2)) {
			find(n - 1, a[n - 4], l1, l3);
		}
	}

	void count() throws IOException {
		int n = nextInt();
		pos = new HashSet<String>();
		a = new String[n];
		for (int i = 0; i < n; i++) {
			a[i] = nextToken();
		}
		if (n == 1) {
			out.println("YES");
			return;
		}
		if (n == 2) {
			if (take(a[0], a[1])) {
				out.println("YES");
			} else {
				out.println("NO");
			}
			return;
		}
		find(n, a[n - 3], a[n - 2], a[n - 1]);

		if (fl) {
			out.println("YES");
		} else {
			out.println("NO");
		}
	}

	BufferedReader in;
	PrintWriter out;
	StringTokenizer str;
	String readline;

	String nextToken() throws IOException {
		while (str == null || !str.hasMoreTokens()) {
			readline = in.readLine();
			if (readline == null) {
				return null;
			} else {
				str = new StringTokenizer(readline);
			}
		}
		return str.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	void run() throws IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		count();
		out.close();
	}

	public static void main(String[] args) throws IOException {
		new B().run();
	}
}

import java.io.BufferedInputStream;
import java.io.IOException;
import java.util.InputMismatchException;

public class Main
{
	private boolean[][] canCombine;
	private boolean[][][][] dp;

	public boolean dfs(int n, int x, int y, int z)
	{
		if(dp[n][x][y][z])
		{
			return false;
		}
		if(3 == n)
		{
			return canCombine[x][z] && canCombine[y][z];
		}
		if(canCombine[y][z] && dfs(n - 1, n - 4, x, z))
		{
			return true;
		}
		if(canCombine[n - 4][z] && dfs(n - 1, z, x, y))
		{
			return true;
		}
		dp[n][x][y][z] = true;
		return false;
	}

	public void foo()
	{
		MyScanner scan = new MyScanner();
		int n = scan.nextInt();
		String[] s = new String[n];
		canCombine = new boolean[n][n];
		for(int i = 0;i < n;++i)
		{
			s[i] = scan.next();
			for(int j = 0;j < i;++j)
			{
				if(s[i].charAt(0) == s[j].charAt(0) || s[i].charAt(1) == s[j].charAt(1))
				{
					canCombine[i][j] = true;
					canCombine[j][i] = true;
				}
			}
		}
		dp = new boolean[n + 1][n][n][n];
		if(1 == n)
		{
			System.out.println("YES");
		}
		else if(2 == n)
		{
			System.out.println(canCombine[0][1] ? "YES" : "NO");
		}
		else
		{
			System.out.println(dfs(n, n - 3, n - 2, n - 1) ? "YES" : "NO");
		}
	}

	public static void main(String[] args)
	{
		new Main().foo();
	}

	class MyScanner
	{
	    private byte[] buf = new byte[1024];
	    private int curChar;
	    private int numChars;
	    BufferedInputStream bis = new BufferedInputStream(System.in);

	    public int read()
	    {
	        if (-1 == numChars)
	        {
	        	throw new InputMismatchException();
	        }
	        if (curChar >= numChars)
	        {
	            curChar = 0;
	            try
	            {
	                numChars = bis.read(buf);
	            }
	            catch (IOException e)
	            {
	                throw new InputMismatchException();
	            }
	            if (numChars <= 0)
	            {
	            	return -1;
	            }
	        }
	        return buf[curChar++];
	    }

	    public int nextInt()
	    {
	        int c = read();
	        while (isSpaceChar(c))
	        {
	        	c = read();
	        }
	        int sgn = 1;
	        if (c == '-')
	        {
	            sgn = -1;
	            c = read();
	        }
	        int res = 0;
	        do
	        {
	            if (c < '0' || c > '9')
	            {
	            	throw new InputMismatchException();
	            }
	            res *= 10;
	            res += c - '0';
	            c = read();
	        } while (!isSpaceChar(c));
	        return res * sgn;
	    }

	    public String next()
	    {
	        int c = read();
	        while (isSpaceChar(c))
	        {
	        	c = read();
	        }
	        StringBuilder res = new StringBuilder();
	        do
	        {
	            res.appendCodePoint(c);
	            c = read();
	        } while (!isSpaceChar(c));
	        return res.toString();
	    }

	    private boolean isSpaceChar(int c)
	    {
	        return ' ' == c || '\n' == c || '\r' == c || '\t' == c || -1 == c;
	    }
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;

public class B {

    public static void main(String[] args) throws NumberFormatException,
            IOException {
        BufferedReader buf = new BufferedReader(
                new InputStreamReader(System.in));
        int n = Integer.parseInt(buf.readLine());
        String[] a = buf.readLine().split(" ");
        map = new HashMap<String, Integer>();
        for (int i = 0; i < a.length; i++)
            if (!map.containsKey(a[i]))
                map.put(a[i], i);
        check = false;
        boolean[][][][] dp = new boolean[n][n][n][n];
        dfs(a, dp, a.length - 1);

        if (check)
            System.out.println("YES");
        else
            System.out.println("NO");
    }

    static HashMap<String, Integer> map;

    private static void dfs(String[] a, boolean[][][][] dp, int i) {
        if (i == 0)
            check = true;
        else if (i - 2 >= 0
                && dp[i][map.get(a[i])][map.get(a[i - 1])][map.get(a[i - 2])])
            return;
        else if (!check) {
            if (i - 2 >= 0)
                dp[i][map.get(a[i])][map.get(a[i - 1])][map.get(a[i - 2])] = true;
            int cnt = 0;
            for (int j = i - 1; j >= 0 && cnt < 2; j -= 2) {
                cnt++;
                String temp = a[j];
                if (a[j].charAt(0) == a[i].charAt(0)
                        || a[j].charAt(1) == a[i].charAt(1)) {
                    a[j] = a[i];

                    dfs(a, dp, i - 1);
                    a[j] = temp;
                }
            }
        }

    }

    static boolean check;

}

import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.util.HashMap;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.math.BigInteger;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		OutputWriter out = new OutputWriter(outputStream);
		TaskB solver = new TaskB();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskB {
    HashMap<State, Boolean> hashMap;
    String[] s;

    public static class State {
        int n;
        String a, b, c;

        public State(int n, String a, String b, String c) {
            this.n = n;
            this.a = a;
            this.b = b;
            this.c = c;
        }

        public boolean equals(Object o) {
            if (this == o)
                return true;
            if (o == null || getClass() != o.getClass())
                return false;
            State state = (State) o;
            if (n != state.n)
                return false;
            if (!a.equals(state.a))
                return false;
            if (!b.equals(state.b))
                return false;
            if (!c.equals(state.c))
                return false;
            return true;
        }

        public int hashCode() {
            int res = a.hashCode();
            res = 31 * res + b.hashCode();
            res = 31 * res + c.hashCode();
            res = 31 * res + n;
            return res;
        }
    }

    public boolean ok(String s1, String s2) {
        return s1.charAt(0) == s2.charAt(0) || s1.charAt(1) == s2.charAt(1);
    }

    public boolean func(State state) {
        State state1, state2;
        state1 = state2 = null;
        boolean b, b1, b2;

        if (hashMap.containsKey(state))
            return hashMap.get(state);
        if (state.n == 1)
            return true;
        if (state.n == 2)
            return ok(state.b, state.c);
        if (state.n == 3)
            return ok(state.a, state.c) && ok(state.b, state.c);
        if (ok(state.b, state.c))
            state1 = new State(state.n - 1, s[state.n-4], state.a, state.c);
        if (ok(s[state.n-4], state.c))
            state2 = new State(state.n - 1, state.c, state.a, state.b);
        if (state1 == null && state2 == null) {
            hashMap.put(state, false);
            return false;
        }
        if (state1 == null) {
            b2 = func(state2);
            hashMap.put(state2, b2);
            return b2;
        }
        if (state2 == null) {
            b1 = func(state1);
            hashMap.put(state1, b1);
            return b1;
        }
        b1 = func(state1);
        b2 = func(state2);
        b = b1 || b2;
        hashMap.put(state1, b1);
        hashMap.put(state2, b2);
        hashMap.put(state, b);
        return b;
    }

	public void solve(int testNumber, InputReader in, OutputWriter out) {
        int n = in.readInt();
        s = new String[n];
        for (int i = 0; i < n; i++)
            s[i] = in.readString();

        hashMap = new HashMap<State, Boolean>();
        String a, b, c;
        a = b = c = new String("dummy");
        try {
            c = new String(s[n-1]);
            b = new String(s[n-2]);
            a = new String(s[n-3]);
        }
        catch (ArrayIndexOutOfBoundsException e) {

        }

        if (func(new State(n, a, b, c)))
            out.printLine("YES");
        else
            out.printLine("NO");
	}
}

class InputReader {

    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;

    public InputReader(InputStream stream) {
        this.stream = stream;
    }

    public int read() {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = stream.read(buf);
            }
            catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    public int readInt() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        int res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public String readString() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        StringBuffer res = new StringBuffer();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isSpaceChar(c));
        return res.toString();
    }

    public static boolean isSpaceChar(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    }

class OutputWriter {
    private final PrintWriter writer;

    public OutputWriter(OutputStream outputStream) {
        writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
    }

    public OutputWriter(Writer writer) {
        this.writer = new PrintWriter(writer);
    }

    public void print(Object...objects) {
        for (int i = 0; i < objects.length; i++) {
            if (i != 0)
                writer.print(' ');
            writer.print(objects[i]);
        }
    }

    public void printLine(Object...objects) {
        print(objects);
        writer.println();
    }

    public void close() {
        writer.close();
    }

    }

import java.io.*;
import java.util.*;
import java.math.*;

import static java.lang.Math.*;

public class Main implements Runnable {

	//«2», «3», «4», «5», «6», «7», «8», «9», «T», «J», «Q», «K», «A».

	class Triplet {
		String card1, card2, card3;

		public Triplet(String card1, String card2, String card3) {
			this.card1 = card1;
			this.card2 = card2;
			this.card3 = card3;
		}

		@Override
		public boolean equals(Object obj) {
			if (obj instanceof Triplet) {
				Triplet t = (Triplet)obj;
				return this.card1.equals(t.card1) && this.card2.equals(t.card2) && this.card3.equals(t.card3);
			} else {
				return false;
			}
		}

		@Override
		public int hashCode() {
			final int prime = 31;
			return card1.hashCode() + prime * (card2.hashCode() + prime * card3.hashCode());
		}
	}

	boolean mayPutOn(String top, String bottom) {
		return top.charAt(0) == bottom.charAt(0) || top.charAt(1) == bottom.charAt(1);
	}

	void solve() throws Exception {
		int n = sc.nextInt();
		String[] cards = new String[n];
		for (int i = 0; i < n; i++) {
			cards[i] = sc.nextToken();
		}
		if (n == 1 || n == 2 && mayPutOn(cards[1], cards[0])) {
			out.println("YES");
			return;
		}
		if (n == 1 || n == 2) {
			out.println("NO");
			return;
		}
		HashSet<Triplet>[] dp = new HashSet[n];
		for (int i = 0; i < n; i++) {
			dp[i] = new HashSet<Triplet>();
		}
		dp[n - 1].add(new Triplet(cards[n - 1], cards[n - 2], cards[n - 3]));
		for (int i = n - 1; i >= 3; i--) {
			for (Triplet t : dp[i]) {
				if (mayPutOn(t.card1, cards[i - 3])) {
					dp[i - 1].add(new Triplet(t.card2, t.card3, t.card1));
				}
				if (mayPutOn(t.card1, t.card2)) {
					dp[i - 1].add(new Triplet(t.card1, t.card3, cards[i - 3]));
				}
			}
		}
		for (Triplet t : dp[2]) {
			if (mayPutOn(t.card1, t.card2) && mayPutOn(t.card1, t.card3)) {
				out.println("YES");
				return;
			}
		}
		out.println("NO");
	}

	BufferedReader in;
	PrintWriter out;
	FastScanner sc;

	static Throwable uncaught;

	@Override
	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			sc = new FastScanner(in);
			solve();
		} catch (Throwable t) {
			Main.uncaught = t;
		} finally {
			out.close();
		}
	}

	public static void main(String[] args) throws Throwable {
		Thread t = new Thread(null, new Main(), "", 128 * 1024 * 1024);
		t.start();
		t.join();
		if (uncaught != null) {
			throw uncaught;
		}
	}

}

class FastScanner {

	BufferedReader reader;
	StringTokenizer strTok;

	public FastScanner(BufferedReader reader) {
		this.reader = reader;
	}

	public String nextToken() throws IOException {
		while (strTok == null || !strTok.hasMoreTokens()) {
			strTok = new StringTokenizer(reader.readLine());
		}
		return strTok.nextToken();
	}

	public int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	public long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	public double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class BB {
    static byte[][][][] dp;
    static String[] s;

    public static byte can(int a, int b, int c) {
        if (s[b].charAt(0) != s[c].charAt(0)
                && s[b].charAt(1) != s[c].charAt(1))
            return 0;
        if (s[a].charAt(0) != s[c].charAt(0)
                && s[a].charAt(1) != s[c].charAt(1))
            return 0;
        return 1;
    }

    public static byte go(int i, int a, int b, int c) {
        if (i == 2)
            return can(a, b, c);
        else if (dp[i][a][b][c] != -1)
            return dp[i][a][b][c];
        else {
            byte res = 0;
            if (s[b].charAt(0) == s[c].charAt(0)
                    || s[b].charAt(1) == s[c].charAt(1))
                res |= go(i - 1, i - 3, a, c);
            if (s[i - 3].charAt(0) == s[c].charAt(0)
                    || s[i - 3].charAt(1) == s[c].charAt(1))
                res |= go(i - 1, c, a, b);
            return dp[i][a][b][c] = res;
        }
    }

    public static void main(String[] args) throws Exception {
        InputReader in = new InputReader(System.in);
        String[] res = { "NO", "YES" };
        int n = in.nextInt();
        s = new String[n];
        for (int i = 0; i < n; i++)
            s[i] = in.next();
        dp = new byte[n][n][n][n];
        for (int i = 0; i < dp.length; i++)
            for (int j = 0; j < dp.length; j++)
                for (int k = 0; k < dp.length; k++)
                    for (int l = 0; l < dp.length; l++)
                        dp[i][j][k][l] = -1;
        if (n >= 3)
            System.out.println(res[go(n - 1, n - 3, n - 2, n - 1)]);
        else {
            if (n == 1)
                System.out.println("YES");
            else if (n == 2) {
                if (s[0].charAt(1) == s[1].charAt(1)
                        || s[0].charAt(0) == s[1].charAt(0))
                    System.out.println("YES");
                else
                    System.out.println("NO");
            }
        }
    }

    static class InputReader {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
    }
}

import static java.lang.Math.min;
import static java.lang.System.arraycopy;
import static java.util.Arrays.copyOfRange;

import java.io.*;
import java.util.*;

public class B {

	static String TYPES = "SDHC";
	static String VALUES = "23456789TJQKA";

	static class State {
		@Override
		public int hashCode() {
			final int prime = 31;
			int result = 1;
			result = prime * result + Arrays.hashCode(cardsOnTop);
			result = prime * result + numberOfCards;
			return result;
		}

		@Override
		public boolean equals(Object obj) {
			if (this == obj)
				return true;
			if (obj == null)
				return false;
			if (getClass() != obj.getClass())
				return false;
			State other = (State) obj;
			if (!Arrays.equals(cardsOnTop, other.cardsOnTop))
				return false;
			if (numberOfCards != other.numberOfCards)
				return false;
			return true;
		}

		int numberOfCards;
		int[] cardsOnTop;

		private State(int numberOfCards, int[] cardsOnTop) {
			this.numberOfCards = numberOfCards;
			this.cardsOnTop = cardsOnTop;
		}

		boolean success() {
			return numberOfCards == 1;
		}

		State go1(int[] inputCards) {
			if (numberOfCards <= 1) {
				return null;
			}
			int topCard = cardsOnTop[0];
			int otherCard = cardsOnTop[1];
			if (!good(topCard, otherCard)) {
				return null;
			}
			if (cardsOnTop.length == numberOfCards) {
				int[] newTop = copyOfRange(cardsOnTop, 1, cardsOnTop.length);
				newTop[0] = topCard;
				return new State(numberOfCards - 1, newTop);
			} else {
				int[] newTop = new int[cardsOnTop.length];
				arraycopy(cardsOnTop, 1, newTop, 0, cardsOnTop.length - 1);
				newTop[cardsOnTop.length - 1] = inputCards[numberOfCards - cardsOnTop.length - 1];
				newTop[0] = topCard;
				return new State(numberOfCards - 1, newTop);
			}
		}

		State go2(int[] inputCards) {
			if (numberOfCards <= 3) {
				return null;
			}
			int topCard = cardsOnTop[0];
			int otherCard = inputCards[numberOfCards - 4];
			if (!good(topCard, otherCard)) {
				return null;
			}
			if (cardsOnTop.length == numberOfCards) {
				throw new AssertionError();
			} else {
				int[] newTop = new int[cardsOnTop.length];
				arraycopy(cardsOnTop, 1, newTop, 0, cardsOnTop.length - 1);
				newTop[cardsOnTop.length - 1] = topCard;
				return new State(numberOfCards - 1, newTop);
			}
		}
	}

	static boolean good(int card1, int card2) {
		int xor = card1 ^ card2;
		return (xor & 3) == 0 || xor < 4;
	}

	private static void solve() throws IOException {
		int n = nextInt();
		int[] inputCards = new int[n];
		for (int i = 0; i < n; i++) {
			inputCards[i] = nextCard();
		}
		out.println(yes(inputCards) ? "YES" : "NO");
	}

	static boolean yes(int[] inputCards) {
		int n = inputCards.length;
		int cnt = min(n, 3);
		int[] initialCardsOnTop = new int[cnt];
		for (int i = 0; i < cnt; i++) {
			initialCardsOnTop[i] = inputCards[n - 1 - i];
		}
//		System.err.println(Arrays.toString(inputCards));
		State initialState = new State(n, initialCardsOnTop);
		Queue<State> q = new ArrayDeque<State>();
		Set<State> visited = new HashSet<State>();
		q.add(initialState);
		visited.add(initialState);
		while (!q.isEmpty()) {
			State s = q.poll();
			if (s.success()) {
				return true;
			}
			for (State to: new State[]{s.go1(inputCards), s.go2(inputCards)}) {
				if (to == null) {
					continue;
				}
				if (!visited.contains(to)) {
					visited.add(to);
					q.add(to);
				}
			}
		}
		return false;
	}

	static int nextCard() throws IOException {
		String s = nextToken();
		int type = TYPES.indexOf(s.charAt(1));
		int value = VALUES.indexOf(s.charAt(0));
		return value * 4 + type;
	}

	public static void main(String[] args) {
		try {
			br = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			solve();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			System.exit(239);
		}
	}

	static BufferedReader br;
	static StringTokenizer st;
	static PrintWriter out;

	static String nextToken() throws IOException {
		while (st == null || !st.hasMoreTokens()) {
			String line = br.readLine();
			if (line == null) {
				return null;
			}
			st = new StringTokenizer(line);
		}
		return st.nextToken();
	}

	static int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	static long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	static double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
}

import java.util.*;
import java.math.*;
import java.io.*;

public class Main
	{
	public static void main(String args[]) throws IOException
		{
		Scanner c=new Scanner(System.in);
		int N=Integer.parseInt(c.nextLine());
		int card[]=new int[N];
		String C[]=c.nextLine().split(" ");
		for(int i=0;i<N;i++)
			card[i]=val(C[i].charAt(0))+suit(C[i].charAt(1));
		//System.out.println(Arrays.toString(card));
		if(N==1)
			{
			System.out.println("YES");
			return;
			}
		else if(N==2)
			{
			if(match(card[0],card[1]))
				System.out.println("YES");
			else
				System.out.println("NO");
			return;
			}
		else if(N==3)
			{
			if(match(card[0],card[2])&&match(card[1],card[2]))
				System.out.println("YES");
			else
				System.out.println("NO");
			return;
			}
		int DP[][][][]=new int[N][52][52][52];
		for(int i=0;i<52;i++)
			{
			for(int j=0;j<52;j++)
				{
				for(int k=0;k<52;k++)
					{
					if(match(k,j)&&match(k,i))
						DP[0][i][j][k]=1;
					}
				}
			}
		for(int index=1;index<=N-3;index++)
			{
			for(int i=0;i<52;i++)
				{
				for(int j=0;j<52;j++)
					{
					for(int k=0;k<52;k++)
						{
						int way1=0, way2=0;
						if(match(j,k))
							way1=DP[index-1][card[index-1]][i][k];
						if(match(k,card[index-1]))
							way2=DP[index-1][k][i][j];
						DP[index][i][j][k]=Math.max(way1,way2);
						}
					}
				}
			}
		if(DP[N-3][card[N-3]][card[N-2]][card[N-1]]==1)
			System.out.println("YES");
		else
			System.out.println("NO");
		}

	private static boolean match(int c1,int c2)
		{
		if(c1/13==c2/13)
			return true;
		else if(c1%13==c2%13)
			return true;
		return false;
		}

	private static int val(char c)
		{
		if(c>='2'&&c<='9')
			return c-'2';
		if(c=='T')
			return 8;
		if(c=='J')
			return 9;
		if(c=='Q')
			return 10;
		if(c=='K')
			return 11;
		if(c=='A')
			return 12;
		return 0;
		}
	private static int suit(char charAt)
		{
		if(charAt=='S')
			return 0;
		if(charAt=='D')
			return 13;
		if(charAt=='H')
			return 26;
		if(charAt=='C')
			return 39;
		return 0;
		}
	}
//must declare new classes here

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Locale;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class CF208B {

    BufferedReader in;
    StringTokenizer st;
    PrintWriter out;

    public static void main(String[] args) {
        CF208B t = new CF208B();
        t.init();
    }

    void run() throws Exception  {
        int n = Int();
        String[] array = new String[n];
        for (int i = 0; i < array.length; i++) {
            array[i] = String();
        }
        PrintLn(possible(array) ? "YES" : "NO");
    }

    private Object[] memory = new Object[53];

    boolean possible(String[] cards) {
        if (cards.length == 1) {
            return true;
        } else if (cards.length == 2) {
            return compatible(cards[0], cards[1]);
        } else if (cards.length == 3) {
            return compatible(cards[1], cards[2]) && compatible(cards[0], cards[2]);
        } else {
            String lastThree = cards[cards.length - 3] + cards[cards.length - 2] + cards[cards.length - 1];
            if (memory[cards.length] == null) {
                memory[cards.length] = new TreeMap<String, Boolean>();
            }
            if (((TreeMap<String, Boolean>) memory[cards.length]).containsKey(lastThree)) {
                return ((TreeMap<String, Boolean>) memory[cards.length]).get(lastThree);
            }

            if (compatible(cards[cards.length - 2], cards[cards.length - 1])) {
                String[] newArray = new String[cards.length - 1];
                for (int i = 0; i < newArray.length - 1; i++) {
                    newArray[i] = cards[i];
                }
                newArray[newArray.length - 1] = cards[cards.length - 1];
                if (possible(newArray)) {
                    ((TreeMap<String, Boolean>) memory[cards.length]).put(lastThree, true);
                    return true;
                }
            }
            if (compatible(cards[cards.length - 4], cards[cards.length - 1])) {
                String[] newArray = new String[cards.length - 1];
                for (int i = 0; i < newArray.length; i++) {
                    newArray[i] = cards[i];
                }
                newArray[newArray.length - 3] = cards[cards.length - 1];
                boolean res = possible(newArray);
                ((TreeMap<String, Boolean>) memory[cards.length]).put(lastThree, res);
                return res;
            }
            return false;
        }
    }

    boolean compatible(String card1, String card2) {
        return card1.charAt(0) == card2.charAt(0) || card1.charAt(1) == card2.charAt(1);
    }

    void init() {
        try {
            Locale.setDefault(Locale.US);
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(new OutputStreamWriter(System.out));
            run();
            out.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    String next() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
    }

    String String() throws Exception {
        return next();
    }

    int Int() throws Exception {
        return Integer.parseInt(next());
    }

    long Long() throws Exception {
        return Long.parseLong(next());
    }

    double Double() throws Exception {
        return Double.parseDouble(next());
    }

    void PrintLn(Object line) {
        out.println(line);
    }

}

//package round130;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;

public class B {
	InputStream is;
	PrintWriter out;
	String INPUT = "";

	void solve()
	{
		int n = ni();
		char[][] c = new char[n][];
		for(int i = 0;i < n;i++){
			c[i] = ns(2);
		}
		if(n >= 3){
			boolean[][][][] dp = new boolean[2][n][n][n];
			dp[0][n-3][n-2][n-1] = true;
			int cur = 1, prev = 0;
			for(int x = n-1;x >= 3;x--, cur^=1, prev^=1){
				for(int i = 0;i < n;i++){
					for(int j = 0;j < n;j++){
						Arrays.fill(dp[cur][i][j], false);
					}
				}
				for(int i = 0;i < n;i++){
					for(int j = 0;j < n;j++){
						for(int k = 0;k < n;k++){
							if(dp[prev][i][j][k]){
								dp[cur][x-3][i][k] |= c[j][0]==c[k][0] || c[j][1]==c[k][1];
								dp[cur][k][i][j] |= c[x-3][0]==c[k][0] || c[x-3][1]==c[k][1];
							}
						}
					}
				}
			}
			for(int i = 0;i < n;i++){
				for(int j = 0;j < n;j++){
					for(int k = 0;k < n;k++){
						if(dp[prev][i][j][k]){
							if(c[j][0]==c[k][0]||c[j][1]==c[k][1]){
								if(c[i][0]==c[k][0]||c[i][1]==c[k][1]){
									out.println("YES");
									return;
								}
							}
						}
					}
				}
			}
			out.println("NO");
		}else if(n == 1){
			out.println("YES");
		}else{
			if(c[0][0]==c[1][0]||c[0][1]==c[1][1]){
				out.println("YES");
			}else{
				out.println("NO");
			}
		}
	}

	void run() throws Exception
	{
		is = oj ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		tr(System.currentTimeMillis()-s+"ms");
	}

	public static void main(String[] args) throws Exception
	{
		new B().run();
	}

	public int ni()
	{
		try {
			int num = 0;
			boolean minus = false;
			while((num = is.read()) != -1 && !((num >= '0' && num <= '9') || num == '-'));
			if(num == '-'){
				num = 0;
				minus = true;
			}else{
				num -= '0';
			}

			while(true){
				int b = is.read();
				if(b >= '0' && b <= '9'){
					num = num * 10 + (b - '0');
				}else{
					return minus ? -num : num;
				}
			}
		} catch (IOException e) {
		}
		return -1;
	}

	public long nl()
	{
		try {
			long num = 0;
			boolean minus = false;
			while((num = is.read()) != -1 && !((num >= '0' && num <= '9') || num == '-'));
			if(num == '-'){
				num = 0;
				minus = true;
			}else{
				num -= '0';
			}

			while(true){
				int b = is.read();
				if(b >= '0' && b <= '9'){
					num = num * 10 + (b - '0');
				}else{
					return minus ? -num : num;
				}
			}
		} catch (IOException e) {
		}
		return -1;
	}

	public String ns()
	{
		try{
			int b = 0;
			StringBuilder sb = new StringBuilder();
			while((b = is.read()) != -1 && (b == '\r' || b == '\n' || b == ' '));
			if(b == -1)return "";
			sb.append((char)b);
			while(true){
				b = is.read();
				if(b == -1)return sb.toString();
				if(b == '\r' || b == '\n' || b == ' ')return sb.toString();
				sb.append((char)b);
			}
		} catch (IOException e) {
		}
		return "";
	}

	public char[] ns(int n)
	{
		char[] buf = new char[n];
		try{
			int b = 0, p = 0;
			while((b = is.read()) != -1 && (b == ' ' || b == '\r' || b == '\n'));
			if(b == -1)return null;
			buf[p++] = (char)b;
			while(p < n){
				b = is.read();
				if(b == -1 || b == ' ' || b == '\r' || b == '\n')break;
				buf[p++] = (char)b;
			}
			return Arrays.copyOf(buf, p);
		} catch (IOException e) {
		}
		return null;
	}

	double nd() { return Double.parseDouble(ns()); }
	boolean oj = System.getProperty("ONLINE_JUDGE") != null;
	void tr(Object... o) { if(!oj)System.out.println(Arrays.deepToString(o)); }
}

import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);

        int n = s.nextInt();

        ArrayList<String> ar = new ArrayList<String>();
        for (int i = 0; i < n; i++) {
            ar.add(s.next());
        }
        ok = 0;
        tree = new TreeSet<String>();
//      System.out.println(ar.toString());
        dfs(ar);

        if(ok==1)
            System.out.println("YES");
        else System.out.println("NO");
    }
    static int ok;
    private static void dfs(ArrayList<String> ar) {
//      System.out.println(ar.toString());
        if(tree.contains(ar.toString()))
            return ;
        tree.add(ar.toString());

        if(ok==1)
            return ;
        if(ar.size() < 2){
            ok = 1;
            return;
        }

        int len = ar.size();
        String a = ar.get(len-1);
        String b = ar.get(len-2);
        if(a.charAt(0)==b.charAt(0) || a.charAt(1)==b.charAt(1)){
            ArrayList<String> ar1 = new ArrayList<String>(ar);
            ar1.remove(len-2);
            dfs(ar1);
        }

        if(len >= 4){
            b = ar.get(len-4);
            if(a.charAt(0)==b.charAt(0) || a.charAt(1)==b.charAt(1)){
                ArrayList<String> ar2 = new ArrayList<String>(ar);
                ar2.set(len-4, a);
                ar2.remove(len-1);
                dfs(ar2);
            }
        }

    }
    static TreeSet<String> tree;

}

import static java.lang.Math.*;
import static java.util.Arrays.*;
import java.util.*;
import java.io.*;

public class Main {

	int n;
	int[] a;
	boolean visited[][][][];
	void solve() {
		n = sc.nextInt();
		a = new int[n + 3];
		for (int i = 0; i < n; i++) {
			a[n - 1 - i] = getId(sc.next());
		}
		a[n] = a[n+1] = a[n+2] = 52;

		visited = new boolean[n][53][53][53];
		solved = false;
		rec(0, a[0], a[1], a[2]);
		out.println(solved ? "YES":"NO");
	}

	boolean solved;
	void rec(int p, int x0, int x1, int x2) {
		if (p == n - 1) {
			solved = true;
			return;
		}

		if (visited[p][x0][x1][x2]) return;
		visited[p][x0][x1][x2] = true;

		if (can(x0, x1))
			rec(p + 1, x0, x2, a[p+3]);
		if (can(x0, a[p+3]))
			rec(p + 1, x1, x2, x0);
	}

	boolean can(int x, int y) {
		if (y == 52) return false;
		return (x / 4) == (y / 4) || (x % 4) == (y % 4);
	}

	int getId(String s) {
		return "A23456789TJQK".indexOf(s.charAt(0)) * 4 + "SDHC".indexOf(s.charAt(1));
	}

	public static void main(String[] args) throws Exception {
		Class<?> here = new Object(){}.getClass().getEnclosingClass();
		try {
			String packageName = here.getPackage().getName();
			packageName = "src/" + packageName.replaceAll("\\.", "/") + "/";
			System.setIn(new FileInputStream(packageName + "input.txt"));
//			System.setOut(new PrintStream(new FileOutputStream(packageName + "output.txt")));
		} catch (FileNotFoundException e) {
		} catch (NullPointerException e) {
		}

		Object o = Class.forName(here.getName()).newInstance();
		o.getClass().getMethod("run").invoke(o);
	}

	static void tr(Object... os) {
		System.err.println(deepToString(os));
	}

	MyScanner sc = null;
	PrintWriter out = null;
	public void run() throws Exception {
		sc = new MyScanner(System.in);
		out = new PrintWriter(System.out);
		for (;sc.hasNext();) {
			solve();
			out.flush();
		}
		out.close();
	}

	void print(int[] a) {
		out.print(a[0]);
		for (int i = 1; i < a.length; i++) out.print(" " + a[i]);
		out.println();
	}

	class MyScanner {
		String line;
		BufferedReader reader;
		StringTokenizer tokenizer;

		public MyScanner(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream));
			tokenizer = null;
		}
		public void eat() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					line = reader.readLine();
					if (line == null) {
						tokenizer = null;
						return;
					}
					tokenizer = new StringTokenizer(line);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
		}
		public String next() {
			eat();
			return tokenizer.nextToken();
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		public boolean hasNext() {
			eat();
			return (tokenizer != null && tokenizer.hasMoreElements());
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++) a[i] = nextInt();
			return a;
		}
	}
}

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.Properties;
import java.util.Stack;

/**
 * Works good for CF
 * @author cykeltillsalu
 */
public class D130 {

	//some local config
	static boolean test = false;
	static String testDataFile = "testdata.txt";
	static String feedFile = "feed.txt";
	CompetitionType type = CompetitionType.CF;
	private static String ENDL = "\n";

	class S {
		int[] cards;

		public S(int[] cards) {
			this.cards = cards;
		}

		@Override
		public String toString() {
			return "S [cards=" + Arrays.toString(cards) + "]";
		}
	}

	// solution
	private void solve() throws Throwable {
		works = false;
		int n = iread();
		int[] card = new int[n];
		cache = new boolean[53][53][53][53];

		for (int i = 0; i < n; i++) {
			String wread = wread();
			int val = toSuite(wread.charAt(1) + "") + toValue(wread.charAt(0));
			card[i] = val;
		}

		rec(card, n - 1);
		if(works){
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
		out.flush();
	}

	private int toValue(char c) {
		switch (c) {
		case 'T':
			return 10;
		case 'J':
			return 11;
		case 'Q':
			return 12;
		case 'K':
			return 0;
		case 'A':
			return 1;

		}
		return c - '0';
	}

	boolean[][][][] cache;
	boolean works = false;

	private void rec(int[] card, int i) {
		int cnt = 0;
		for (int j = card.length-1; j >= 0; j--) {
			if(card[j] >= 0){
				cnt ++;
			}
			if(cnt > 1){
				break;
			}
		}
		if(cnt == 1){
			works = true;
			return;
		}
		if(i <= 0){
			return;
		}
		if(card[i] == -1 && i > 0){
			rec(card, i-1);
		}
		if(i >= 2){
			if(cache[i][card[i]+1][card[i-1]+1][card[i-2]+1]){
				return;
			}
			cache[i][card[i]+1][card[i-1]+1][card[i-2]+1] = true;
		}

		int suiteA = suite(card[i]);
		int valueA = value(card[i]);
		if(i >= 3){
			int suiteB = suite(card[i-3]);
			int valueB = value(card[i-3]);
			if(suiteA == suiteB || valueA == valueB){
				int tmp = card[i];
				int tmp2 = card[i-3];
				card[i-3] = card[i];
				card[i] = -1;
				rec(card, i-1);
				card[i-3] = tmp2;
				card[i] = tmp;
			}
		}

		if(suiteA == suite(card[i-1]) || valueA == value(card[i-1])){
			int tmp = card[i];
			int tmp2 = card[i-1];
			card[i-1] = card[i];
			card[i] = -1;
			rec(card, i-1);
			card[i-1] = tmp2;
			card[i] = tmp;
		}
	}

	private int value(int i) {
		return i - suite(i)*13;
	}

	private int suite(int i) {
		return (i/13);
	}

	private int toSuite(String string) {
		if(string.equals("S")){
			return 0;
		}
		if(string.equals("D")){
			return 13*1;
		}
		if(string.equals("H")){
			return 13*2;
		}
		if(string.equals("C")){
			return 13*3;
		}
		return 0;
	}

	public int iread() throws Exception {
		return Integer.parseInt(wread());
	}

	public double dread() throws Exception {
		return Double.parseDouble(wread());
	}

	public long lread() throws Exception {
		return Long.parseLong(wread());
	}

	public String wread() throws IOException {
		StringBuilder b = new StringBuilder();
		int c;
		c = in.read();
		while (c >= 0 && c <= ' ')
			c = in.read();
		if (c < 0)
			return "";
		while (c > ' ') {
			b.append((char) c);
			c = in.read();
		}
		return b.toString();
	}

	public static void main(String[] args) throws Throwable {

		if(test){ //run all cases from testfile:
			BufferedReader testdataReader = new BufferedReader(new FileReader(testDataFile));
			String readLine = testdataReader.readLine();
			int casenr = 0;
			out: while (true) {
				BufferedWriter w = new BufferedWriter(new FileWriter(feedFile));
				if(!readLine.equalsIgnoreCase("input")){
					break;
				}
				while (true) {
					readLine = testdataReader.readLine();
					if(readLine.equalsIgnoreCase("output")){
						break;
					}
					w.write(readLine + "\n");
				}
				w.close();
				System.out.println("Answer on case "+(++casenr)+": ");

				new D130().solve();
				System.out.println("Expected answer: ");

				while (true) {
					readLine = testdataReader.readLine();

					if(readLine == null){
						break out;
					}
					if(readLine.equalsIgnoreCase("input")){
						break;
					}
					System.out.println(readLine);
				}
				System.out.println("----------------");
			}
			testdataReader.close();
		} else { // run on server
			new D130().solve();
		}
		out.close();
	}

	public D130() throws Throwable {
		if (test) {
			in = new BufferedReader(new FileReader(new File(feedFile)));
		}
	}

	InputStreamReader inp = new InputStreamReader(System.in);
	BufferedReader in = new BufferedReader(inp);
	static BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out));

	enum CompetitionType {CF, OTHER};
}

import java.io.*;
import java.util.*;

public class B {
    public static void main(String[] args) throws Exception {
        new B().solve();
    }

    void solve() throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(in.readLine());
        int[] card = new int[N];
        String[] sp = in.readLine().split(" ");

        String value = "A23456789TJQK";
        String suit = "SDHC";

        for (int i = 0; i < N; i++) {
            int a = value.indexOf(sp[i].charAt(0));
            int b = suit.indexOf(sp[i].charAt(1));
            card[i] = b * 13 + a;
        }

        if (N <= 3) {
            boolean s = solve(card);
            System.out.println(s ? "YES" : "NO");
            return;
        }
        boolean[][][][] dp = new boolean[N][52][52][52];
        // [0]
        for (int a = 0; a < 52; a++) {
            for (int b = 0; b < 52; b++) {
                for (int c = 0; c < 52; c++) {
                    dp[0][a][b][c] = solve(new int[] { a, b, c });
                }
            }
        }

        for (int i = 1; i <= N - 3; i++) {
            int p = card[i - 1];
            for (int a = 0; a < 52; a++) {
                for (int b = 0; b < 52; b++) {
                    for (int c = 0; c < 52; c++) {
                        dp[i][a][b][c] = false;
                        if (can(c, b) && dp[i - 1][p][a][c]) {
                            dp[i][a][b][c] = true;
                        } else if (can(c, p) && dp[i - 1][c][a][b]) {
                            dp[i][a][b][c] = true;
                        }
                    }
                }
            }
        }

        boolean d = dp[N - 3][card[N - 3]][card[N - 2]][card[N - 1]];
        System.out.println(d ? "YES" : "NO");

    }
    boolean solve(int[] c) {
        int len = c.length;
        if (len == 1) {
            return true;
        } else {
            if (can(c[len - 2], c[len - 1])) {
                if (len == 2) {
                    return true;
                } else if (can(c[len - 3], c[len - 1])) {
                    return true;
                }
            }
            return false;
        }
    }
    boolean can(int a, int b) {
        return a % 13 == b % 13 || a / 13 == b / 13;
    }
}

//

import java.util.*;
import java.io.*;
import static java.lang.Math.*;

public class B{
    public static void main(String[] args) throws Exception{
        new B().run();
    }

    int n;
    String[] cards;
    Set<StringArray> ng = new TreeSet<StringArray>();
    boolean ok(StringArray sa){
        //System.out.printf("ok(%s)\n", s);
        if(ng.contains(sa))
            return false;
        int cs = sa.ar.length;
        if(cs == 1)return true;
        char num = sa.ar[0].charAt(0);
        char suit = sa.ar[0].charAt(1);
        if(num == sa.ar[1].charAt(0) || suit == sa.ar[1].charAt(1)){
            StringArray next = new StringArray(cs-1);
            next.ar[0] = sa.ar[0];
            for(int i = 2; i < cs; i++)
                next.ar[i-1] = sa.ar[i];
            if(ok(next))
                return true;
        }
        if(cs >= 4 && (num == sa.ar[3].charAt(0) || suit == sa.ar[3].charAt(1))){
            StringArray next = new StringArray(cs-1);
            next.ar[0] = sa.ar[1];
            next.ar[1] = sa.ar[2];
            next.ar[2] = sa.ar[0];
            for(int i = 4; i < cs; i++)
                next.ar[i-1] = sa.ar[i];
            if(ok(next))
                return true;
        }
        ng.add(sa);
        return false;
    }

    void run() throws Exception{
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        cards = new String[n];
        for(int i = 0; i < n; i++)
            cards[i] = sc.next();
        StringArray sa = new StringArray(n);
        for(int i = n-1; i >= 0; i--)
            sa.ar[n-i-1] = cards[i];
        System.out.println(ok(sa) ? "YES" : "NO");
    }
}

class StringArray implements Comparable<StringArray>{
    String[] ar;
    StringArray(int n){
        ar = new String[n];
    }
    @Override public int hashCode(){
        return 0;
    }
    @Override public boolean equals(Object o){
        StringArray sa = (StringArray) o;
        if(ar.length != sa.ar.length)
            return false;
        for(int i = 0; i < ar.length; i++)
            if(!ar[i].equals(sa.ar[i]))
                return false;
        return true;
    }
    @Override public int compareTo(StringArray sa){
        if(ar.length != sa.ar.length)
            return ar.length - sa.ar.length;
        for(int i = 0; i < ar.length; i++)
            if(ar[i].compareTo(sa.ar[i]) != 0)
                return ar[i].compareTo(sa.ar[i]);
        return 0;
    }
}

import java.util.*;
import java.io.*;
import static java.lang.Math.*;

public class B{
    public static void main(String[] args) throws Exception{
        new B().run();
    }

    int n;
    String[] cards;
    TreeSet<String> ng = new TreeSet<String>();
    boolean ok(String s){
        //System.out.printf("ok(%s)\n", s);
        if(ng.contains(s))
            return false;
        int len = s.length();
        int cs = len / 2;
        if(cs == 1)return true;
        char num = s.charAt(0);
        char suit = s.charAt(1);
        if(num == s.charAt(2) || suit == s.charAt(3)){
            if(ok(s.substring(0,2) + s.substring(4)))
                return true;
        }
        if(cs >= 4 && (num == s.charAt(6) || suit == s.charAt(7))){
            if(ok(s.substring(2, 6) + s.substring(0,2) + s.substring(8)))
                return true;
        }
        ng.add(s);
        return false;
    }

    void run() throws Exception{
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        cards = new String[n];
        for(int i = 0; i < n; i++)
            cards[i] = sc.next();
        StringBuilder sb = new StringBuilder();
        for(int i = n-1; i >= 0; i--)
            sb.append(cards[i]);
        System.out.println(ok(sb.toString()) ? "YES" : "NO");
    }
}

import java.util.*;
import java.io.*;
import static java.lang.Math.*;

public class B{
    public static void main(String[] args) throws Exception{
        new B().run();
    }

    int n;
    String[] cards;
    //TreeSet<String> ng = new TreeSet<String>();
    HashSet<String> ng = new HashSet<String>();
    boolean ok(String s){
        //System.out.printf("ok(%s)\n", s);
        if(ng.contains(s))
            return false;
        int len = s.length();
        int cs = len / 2;
        if(cs == 1)return true;
        char num = s.charAt(0);
        char suit = s.charAt(1);
        if(num == s.charAt(2) || suit == s.charAt(3)){
            if(ok(s.substring(0,2) + s.substring(4)))
                return true;
        }
        if(cs >= 4 && (num == s.charAt(6) || suit == s.charAt(7))){
            if(ok(s.substring(2, 6) + s.substring(0,2) + s.substring(8)))
                return true;
        }
        ng.add(s);
        return false;
    }

    void run() throws Exception{
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        cards = new String[n];
        for(int i = 0; i < n; i++)
            cards[i] = sc.next();
        StringBuilder sb = new StringBuilder();
        for(int i = n-1; i >= 0; i--)
            sb.append(cards[i]);
        System.out.println(ok(sb.toString()) ? "YES" : "NO");
    }
}

import java.util.*;
import java.io.*;
import static java.lang.Math.*;

public class B{
    public static void main(String[] args) throws Exception{
        new B().run();
    }

    int n;
    String[] cards;
    Set<StringArray> ng = new HashSet<StringArray>();
    boolean ok(StringArray sa){
        //System.out.printf("ok(%s)\n", s);
        if(ng.contains(sa))
            return false;
        int cs = sa.ar.length;
        if(cs == 1)return true;
        char num = sa.ar[0].charAt(0);
        char suit = sa.ar[0].charAt(1);
        if(num == sa.ar[1].charAt(0) || suit == sa.ar[1].charAt(1)){
            StringArray next = new StringArray(cs-1);
            next.ar[0] = sa.ar[0];
            for(int i = 2; i < cs; i++)
                next.ar[i-1] = sa.ar[i];
            if(ok(next))
                return true;
        }
        if(cs >= 4 && (num == sa.ar[3].charAt(0) || suit == sa.ar[3].charAt(1))){
            StringArray next = new StringArray(cs-1);
            next.ar[0] = sa.ar[1];
            next.ar[1] = sa.ar[2];
            next.ar[2] = sa.ar[0];
            for(int i = 4; i < cs; i++)
                next.ar[i-1] = sa.ar[i];
            if(ok(next))
                return true;
        }
        ng.add(sa);
        return false;
    }

    void run() throws Exception{
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        cards = new String[n];
        for(int i = 0; i < n; i++)
            cards[i] = sc.next();
        StringArray sa = new StringArray(n);
        for(int i = n-1; i >= 0; i--)
            sa.ar[n-i-1] = cards[i];
        System.out.println(ok(sa) ? "YES" : "NO");
    }
}

class StringArray{
    String[] ar;
    StringArray(int n){
        ar = new String[n];
    }
    @Override public int hashCode(){
        return 0;
    }
    @Override public boolean equals(Object o){
        StringArray sa = (StringArray) o;
        if(ar.length != sa.ar.length)
            return false;
        for(int i = 0; i < ar.length; i++)
            if(!ar[i].equals(sa.ar[i]))
                return false;
        return true;
    }
}

import java.io.*;
import java.util.*;

public class R130_D2_B {
    static HashMap<String, Integer> map = new HashMap<String, Integer>();

    static String[] q;
    static int DP[][][][];

    public static int call(int index, String val1, String val2, String val3) {
        if (index == 0)
            return 1;
        int v1 = map.containsKey(val1) ? map.get(val1) : 54;
        int v2 = map.containsKey(val2) ? map.get(val2) : 54;
        int v3 = map.containsKey(val3) ? map.get(val3) : 54;
        //System.out.println(v1 + " " + v2 + " " + v3);
        if (DP[index][v1][v2][v3] != -1)
            return DP[index][v1][v2][v3];
        int can = 0;
        String val4 = "";
        if (index >= 3) {
            val4 = q[index - 3];
            if (val1.charAt(0) == val4.charAt(0)
                    || val1.charAt(1) == val4.charAt(1))
                can = call(index - 1, val2, val3, val1);
        }
        if (can == 1)
            return DP[index][v1][v2][v3] = 1;
        else {
            if (val1.charAt(0) == val2.charAt(0)
                    || val1.charAt(1) == val2.charAt(1))
                return DP[index][v1][v2][v3] = call(index - 1, val1, val3, val4);
        }
        return DP[index][v1][v2][v3] = 0;
    }

    public static void main(String[] args) throws Exception {
        InputReader in = new InputReader(System.in);
        int n = in.readInt();
        q = new String[n];
        for (int i = 0; i < n; i++) {
            q[i] = in.readString();
        }
        String[] pp = { "2", "3", "4", "5", "6", "7", "8", "9", "T", "J", "Q",
                "K", "A" };
        String[] cc = { "S", "D", "H", "C" };
        int value = 0;
        for (int i = 0; i < pp.length; i++) {
            for (int j = 0; j < cc.length; j++) {
                map.put(pp[i] + cc[j], value++);
            }
        }

        DP = new int[55][55][55][55];
        for (int i = 0; i < 55; i++) {
            for (int j = 0; j < 55; j++) {
                for (int j2 = 0; j2 < 55; j2++) {
                    for (int k = 0; k < 55; k++) {
                        DP[i][j][j2][k] = -1;
                    }
                }
            }
        }
        String val1 = n >= 2 ? q[n - 2] : "";
        String val2 = n >= 3 ? q[n - 3] : "";
        if (call(n - 1, q[n - 1], val1, val2) == 1)
            System.out.println("YES");
        else
            System.out.println("NO");

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1000];
        private int curChar, numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        private int read() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int readInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public long readLong() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public String readString() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuffer res = new StringBuffer();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        private String readLine0() {
            StringBuffer buf = new StringBuffer();
            int c = read();
            while (c != '\n' && c != -1) {
                buf.appendCodePoint(c);
                c = read();
            }
            return buf.toString();
        }

        public String readLine() {
            String s = readLine0();
            while (s.trim().length() == 0)
                s = readLine0();
            return s;
        }

        public String readLine(boolean ignoreEmptyLines) {
            if (ignoreEmptyLines)
                return readLine();
            else
                return readLine0();
        }

        public char readCharacter() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            return (char) c;
        }

        public double readDouble() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            double res = 0;
            while (!isSpaceChar(c) && c != '.') {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, readInt());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            if (c == '.') {
                c = read();
                double m = 1;
                while (!isSpaceChar(c)) {
                    if (c == 'e' || c == 'E')
                        return res * Math.pow(10, readInt());
                    if (c < '0' || c > '9')
                        throw new InputMismatchException();
                    m /= 10;
                    res += (c - '0') * m;
                    c = read();
                }
            }
            return res * sgn;
        }
    }
}

import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.util.Map.Entry;

public class Main {
	public static void main(String[] args) throws IOException {
		(new Main()).solve();
	}

	public void Main() {
	}

	int n;
	int[] v;
	int[][][][] h;

	void solve() throws IOException {
		// BufferedReader in = new BufferedReader(new
		// InputStreamReader(System.in));
		 Scanner in = new Scanner(System.in);
		//MyReader in = new MyReader();
		PrintWriter out = new PrintWriter(System.out);
		// Scanner in = new Scanner(new FileReader("input.txt"));
		// PrintWriter out = new PrintWriter("output.txt");
		n = in.nextInt();
		v = new int[n];
		h = new int[n + 1][52][52][52];
		for (int i = 0; i < n; i++) {
			String s = in.next();
			int a = 0, b = 0;
			switch (s.charAt(0)) {
				case '2': a = 0; break;
				case '3': a = 1; break;
				case '4': a = 2; break;
				case '5': a = 3; break;
				case '6': a = 4; break;
				case '7': a = 5; break;
				case '8': a = 6; break;
				case '9': a = 7; break;
				case 'T': a = 8; break;
				case 'J': a = 9; break;
				case 'Q': a = 10; break;
				case 'K': a = 11; break;
				case 'A': a = 12; break;
				default: break;
			}
			switch (s.charAt(1)) {
				case 'S': b = 0; break;
				case 'D': b = 1; break;
				case 'H': b = 2; break;
				case 'C': b = 3; break;
				default: break;
			}
			v[i] = a * 4 + b;
		}

		boolean result;
		if (n == 1) {
			result = true;
		} else if (n == 2) {
			result = canMove(v[0], v[1]);
		} else {
			result = check(n, v[n - 3], v[n - 2], v[n-1]);
		}

		out.print(result ? "YES" : "NO");

		out.close();
	}

	boolean check(int k, int a, int b, int c) {
		if (h[k][a][b][c] == 0) {
			if (k == 3) {
				return (canMove(a, c) && canMove(b, c));
			}
			if (canMove(c, b) && check(k - 1, v[k - 4], a, c)||canMove(v[k - 4], c) && check(k - 1, c, a, b)) {
				h[k][a][b][c] = 1;
				return true;
			}
			h[k][a][b][c] = -1;
			return false;
		} else {
			return (h[k][a][b][c] == 1);
		}
	}

	boolean canMove(int a, int b) {
		return (a % 4 == b % 4 || a / 4 == b / 4);
	}
};

class MyReader {
	private BufferedReader in;
	String[] parsed;
	int index = 0;

	public MyReader() {
		in = new BufferedReader(new InputStreamReader(System.in));
	}

	public int nextInt() throws NumberFormatException, IOException {
		if (parsed == null || parsed.length == index) {
			read();
		}
		return Integer.parseInt(parsed[index++]);
	}

	public long nextLong() throws NumberFormatException, IOException {
		if (parsed == null || parsed.length == index) {
			read();
		}
		return Long.parseLong(parsed[index++]);
	}

	public String nextString() throws IOException {
		if (parsed == null || parsed.length == index) {
			read();
		}
		return parsed[index++];
	}

	private void read() throws IOException {
		parsed = in.readLine().split(" ");
		index = 0;
	}

	public String readLine() throws IOException {
		return in.readLine();
	}
};

import java.util.*;
import java.io.*;

public class Main {
    public static void main(String arg[])
    {
        new Main();
    }
    private TreeMap<State,Boolean> f;
    private class State implements Comparable<State>
    {
        private int x;
        String last_three_cards[];
        public State(String cards[],int x)
        {
            this.last_three_cards=new String[3];
            for (int i=0;i<3;i++)
            {
                if (x-3+i>=0) this.last_three_cards[i]=cards[x-3+i];
                else this.last_three_cards[i]=null;
            }
            this.x=x;
        }
        public String toString()
        {
            String s=new String();
            s+=x;
            for (int i=0;i<3;i++)
            {
                if (last_three_cards[i]!=null)
                    s+=last_three_cards[i];
            }
            return s;
        }
        public int compareTo(State other)
        {
            return toString().compareTo(other.toString());
        }
    }
    private boolean dfs(String cards[],int x)
    {
        State s=new State(cards,x);
        if (f.get(s)==null)
        {
            if (x>=4)
            {
                if (cards[x-1].charAt(0)==cards[x-4].charAt(0)||cards[x-1].charAt(1)==cards[x-4].charAt(1))
                {
                    String backup=cards[x-4];
                    cards[x-4]=cards[x-1];
                    if (dfs(cards,x-1)) f.put(s,true);
                    cards[x-4]=backup;
                }
                if (cards[x-1].charAt(0)==cards[x-2].charAt(0)||cards[x-1].charAt(1)==cards[x-2].charAt(1))
                {
                    String backup=cards[x-2];
                    cards[x-2]=cards[x-1];
                    if (dfs(cards,x-1)) f.put(s,true);
                    cards[x-2]=backup;
                }
                if (f.get(s)==null) f.put(s,false);
            }
            else if (x>=2)
            {
                if (cards[x-1].charAt(0)==cards[x-2].charAt(0)||cards[x-1].charAt(1)==cards[x-2].charAt(1))
                {
                    String backup=cards[x-2];
                    cards[x-2]=cards[x-1];
                    if (dfs(cards,x-1)) f.put(s,true);
                    cards[x-2]=backup;
                }
                if (f.get(s)==null) f.put(s,false);
            }
            else f.put(s,true);
        }
        //System.out.println(s.toString()+":"+f.get(s));
        return f.get(s);
    }
    public Main()
    {
        Scanner cin=new Scanner(new BufferedInputStream(System.in));
        int x=cin.nextInt();
        String cards[]=new String[x];
        for (int i=0;i<x;i++)
            cards[i]=cin.next();
        f=new TreeMap<State,Boolean>();
        System.out.println(dfs(cards,x)?"YES":"NO");
        cin.close();
    }
}

import java.io.InputStreamReader;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.util.HashSet;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Lokesh Khandelwal aka (codeKNIGHT | phantom11)
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskB solver = new TaskB();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskB {
    boolean status=false;
    String a[];
    HashSet<String> memo=new HashSet<String>();
	public void solve(int testNumber, InputReader in, PrintWriter out) {
        int n=in.nextInt();
        int i;
        a=new String[n];
        for(i=0;i<n;i++)
            a[i]=in.next();
        if(n==1)
        {
            out.println("YES");
            return;
        }
        if(n==2)
        {
            if(compatible(a[0],a[1]))
                out.println("YES");
            else out.println("NO");
            return;
        }
        recur(n,a[n-3],a[n-2],a[n-1]);
        if(status)
            out.println("YES");
        else out.println("NO");
    }
    public void recur(int n,String x,String y,String z)
    {
        String k=n+" "+x+y+z;
        if(memo.contains(k))
            return;
        memo.add(k);
        if(n==3)
        {
            status|=compatible(z,y)&&compatible(z,x);
            return;
        }
        if(!status&&compatible(a[n-4],z))
            recur(n-1,z,x,y);
        if(!status&&compatible(y,z))
            recur(n-1,a[n-4],x,z);
    }
    public boolean compatible(String x,String y)
    {
        return (x.charAt(0)==y.charAt(0)||x.charAt(1)==y.charAt(1));
    }
}

class InputReader
{
    BufferedReader in;
    StringTokenizer tokenizer=null;

    public InputReader(InputStream inputStream)
    {
        in=new BufferedReader(new InputStreamReader(inputStream));
    }
    public String next()
    {
        try{
            while (tokenizer==null||!tokenizer.hasMoreTokens())
            {
                tokenizer=new StringTokenizer(in.readLine());
            }
            return tokenizer.nextToken();
        }
        catch (IOException e)
        {
            return null;
        }
    }
    public int nextInt()
    {
        return Integer.parseInt(next());
    }
    }

import java.io.DataInputStream;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.TreeSet;

public class Solitaire {
	static TreeSet<String> dp ;
	static SL a;
	public static void main(String [] args) throws Exception{
		FS in = new FS(System.in);
		int n = in.nextInt();
		a = new SL();
		dp = new TreeSet<>();
		for(int i = 0 ; i < n ; i++){
			a.add(in.nextString());
		}
		try {
			DFS();
			System.out.println("NO");
		} catch (Exception e) {
			System.out.println("YES");
		}

	}
	static boolean DFS() throws Exception{
		int n = a.size();
		if(n==1){
			throw new ArithmeticException();
		}
		String s = a.toString();
		if(dp.contains(s)){
			return false;
		}
		String x1 ="";
		String x3 ="";
		try{
			x1 = a.get(n-2);
			x3 = a.get(n-4);
		} catch (Exception e) {	}

		for(int i = n-1 ; i < n ; i++){
			if(i!=n-4 && i != n-2){
				String t = a.get(i);
				if(t.charAt(0)==x1.charAt(0) || t.charAt(1)==x1.charAt(1)){
					a.remove(n-2);
					a.add(n-2 , t);
					a.remove(i);
					DFS();
					a.add(i,t);
					a.remove(n-2);
					a.add(n-2,x1);
				}
				if(x3!=""){
					if(t.charAt(0)==x3.charAt(0) || t.charAt(1)==x3.charAt(1)){
						a.remove(n-4);
						a.add(n-4 , t);
						a.remove(i);
						DFS();
						a.add(i,t);
						a.remove(n-4);
						a.add(n-4,x3);
					}
				}
			}
		}
		dp.add(a.toString());
		return false;
	}
}
class SL extends ArrayList<String>{
	@Override
	public String toString() {
		String out = "";
		for(String s : this){
			out+=s+" ";
		}
		return out;
	}
}
class FS
{
   final private int BUFFER_SIZE = 1 << 17;

   private DataInputStream din;
   private byte[] buffer;
   private int bufferPointer, bytesRead;

   public FS(InputStream in)
   {
      din = new DataInputStream(in);
      buffer = new byte[BUFFER_SIZE];
      bufferPointer = bytesRead = 0;
   }
   public String nextString() throws Exception
   {
       StringBuffer sb=new StringBuffer("");
       byte c = read();
       while (c <= ' ') c = read();
       do
       {
           sb.append((char)c);
           c=read();
       }while(c>' ');
       return sb.toString();
   }
   public char nextChar() throws Exception
   {
       byte c=read();
       while(c<=' ') c= read();
       return (char)c;
   }
   public int nextInt() throws Exception
   {
      int ret = 0;
      byte c = read();
      while (c <= ' ') c = read();
      boolean neg = c == '-';
      if (neg) c = read();
      do
      {
          ret = ret * 10 + c - '0';
         c = read();
      } while (c > ' ');
      if (neg) return -ret;
      return ret;
   }
   public long nextLong() throws Exception
   {
      long ret = 0;
      byte c = read();
      while (c <= ' ') c = read();
      boolean neg = c == '-';
      if (neg) c = read();
      do
      {
          ret = ret * 10 + c - '0';
         c = read();
      } while (c > ' ');
      if (neg) return -ret;
      return ret;
   }
   private void fillBuffer() throws Exception
   {
      bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
      if (bytesRead == -1) buffer[0] = -1;
   }

   private byte read() throws Exception
   {
      if (bufferPointer == bytesRead) fillBuffer();
      return buffer[bufferPointer++];
   }
}

import java.util.*;

public class T208B {
	public static Set<String> mem;

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n_cards = in.nextInt();
		String cards = "";
		for (int i = 0; i < n_cards; ++i) cards += in.next();
		mem = new TreeSet<String>();
		if (recurse(cards, n_cards * 2)) System.out.println("YES");
		else System.out.println("NO");
	}

	public static boolean recurse(String s, int n) {
		if (n == 2) return true;
		if (mem.contains(s)) return false;
		mem.add(s);

		if (n >= 4)
			if (s.charAt(n - 2) == s.charAt(n - 4) || s.charAt(n - 1) == s.charAt(n - 3)) {
				String nx = s.substring(0, n - 4) + s.substring(n - 2);
				if (recurse(nx, n - 2)) return true;
			}
		if (n >= 8)
			if (s.charAt(n - 2) == s.charAt(n - 8) || s.charAt(n - 1) == s.charAt(n - 7)) {
				String nx = s.substring(0, n - 8) + s.substring(n - 2) + s.substring(n - 6, n - 2);
				if (recurse(nx, n - 2)) return true;
			}

		return false;
	}
}

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class cf208b {
  static int n;
  static int[] v;
  static Boolean[][][][] memo = new Boolean[60][60][60][60];
  public static void main(String[] args) {
    FastIO in = new FastIO(), out = in;
    n = in.nextInt();
    v = new int[n];
    for(int i=0; i<n; i++)
      v[i] = encode(in.next().trim());
    boolean ans = go(n-1, Math.max(n-3, -1), Math.max(n-2,-1), Math.max(n-1,-1));
    out.println(ans?"YES":"NO");
    out.close();
  }
  static boolean go(int pos, int a, int b, int c) {
    if(pos == 0) return true;
    if(memo[pos][a+1][b+1][c+1] != null) return memo[pos][a+1][b+1][c+1];
    boolean ret = false;
    if(compatible(c,b))
      ret |= go(pos-1, Math.max(pos-3,-1), a, c);
    if(compatible(c,pos-3))
      ret |= go(pos-1, c, a, b);
    return memo[pos][a+1][b+1][c+1] = ret;
  }
  static boolean compatible(int x, int y) {
    if(x < 0 || y < 0) return false;
    if(v[x]%13 == v[y]%13) return true;
    if(v[x]/13 == v[y]/13) return true;
    return false;
  }
  static String suits = "SDHC", vals = "23456789TJQKA";
  static int encode(String s) {
    return suits.indexOf(s.charAt(1))*13 + vals.indexOf(s.charAt(0));
  }
  static class FastIO extends PrintWriter {
    BufferedReader br;
    StringTokenizer st;

    public FastIO() {
      this(System.in,System.out);
    }
    public FastIO(InputStream in, OutputStream out) {
      super(new BufferedWriter(new OutputStreamWriter(out)));
      br = new BufferedReader(new InputStreamReader(in));
      scanLine();
    }
    public void scanLine() {
      try {
        st = new StringTokenizer(br.readLine().trim());
      } catch(Exception e) {
        throw new RuntimeException(e.getMessage());
      }
    }
    public int numTokens() {
      if(!st.hasMoreTokens()) {
        scanLine();
        return numTokens();
      }
      return st.countTokens();
    }
    public String next() {
      if(!st.hasMoreTokens()) {
        scanLine();
        return next();
      }
      return st.nextToken();
    }
    public double nextDouble() {
      return Double.parseDouble(next());
    }
    public long nextLong() {
      return Long.parseLong(next());
    }
    public int nextInt() {
      return Integer.parseInt(next());
    }
  }
}

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Locale;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

public class Solution implements Runnable {

	BufferedReader in;
	PrintWriter out;
	StringTokenizer st;

	String nextToken() throws Exception {
		while (st == null || !st.hasMoreTokens()) {
			st = new StringTokenizer(in.readLine());
		}
		return st.nextToken();
	}

	int nextInt() throws Exception {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws Exception {
		return Long.parseLong(nextToken());
	}

	int[] a;
	HashMap<Long, Boolean> map;

	boolean match(int a, int b) {
		return a % 256 == b % 256 || a / 256 == b / 256;
	}

	boolean rek(int n, int a3, int a2, int a1) {
		long code = n * (1l << 48) + a1 * (1l << 32) + a2 * (1l << 16) + a3;
		if (map.containsKey(code)) return map.get(code);
		if (n == 3) {
			return match(a1, a3) && match(a1, a2);
		}
		boolean ans = false;
		if (match(a1, a2)) {
			ans |= rek(n - 1, a[n - 4], a3, a1);
		}
		if (match(a1, a[n - 4])) {
			ans |= rek(n - 1, a1, a3, a2);
		}
		map.put(n * (1l << 48) + a1 * (1l << 32) + a2 * (1l << 16) + a3, ans);
		return ans;
	}

	void solve() throws Exception {
		map = new HashMap<Long, Boolean>();
		int n = nextInt();
		a = new int[n];
		for (int i = 0; i < n; i++) {
			String s = nextToken();
			a[i] = (s.charAt(0) % 256) * 256 + (s.charAt(1) % 256);
		}
		if (n < 3) {
			boolean ans = true;
			for (int i = 0; i < n - 1; i++) ans &= match(a[i], a[n - 1]);
			if (ans) out.println("YES"); else out.println("NO");
		} else {
			if (rek(n, a[n - 3], a[n - 2], a[n - 1])) out.println("YES"); else out.println("NO");
		}
	}

	public void run() {
		try {
			Locale.setDefault(Locale.UK);
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			solve();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		} finally {
			out.close();
		}
	}

	public static void main(String[] args) {
		new Thread(null, new Solution(), "1", 1 << 28).start();
	}

}

import java.io.*;
import java.math.BigInteger;
import java.util.HashMap;
import java.util.InputMismatchException;

public class Main {
	public static void main(String[] args) {
		long time_beg = -1;
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		if (args.length > 0 && args[0].equals("outside")) {
			time_beg = System.currentTimeMillis();
			try {
				inputStream = new FileInputStream("io/in.txt");
//				outputStream = new FileOutputStream("io/out.txt");
			} catch (Exception e) {
				System.err.println(e);
				System.exit(1);
			}
		} else {
//			try {
//				inputStream = new FileInputStream("file_name");
//				outputStream = new FileOutputStream("file_name");
//			} catch (Exception e) {
//				System.err.println(e);
//				System.exit(1);
//			}
		}
		Solver s = new Solver();
		s.in = new InputReader(inputStream);
		s.out = new OutputWriter(outputStream);
		s.solve();
		s.out.close();
		if (args.length > 0 && args[0].equals("outside")) {
			System.err.printf("*** Total time: %.3f ***\n", (System.currentTimeMillis() - time_beg) / 1000.0);
		}
	}
}

class OutputWriter {
	private final PrintWriter writer;

	public OutputWriter(OutputStream outputStream) {
		writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
	}

	public OutputWriter(Writer writer) {
		this.writer = new PrintWriter(writer);
	}

	public void print(Object... objects) {
		for (int i = 0; i < objects.length; i++) {
			if (i != 0)
				writer.print(' ');
			writer.print(objects[i]);
		}
	}

	public void printLine(Object... objects) {
		print(objects);
		writer.println();
	}

	public void printLine(char[] array) {
		writer.println(array);
	}

	public void printFormat(String format, Object... objects) {
		writer.printf(format, objects);
	}

	public void close() {
		writer.close();
	}

	public void flush() {
		writer.flush();
	}
}

class InputReader {
	private boolean finished = false;

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	private int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int peek() {
		if (numChars == -1)
			return -1;
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				return -1;
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar];
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public long readLong() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public static boolean isSpaceChar(int c) {
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	private String readLine0() {
		StringBuilder buf = new StringBuilder();
		int c = read();
		while (c != '\n' && c != -1) {
			if (c != '\r')
				buf.appendCodePoint(c);
			c = read();
		}
		return buf.toString();
	}

	public String readLine() {
		String s = readLine0();
		while (s.trim().length() == 0)
			s = readLine0();
		return s;
	}

	public String readLine(boolean ignoreEmptyLines) {
		if (ignoreEmptyLines)
			return readLine();
		else
			return readLine0();
	}

	public BigInteger readBigInteger() {
		try {
			return new BigInteger(readString());
		} catch (NumberFormatException e) {
			throw new InputMismatchException();
		}
	}

	public char readCharacter() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		return (char) c;
	}

	public double readDouble() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		double res = 0;
		while (!isSpaceChar(c) && c != '.') {
			if (c == 'e' || c == 'E')
				return res * Math.pow(10, readInt());
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		}
		if (c == '.') {
			c = read();
			double m = 1;
			while (!isSpaceChar(c)) {
				if (c == 'e' || c == 'E')
					return res * Math.pow(10, readInt());
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				m /= 10;
				res += (c - '0') * m;
				c = read();
			}
		}
		return res * sgn;
	}

	public boolean isExhausted() {
		int value;
		while (isSpaceChar(value = peek()) && value != -1)
			read();
		return value == -1;
	}
}

class Solver {
	InputReader in;
	OutputWriter out;

	void solve() {
		dp = new int[64][64][64][64];
		fill(dp, -1);

		char[] a = {'2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A'};
		char[] b = {'S', 'D', 'H', 'C'};
		MAP = new HashMap<>();
		RMAP = new HashMap<>();
		for (int j = 0; j < a.length; ++j)
			for (int i = 0; i < b.length; ++i) {
				String s = String.valueOf(a[j]) + String.valueOf(b[i]);
				MAP.put(s, j * b.length + i);
				RMAP.put(j * b.length + i, s);
			}

		int n = in.readInt();
		mas = new int[n];
		for (int i = 0; i < n; ++i)
			mas[i] = MAP.get(in.readString());

		if (mas.length < 3) {
			if (mas.length == 1) out.printLine("YES");
			else {
				if (RMAP.get(mas[0]).charAt(0) == RMAP.get(mas[1]).charAt(0)
						|| RMAP.get(mas[0]).charAt(1) == RMAP.get(mas[1]).charAt(1))
					out.printLine("YES");
				else out.printLine("NO");
			}
			return;
		}

		if (rec(n - 1, mas[n - 3], mas[n - 2], mas[n - 1]) == 1) out.printLine("YES");
		else out.printLine("NO");
	}

	HashMap<String, Integer> MAP;
	HashMap<Integer, String> RMAP;
	int[] mas;

	int rec(int pos, int v1, int v2, int v3) {
		if (dp[pos][v1][v2][v3] != -1) return dp[pos][v1][v2][v3];
		if (pos == 0) return dp[pos][v1][v2][v3] = 1;

		String s1 = RMAP.get(v3);
		// -1
		String s2 = RMAP.get(v2);
		if (s1.charAt(0) == s2.charAt(0) || s1.charAt(1) == s2.charAt(1)) {
			int nv1 = v1;
			if (pos >= 3) nv1 = mas[pos - 3];
			int nv2 = v1;
			int nv3 = v3;
			if (rec(pos - 1, nv1, nv2, nv3) == 1)
				return dp[pos][v1][v2][v3] = 1;
		}

		// -3
		if (pos >= 3) {
			s2 = RMAP.get(mas[pos - 3]);
			if (s1.charAt(0) == s2.charAt(0) || s1.charAt(1) == s2.charAt(1)) {
				int nv1 = v3;
				int nv2 = v1;
				int nv3 = v2;
				if (rec(pos - 1, nv1, nv2, nv3) == 1)
					return dp[pos][v1][v2][v3] = 1;
			}
		}

		return dp[pos][v1][v2][v3] = 0;
	}

	int[][][][] dp;

	public static void fill(int[] array, int value) {
		for (int i = 0; i < array.length; ++i)
			array[i] = value;
	}

	public static void fill(int[][] array, int value) {
		for (int i = 0; i < array.length; ++i)
			fill(array[i], value);
	}

	public static void fill(int[][][] array, int value) {
		for (int i = 0; i < array.length; ++i)
			fill(array[i], value);
	}

	public static void fill(int[][][][] array, int value) {
		for (int i = 0; i < array.length; ++i)
			fill(array[i], value);
	}
}

import java.util.*;
import java.io.*;
public class program
{

    static class Card
    {
        String number="";
        String suit="";
        Card(char a, char b)
        {
            number=number+a;
            suit=suit+ b;
        }
    }
    HashMap<ArrayList<Card> , Boolean> map= new HashMap<>();
boolean solve(ArrayList<Card> list, int size)
{
    if(size==1)
    {
        return true;
    }
    if(map.get(list)!=null)
    {
        return map.get(list);
    }

    Card second;
if(size-3>=1)
{
     second=list.get(size-3-1);
}
else
{
    second=null;
}
boolean mmf=false;
boolean mms=false;
Card first=list.get(size-1-1);
Card current=list.get(size-1);
if(current.number.equals(first.number)||current.suit.equals(first.suit))
{
    list.remove(size-1-1);
   mmf= solve(list,size-1);
    list.add(size-1-1,first);
}
if(second!=null)
{
    if(second.number.equals(current.number)||second.suit.equals(current.suit))
    {
        list.remove(size-1-3);
        list.add(size-1-3,current);
        list.remove(size-1);
       mms= solve(list,size-1);
       list.add(size-1,current);
       list.remove(size-1-3);
       list.add(size-1-3,second);

    }

}

map.put(list,mmf||mms);
return mmf||mms;

}

    public static void main(String[] args)throws IOException {
        BufferedReader ab=new BufferedReader(new InputStreamReader(System.in));
        int n=Integer.parseInt(ab.readLine());
        String temp[]=ab.readLine().split(" ");
        ArrayList<Card> card=new ArrayList<>();
        for(int i=0;i<n;i++)
        {
         Card c=new Card(temp[i].charAt(0), temp[i].charAt(1));
         card.add(c);
        }
        program p=new program();
      if (  p.solve(card, card.size()))
      {
          System.out.println("YES");
      }
      else
      {
          System.out.println("NO");
      }

    }

}

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.StringTokenizer;

public class B208{
	static final boolean FILE_IO = false;
	static final String output_file = "output.txt";
	static final String input_file = "input.txt";

	public static void main(String[] args){
		InputReader in = new InputReader();
		PrintWriter out;
		if(FILE_IO){
			try{
				out = new PrintWriter(output_file);
			} catch(FileNotFoundException e){
				throw new RuntimeException(e);
			}
		} else {
			out = new PrintWriter(System.out);
		}
		final long start = System.currentTimeMillis();
		new Task1().solve(in, out);
		final long duration = System.currentTimeMillis()-start;
		out.close();
	}

	static class Task1{
		static boolean answer=false;
		HashMap<Marker, Boolean> visited;

		static class Marker{
			String last, preLast, prepreLast, preprepreLast;
			Integer size, hash;

			public Marker(int size, String last, String preLast, String prepreLast, String preprepreLast){
				this.size=size;
				this.last=last;
				this.preLast=preLast;
				this.prepreLast=prepreLast;
				this.preprepreLast=preprepreLast;
			}

			public int hashCode(){
				if(hash!=null) return hash;
				hash = size;
				hash = hash*31 + last.hashCode();
				hash = hash*31 + preLast.hashCode();
				hash = hash*31 + prepreLast.hashCode();
				hash = hash*31 + preprepreLast.hashCode();
				return hash;
			}

			public boolean equals(Object temp){
				Marker o = (Marker)temp;
				return(
						size.equals(o.size) &&
						last.equals(o.last) &&
						preLast.equals(o.preLast) &&
						prepreLast.equals(o.prepreLast)
					);
			}
		}

		public void solve(InputReader in, PrintWriter out){
			int n=in.nextInt();
			ArrayList<String> deck = new ArrayList<String>();

			for(int i=0; i<n; i++){
				deck.add(in.next());
			}

			visited = new HashMap<Marker, Boolean>();
			solve(deck);
			if(answer){
				out.println("YES");
			} else {
				out.println("NO");
			}
		}

		boolean match(String a, String b){
			return (a.charAt(0)==b.charAt(0) || a.charAt(1)==b.charAt(1));
		}

		void solve(ArrayList<String> deck){
			int n=deck.size();
			if(n==1 || answer){
				answer=true;
				return;
			}

			if(n>3){
				String last = deck.get(n-1);
				String _preLast = deck.get(n-2);
				String _prepreLast = deck.get(n-3);
				String _preprepreLast = deck.get(n-4);
				Marker mm = new Marker(n, last, _preLast, _prepreLast, _preprepreLast);

				if(visited.containsKey(mm)){
					//System.out.println(n+" "+_preprepreLast+" "+_prepreLast+" "+_preLast+" "+last);
					return;
				}
				visited.put(mm, true);
			}

			if(n>1 && match(deck.get(n-2), deck.get(n-1))){
				ArrayList<String> copy1 = new ArrayList<String>(deck);
				copy1.set(n-2, deck.get(n-1));
				copy1.remove(n-1);
				solve(copy1);
			}

			if(n>3 && match(deck.get(n-4),deck.get(n-1)) ){
				ArrayList<String> copy3 = new ArrayList<String>(deck);
				copy3.set(n-4, deck.get(n-1));
				copy3.remove(n-1);
				solve(copy3);
			}
		}
	}

	static class InputReader{
		private BufferedReader reader;
		private StringTokenizer tokenizer;

		public InputReader(){
			if(FILE_IO){
				try{
					reader = new BufferedReader(new FileReader(input_file));
				} catch(FileNotFoundException e){
					throw new RuntimeException(e);
				}
			} else {
				reader = new BufferedReader(new InputStreamReader(System.in));
			}
			tokenizer = null;
		}

		public String next(){
			while(tokenizer==null || !tokenizer.hasMoreTokens()){
				try{
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e){
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public int nextInt(){
			return (int)Integer.parseInt(next());
		}

		public long nextLong(){
			return (long)Long.parseLong(next());
		}

		public double nextDouble(){
			return (double)Double.parseDouble(next());
		}

		public String nextLine(){
			String s = null;
			try{
				s = reader.readLine();
			} catch(Exception e){
				throw new RuntimeException(e);
			}
			return s;
		}
	}
}

import java.io.*;
import java.util.*;
import java.math.*;

public class Main {
    static boolean find = false;
    static TreeSet<Integer> set = new TreeSet<>();
    public static void main(String[] args) throws Exception {
        PrintWriter out = new PrintWriter(System.out,true);
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(in.readLine());
        String[] mas = new String[n];
        StringTokenizer st = new StringTokenizer(in.readLine());
        for(int i = 0;i < n;i++) mas[i] = st.nextToken();
        func(mas,n-1);
        if(find) {
            out.println("YES");
        }else{
            out.println("NO");
        }
    }

    public static void func(String[] mas, int last) {
        int d = Arrays.toString(mas).hashCode();
        if(set.contains(d)) return;
        set.add(d);
        if(last == 0 || find) find = true;
        if(last > 0 && (mas[last-1].charAt(0) == mas[last].charAt(0) || mas[last-1].charAt(1) == mas[last].charAt(1))) {
            String a = mas[last-1];
            mas[last-1] = mas[last];
            mas[last] = "";
            func(mas,last-1);
            mas[last] = mas[last-1];
            mas[last-1] = a;
        }
        if(last > 2 && (mas[last-3].charAt(0) == mas[last].charAt(0) || mas[last-3].charAt(1) == mas[last].charAt(1))) {
            String a = mas[last-3];
            mas[last-3] = mas[last];
            mas[last] = "";
            func(mas,last-1);
            mas[last] = mas[last-3];
            mas[last-3] = a;
        }
    }
}

/*
 * @author derrick20
 */
import java.awt.*;
import java.io.*;
import java.util.*;

public class solitaire {
    public static void main(String args[]) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        N = sc.nextInt();

        StringBuilder cards = new StringBuilder();
        for (int i = 0; i < N; i++) {
            String s = sc.next();
            cards.append(s);
        }

        memo = new HashMap<>();
        boolean ans = solve(cards, 2 * N - 1);
        out.println(ans ? "YES" : "NO");
        out.close();
    }

    static int N;
    // Shoot so hashmaps HAVE TO USE IMMUTABLES
    // SO EITHER STRINGS OR INTS OR LONGS, ETC...
    static HashMap<String, Boolean> memo;
//    static Card ZERO = new Card(0, 0);
    // Using the i indexed card, return whether we can solve it on the remaining cards
    static boolean solve(StringBuilder cards, int i) {
        if (i == 1) {
            // we finished!
            return true;
        }
        if (memo.containsKey(cards.toString())) {
            return memo.get(cards.toString());
        }
        else {
            boolean ans = false;

            StringBuilder copy = new StringBuilder(cards);
            String top = copy.substring(i - 1);
            if (copy.charAt(i) == copy.charAt(i - 2) || copy.charAt(i - 1) == copy.charAt(i - 3)) {
                // Try going placing onto the next card down
                String old = copy.substring(i - 3, i - 2 + 1);
                // delete that card and replace the one below
                copy.replace(i - 3, i - 2 + 1, top);
                ans |= solve(new StringBuilder(copy.substring(0, i - 2 + 1)), i - 2);
                // put it back, since we need to try the next case
                copy.replace(i - 3, i - 2 + 1, old);
            }
            if (i >= 7) {
                if (copy.charAt(i) == copy.charAt(i - 6) || copy.charAt(i - 1) == copy.charAt(i - 7)) {
                    // Try replacing the 3 cards down one
                    String old = copy.substring(i - 7, i - 6 + 1);
                    copy.replace(i - 7, i - 6 + 1, top);
                    // TODO AHH this line needs to be just moving over by one card, so 2 over!
                    ans |= solve(new StringBuilder(copy.substring(0, i - 2 + 1)), i - 2);
                    // put it back, since we need to try the next case
                    copy.replace(i - 7, i - 6 + 1, old);
                }
            }
//            System.out.println(memo);
            memo.put(cards.toString(), ans);
            return ans;
        }
    }

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        FastScanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        FastScanner(FileReader s) {
            br = new BufferedReader(s);
        }

        String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        String nextLine() throws IOException {
            return br.readLine();
        }

        double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }

        int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        long nextLong() throws IOException {
            return Long.parseLong(next());
        }
    }
}

import java.io.*;

public class CF208B {
	static int translate(char c) {
		switch (c) {
			case 'S': return 0;
			case 'D': return 1;
			case 'H': return 2;
			case 'C': return 3;
			case 'T': return 10;
			case 'J': return 11;
			case 'Q': return 12;
			case 'K': return 0;
			case 'A': return 1;
			default: return c - '0';
		}
	}
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		char[] aa = br.readLine().toCharArray();
		int[] vv = new int[n];
		int[] ss = new int[n];
		for (int i = 0; i < n; i++) {
			vv[i] = translate(aa[i * 3]);
			ss[i] = translate(aa[i * 3 + 1]);
		}
		if (n == 1) {
			System.out.println("YES");
			return;
		}
		if (n == 2) {
			System.out.println(vv[0] == vv[1] || ss[0] == ss[1] ? "YES" : "NO");
			return;
		}
		boolean[][][][][][][] dp = new boolean[n][13][4][13][4][13][4];
		for (int v2 = 0; v2 < 13; v2++)
			for (int s2 = 0; s2 < 4; s2++)
				for (int v1 = 0; v1 < 13; v1++)
					for (int s1 = 0; s1 < 4; s1++)
						for (int v0 = 0; v0 < 13; v0++)
							for (int s0 = 0; s0 < 4; s0++)
								dp[2][v2][s2][v1][s1][v0][s0] = (v1 == v0 || s1 == s0) && (v2 == v0 || s2 == s0);
		for (int i = 3; i < n; i++) {
			int v3 = vv[i - 3];
			int s3 = ss[i - 3];
			for (int v2 = 0; v2 < 13; v2++)
				for (int s2 = 0; s2 < 4; s2++)
					for (int v1 = 0; v1 < 13; v1++)
						for (int s1 = 0; s1 < 4; s1++)
							for (int v0 = 0; v0 < 13; v0++)
								for (int s0 = 0; s0 < 4; s0++) {
									boolean yes = false;
									if (v1 == v0 || s1 == s0)
										yes = yes || dp[i - 1][v3][s3][v2][s2][v0][s0];
									if (v3 == v0 || s3 == s0)
										yes = yes || dp[i - 1][v0][s0][v2][s2][v1][s1];
									dp[i][v2][s2][v1][s1][v0][s0] = yes;
								}
		}
		System.out.println(dp[n - 1][vv[n - 3]][ss[n - 3]][vv[n - 2]][ss[n - 2]][vv[n - 1]][ss[n - 1]] ? "YES" : "NO");
	}
}

import java.util.*;

public class LittleElephantInterval {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);

		int N = Integer.parseInt(in.nextLine());
		int x = N - 1;
		Queue<String[]> allCards = new LinkedList<String[]>();
		HashSet<String> lineup = new HashSet<String>();
		String l = in.nextLine();
		lineup.add(l);
		allCards.add(l.split(" "));
		while (!allCards.isEmpty()) {

			String[] cards = allCards.poll();
			x = cards.length - 1;
			if (x == 0) {
				break;
			}

			if (x - 1 > -1 && valid(cards[x], cards[x - 1])) {
				String[] c = put(Arrays.copyOf(cards, x + 1), x, x - 1);
				String[] d= Arrays.copyOf(c, c.length - 1);
				String l1  = Arrays.toString(d);
				if(!lineup.contains(l1)){
					allCards.add(d);
					lineup.add(l1);
				}
			}
			if (x - 3 > -1 && valid(cards[x], cards[x - 3])) {
				String[] c = put(Arrays.copyOf(cards, x + 1), x, x - 3);
				String [] d =  Arrays.copyOf(c, c.length - 1);
				String l1  = Arrays.toString(d);
				if(!lineup.contains(l1)){
					allCards.add(d);
					lineup.add(l1);
				}
			}
		}

		System.out.println(x == 0 ? "YES" : "NO");
	}

	private static String[] put(String[] cards, int x, int i) {
		cards[i] = cards[x];
		cards[x] = "EMPTY";
		return cards;
	}

	private static boolean valid(String l, String r) {
		return l.charAt(0) == r.charAt(0) || l.charAt(1) == r.charAt(1);
	}
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.util.HashMap;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        b208 solver = new b208();
        solver.solve(1, in, out);
        out.close();
    }

    static class b208 {
        HashMap<String, Boolean> memo;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            String deck = in.nextLine();
            memo = new HashMap<>();
            if (can(deck)) {
                out.println("YES");
            } else {
                out.println("NO");
            }
        }

        boolean can(String deck) {
            boolean res = false;
            if (memo.containsKey(deck)) {
                res = memo.get(deck);
            } else {
                res = _can(deck);
                memo.put(deck, res);
            }
            return res;
        }

        boolean _can(String deck) {
            int size = getSize(deck);
            if (size == 1) return true;
            boolean ans = false;
            if (canNext1(deck)) {
                ans |= can(getNext1(deck));
            }
            if (canNext3(deck)) {
                ans |= can(getNext3(deck));
            }
            return ans;
        }

        int getSize(String deck) {
            return (deck.length() + 1) / 3;
        }

        String getNext1(String deck) {
            deck = deck.substring(0, deck.length() - 5) + deck.substring(deck.length() - 2);
            return deck;
        }

        boolean canNext1(String deck) {
            if (deck.charAt(deck.length() - 1) == deck.charAt(deck.length() - 4)) return true;
            if (deck.charAt(deck.length() - 2) == deck.charAt(deck.length() - 5)) return true;
            return false;
        }

        String getNext3(String deck) {
            deck = deck.substring(0, deck.length() - 11) + deck.substring(deck.length() - 2) + deck.substring(deck.length() - 9, deck.length() - 3);
            return deck;
        }

        boolean canNext3(String deck) {
            if (deck.length() < 11) return false;
            if (deck.charAt(deck.length() - 1) == deck.charAt(deck.length() - 10)) return true;
            if (deck.charAt(deck.length() - 2) == deck.charAt(deck.length() - 11)) return true;
            return false;
        }

    }

    static class InputReader {
        private BufferedReader reader;
        private StringTokenizer stt;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
        }

        public String nextLine() {
            try {
                return reader.readLine();
            } catch (IOException e) {
                return null;
            }
        }

        public String next() {
            while (stt == null || !stt.hasMoreTokens()) {
                stt = new StringTokenizer(nextLine());
            }
            return stt.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}

import java.util.*;
import java.io.*;

public class b208{
  public static  boolean  valid(String[] arr,int i,int j)
  {
    if(arr[i].charAt(0)==arr[j].charAt(0) || arr[i].charAt(1)==arr[j].charAt(1))
      return true;
    return false;
  }
  public  static void  main(String arg[]){
  Queue<String[] >  allcards = new LinkedList<String[]>();
  HashSet<String> has = new HashSet<String>();
   Scanner sc = new Scanner(System.in);
   int n = Integer.parseInt(sc.nextLine());
    String l=  sc.nextLine();
    has.add(l);
    int x=0;
    allcards.add(l.split(" "));
    while(!allcards.isEmpty())
    {
      String[] temp = allcards.poll();
       x = temp.length;
      x=x-1;
      if(x==0)
        break;
      if(x-1>=0 && valid(temp,x,x-1) )
      {
        String ext = temp[x];
        String[] ar = Arrays.copyOf(temp,temp.length-1);
        ar[x-1]=ext;
        l = Arrays.toString(ar);
        if(!has.contains(l))
        {
          has.add(l);
          allcards.add(ar);
        }
      }
      if(x-3>=0 && valid(temp,x,x-3) )
      {
        String ext = temp[x];
        String[] ar = Arrays.copyOf(temp,temp.length-1);
        ar[x-3]=ext;
        l = Arrays.toString(ar);
        if(!has.contains(l))
        {
          has.add(l);
          allcards.add(ar);
        }
      }

    }
    if(x==0)
      System.out.println("YES");
    else
       System.out.println("NO");
   }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;
import java.io.BufferedReader;

public class fstclass {
	static int d1[] = new int[503030];
	static int d2[] = new int[503030];
	static String s[] = new String[3030];
	static String d = "TJQKASDHC";
	static Map <String, Integer> mp1 = new HashMap<>();
	static Map <String, Integer> mp2 = new HashMap<>();
	public static void main(String[] args) {
		InputStream inputStream = System.in;
        InputReader in = new InputReader(inputStream);
        int n = in.nextInt();
        for(int i = 1; i <= n; i ++) {
        	s[i] = in.next();
        }
        if(n > 3) {
        	mp1.put(s[n - 2] + s[n - 1] + s[n], 1);
        }
        if(n == 1) {
        	mp1.put(s[1] + s[1] + s[1], 1);
        }
        if(n == 2) {
        	mp1.put(s[2] + s[1] + s[2], 1);
        }
        if(n == 3) {
        	mp1.put(s[1] + s[2] + s[3], 1);
        }
        n -= 3;
        while(n > 0) {
        	for(Map.Entry entry: mp1.entrySet()) {
        		String ss = (String) entry.getKey();
        		if(ss.charAt(4) == s[n].charAt(0) || ss.charAt(5) == s[n].charAt(1)) {
        			String dd = "";
        			dd += ss.charAt(4);
        			dd += ss.charAt(5);
        			dd += ss.charAt(0);
        			dd += ss.charAt(1);
        			dd += ss.charAt(2);
        			dd += ss.charAt(3);
        			mp2.put(dd, 1);
        		}
        		if(ss.charAt(4) == ss.charAt(2) || ss.charAt(5) == ss.charAt(3)) {
        			String dd = s[n];
        			dd += ss.charAt(0);
        			dd += ss.charAt(1);
        			dd += ss.charAt(4);
        			dd += ss.charAt(5);
        			mp2.put(dd, 1);
        		}
        	}
        	mp1.clear();
        	for(Map.Entry entry: mp2.entrySet()) {
        		String ss = (String) entry.getKey();
        		mp1.put(ss, 1);
        	}
        	mp2.clear();
        	n --;
        }
        for(Map.Entry entry: mp1.entrySet()) {
    		String ss = (String) entry.getKey();
    		check("" + ss.charAt(0) + ss.charAt(1), "" + ss.charAt(2) + ss.charAt(3), "" + ss.charAt(4) + ss.charAt(5));
    	}
        System.out.print("NO");
	}
	public static void check(String s1, String s2, String s3) {
		if((s3.charAt(0) == s2.charAt(0) || s3.charAt(1) == s2.charAt(1)) && (s3.charAt(0) == s1.charAt(0) || s3.charAt(1) == s1.charAt(1))) {
			System.out.print("YES");
			System.exit(0);
		}
	}

	static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }

}

// package Practice.CF208;

import java.io.*;
import java.util.*;

public class CF208C {
    public static  boolean  valid(String[] arr,int i,int j)
    {
        if(arr[i].charAt(0)==arr[j].charAt(0) || arr[i].charAt(1)==arr[j].charAt(1))
            return true;
        return false;
    }

    public  static void  main(String arg[]){
        Queue<String[] >  allcards = new LinkedList<String[]>();
        HashSet<String> has = new HashSet<String>();
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.nextLine());
        String l=  sc.nextLine();
        has.add(l);
        int x=0;
        allcards.add(l.split(" "));
        while(!allcards.isEmpty())
        {
            String[] temp = allcards.poll();
            x = temp.length;
            x=x-1;
            if(x==0)
                break;
            if(x-1>=0 && valid(temp,x,x-1) )
            {
                String ext = temp[x];
                String[] ar = Arrays.copyOf(temp,temp.length-1);
                ar[x-1]=ext;
                l = Arrays.toString(ar);
                if(!has.contains(l))
                {
                    has.add(l);
                    allcards.add(ar);
                }
            }
            if(x-3>=0 && valid(temp,x,x-3) )
            {
                String ext = temp[x];
                String[] ar = Arrays.copyOf(temp,temp.length-1);
                ar[x-3]=ext;
                l = Arrays.toString(ar);
                if(!has.contains(l))
                {
                    has.add(l);
                    allcards.add(ar);
                }
            }

        }
        if(x==0)
            System.out.println("YES");
        else
            System.out.println("NO");
    }
}

import java.util.*;
import java.io.*;

public class B {

	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer st;

	int n;
	String[] s;
	Map<String, Boolean> cache;

	boolean dfs(String[] ss, int d) {

		if (d == 1) {
			return true;
		}
		String t = "";
		for(int i = 0; i < ss.length; ++i)  t+=ss[i];
		if (cache.containsKey(t)) {
			return cache.get(t);
		}

		String[] s2 = new String[ss.length - 1];

		int i = ss.length - 1;
		if (i >= 1
				&& (ss[i].charAt(0) == ss[i - 1].charAt(0) || ss[i].charAt(1) == ss[i - 1]
						.charAt(1))) {

			for(int j = 0; j < i; ++j) {
				s2[j] = ss[j];
			}
			s2[i - 1] = ss[i];
			if (dfs(s2, d - 1)) {
				cache.put(t, true);
				return true;
			}
		}
		if (i >= 3
				&& (ss[i].charAt(0) == ss[i - 3].charAt(0) || ss[i]
						.charAt(1) == ss[i - 3].charAt(1))) {

			for(int j = 0; j < i; ++j) {
				s2[j] = ss[j];
			}
			s2[i - 3] = ss[i];
			if (dfs(s2, d - 1)) {
				cache.put(t, true);
				return true;
			}
		}
		cache.put(t, false);
		return false;
	}

	public void solve() throws IOException {
		n = nextInt();
//		n = 50;
		s = new String[n];
		cache = new HashMap<String, Boolean>();
//		Random rng = new Random();
		for (int i = 0; i < n; ++i) {
			s[i] = next();
//			s[i] = "";
//			s[i] += rng.nextInt(10);
//			s[i] += rng.nextInt(10);
		}
//		debug(s);
		if (dfs(s, n)) {
			out.println("YES");
		} else {
			out.println("NO");
		}
	}

	B() throws IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		//in = new BufferedReader(new InputStreamReader(new FileInputStream("Main.in")));
		out = new PrintWriter(System.out);
		eat("");

		solve();

		out.close();
	}

	void eat(String s) {
		st = new StringTokenizer(s);
	}

	String nextLine() {
		try {
			return in.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

	boolean hasNext() {
		while (!st.hasMoreTokens()) {
			String s = nextLine();
			if (s == null)
				return false;
			eat(s);
		}
		return true;
	}

	String next() {
		hasNext();
		return st.nextToken();
	}

	int nextInt() {
		return Integer.parseInt(next());
	}

	long nextLong() {
		return Long.parseLong(next());
	}

	double nextDouble() {
		return Double.parseDouble(next());
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}

	public static void main(String[] args) throws IOException {
		new B();
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;

public class Main {

    static Set<String> seen;

    static boolean dfs(String s) {
        if (s.length() == 2)
            return true;
        seen.add(s);

        String last = s.substring(s.length() - 2);
        s = s.substring(0, s.length() - 2);
        if (s.length() >= 2) {
            String toDelete = s.substring(s.length() - 2);
            if (toDelete.charAt(0) == last.charAt(0) || toDelete.charAt(1) == last.charAt(1)) {
                String next = s.substring(0, s.length() - 2) + last;
                if (!seen.contains(next) && dfs(next))
                    return true;
            }
        }

        if (s.length() >= 6) {
            String toDelete = s.substring(s.length() - 6, s.length() - 4);
            if (toDelete.charAt(0) == last.charAt(0) || toDelete.charAt(1) == last.charAt(1)) {
                String next = s.substring(0, s.length() - 6) + last + s.substring(s.length() - 4);
                if (!seen.contains(next) && dfs(next))
                    return true;
            }
        }

        return false;
    }

    public static void main(String[] args) {
        InputReader in = new InputReader(System.in);

        int N = in.nextInt();
        String initialState = "";
        for (int i = 0; i < N; ++i)
            initialState += in.next();

        seen = new HashSet<String>();

        System.out.println(dfs(initialState) ? "YES" : "NO");
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        public String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens())
                    tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }

            return tokenizer.nextToken();
        }

        public String nextLine() {
            String line = null;
            try {
                tokenizer = null;
                line =  reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            return line;
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }
    }
}

import java.awt.Point;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class B {
    static String[] a;
    static int[][][][] dp;

    public static void main(String[] args) throws IOException {
        InputReader in = new InputReader();
        int n = in.nextInt();
        a = new String[n];
        dp = new int[n + 1][n + 1][n + 1][n + 1];
        for (int i = 0; i < n; i++)
            a[i] = in.next();
        if(n==1){
            System.out.println("YES");
            return;
        }
        for (int i = 0; i < n + 1; i++) {
            for (int j = 0; j < n + 1; j++) {
                for (int k = 0; k < n + 1; k++) {
                    for (int z = 0; z < n + 1; z++) {
                        dp[i][j][k][z] = -1;
                    }
                }
            }
        }
        int res = solve(n - 1, n - 3, n - 2, n - 1);
        if (res == 1)
            System.out.println("YES");
        else
            System.out.println("NO");
    }

    public static int solve(int at, int a, int b, int c) {
        if (at == 1)
            return ok(c, b) ? 1 : 0;
        if (a < 0 || b < 0 || c < 0)
            return 0;
        if (dp[at][a][b][c] != -1)
            return dp[at][a][b][c];
        int res = 0;
        if (ok(c, b)) {
            res = Math.max(res, solve(at - 1, at - 3, a, c));
        }
        if (ok(c, at - 3)) {
            res = Math.max(res, solve(at - 1, c, a, b));
        }
        return dp[at][a][b][c] = res;
    }

    public static boolean ok(int c, int b) {
        if (c < 0 || b < 0)
            return false;
        return a[c].charAt(0) == a[b].charAt(0)
                || a[c].charAt(1) == a[b].charAt(1);
    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer st;

        public InputReader() throws IOException {
            in = new BufferedReader(new InputStreamReader(System.in));
            st = new StringTokenizer(in.readLine());
        }

        public String next() throws IOException {
            while (!st.hasMoreElements())
                st = new StringTokenizer(in.readLine());
            return st.nextToken();
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }
    }

}

import java.util.*;
import java.io.*;

public class forceees {
    public static void main(String[] args) throws IOException {
        BufferedReader rd = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(rd.readLine());
        cards = new String[N];
        StringTokenizer st = new StringTokenizer(rd.readLine());
        for(int i=0; i<N; i++){
            cards[i] = st.nextToken();
            cardToint.put(cards[i], i);
        }
        for(int i=0; i<N; i++){
            for(int j=0; j<N; j++){
                if(i==j) continue;
                String a = cards[i], b = cards[j];
                if(a.charAt(0)==b.charAt(0) || a.charAt(1)==b.charAt(1)) canstick[i][j] = true;
            }
        }
        boolean f;
        if(N==1){
            f = true;
        }
        else if(N==2){
            f = (canstick[1][0]);
        }
        else if(N==3){
            f = (canstick[2][1]) && canstick[2][0];
        }
        else{
            f = rec(N-3 , N-2 , N-1, N-3);
        }
        if(f) System.out.println("YES");
        else System.out.println("NO");
    }

    static boolean simulate(int a, int b, int c, int d){
        if(canstick[d][a]){
            // d b c
            if(canstick[c][b]){
                // d c
                if(canstick[c][d]){
                    return true;
                }
            }
        }
        if(canstick[d][c]){
            // a b d
            if(canstick[d][b]){
                // a d
                if(canstick[d][a]){
                    return true;
                }
            }
        }
        return false;
    }

    static boolean rec(int b, int c, int d, int k){
    //  System.out.println(b+" "+c+" "+d+" "+k);
        if(been[b][c][d][k]) return dp[b][c][d][k];
        if(k==0){
            boolean can = false;

            if(canstick[d][c] && canstick[d][b]) can = true;

            been[b][c][d][k] = true;
            dp[b][c][d][k] = can;
            return can;
        }
        // d -> c   an   d->a
        if(canstick[d][k-1]){ // k-1 b c d
            boolean find = rec(d, b, c, k-1);
            if(find){
                been[b][c][d][k] = true;
                dp[b][c][d][k] = true;
                return true;
            }
        }

        if(canstick[d][c]){ // k-1 b c d
            boolean find = rec(k-1, b, d, k-1);
            if(find){
                been[b][c][d][k] = true;
                dp[b][c][d][k] = true;
                return true;
            }
        }
        been[b][c][d][k] = true;
        dp[b][c][d][k] = false;
        return false;
    }

    static boolean[][][][] been = new boolean[53][53][53][53];

    static boolean[][][][] dp = new boolean[53][53][53][53];

    static boolean[][] canstick = new boolean[53][53];

    static String[] cards;

    static HashMap<String, Integer> cardToint = new HashMap<String, Integer>();

}

import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Deque;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;
import java.util.Set;

public class TaskB {
    /**
     * @param args
     */
    public static void main(String[] args) {
        TaskB task = new TaskB();
        task.read();
        task.write();
    }

    int n;
    List<String> lines = new ArrayList<String>();
    Deque<String> q = new LinkedList<String>();
    Deque<Integer> q1 = new LinkedList<Integer>();
    List<HashSet<String> > was = new ArrayList<HashSet<String> >();

    public void read() {
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        for (int i = 0; i < n; i++){
            lines.add(in.next());
            was.add(new HashSet<String>());
        }
        in.close();
    }

    public void write() {
        PrintWriter out = new PrintWriter(System.out);
        String f = "";
        String next;
        for (int i = Math.max(0, n - 3); i < n; i++){
            f += lines.get(i);
        }
        int len = Math.max(0, n - 3);
        int size;
        boolean fl = false;
        q.push(f);
        q1.push(len);
        was.get(len).add(f);
        while (!q.isEmpty()){
            f = q.poll();
            len = q1.poll();
            size = f.length();
            if (size > 4) {
                if ((f.charAt(size - 1) == f.charAt(size - 3)) || (f.charAt(size - 2) == f.charAt(size - 4))){
                    next = f.substring(0, size - 4) + f.charAt(size - 2) + f.charAt(size - 1);
                    if (len > 0){
                        next = lines.get(len - 1) + next;
                    }
                    if (!was.get(Math.max(0, len - 1)).contains(next)){
                        q.push(next);
                        q1.push(Math.max(0, len - 1));
                        was.get(Math.max(0, len - 1)).add(next);
                    }
                }
                if (len > 0){
                    if ((f.charAt(size - 1) == lines.get(len - 1).charAt(1)) || (f.charAt(size - 2) == lines.get(len - 1).charAt(0))){
                        next = "" + f.charAt(size - 2) + f.charAt(size - 1) + f.substring(0, size - 2);
                        if (!was.get(len - 1).contains(next)){
                            q.push(next);
                            q1.push(len - 1);
                            was.get(len - 1).add(next);
                        }
                    }
                }
            }else{
                if (size == 2){
                    fl = true;
                }else{
                    if ((f.charAt(size - 1) == f.charAt(size - 3)) || (f.charAt(size - 2) == f.charAt(size - 4))){
                    next = "" + f.charAt(size - 2) + f.charAt(size - 1);
                    if (!was.get(0).contains(next)){
                        q.push(next);
                        q1.push(0);
                        was.get(0).add(next);
                    }
                    }
                }
            }

        }
        if (fl){
            out.println("YES");
        }else{
            out.println("NO");
        }
        out.flush();
        out.close();
    }
}

import java.util.Scanner;

public class Solitair implements Runnable {
  int get(String s) {
    if (s.length() != 2) throw new RuntimeException();
    int res = 0;
    char c = s.charAt(0);
    if ('2' <= c && c <='9') {
      res += c - '2';
    }
    if (c == 'T') res += 8;
    if (c == 'J') res += 9;
    if (c == 'Q') res += 10;
    if (c == 'K') res += 11;
    if (c == 'A') res += 12;
    c = s.charAt(1);
    int m = 0;
    if (c == 'D') m = 1;
    if (c == 'H') m = 2;
    if (c == 'C') m = 3;
    return res + 13 * m;
  }

  boolean match(int a, int b) {
    return a % 13 == b % 13 || a / 13 == b / 13;
  }

  public void run() {
    try {
      Scanner in = new Scanner(System.in);
      //BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
      int n = in.nextInt();
      int[] p = new int[n];
      for (int i = 0; i < n; i++) {
        p[i] = get(in.next());
      }
      boolean[][][][] res = new boolean[52][52][52][n];
      if (n == 1) {
        System.out.println("YES");
        return;
      }
      if (n == 2) {
        if (match(p[0], p[1])) {
          System.out.println("YES");
        } else {
          System.out.println("NO");
        }
        return;
      }
      res[p[n - 1]][p[n - 2]][p[n - 3]][n - 1] = true;
      for (int i = n - 1; i > 0; i--) {
        for (int a = 0; a < 52; a++)
          for (int b = 0; b < 52; b++)
            for (int c = 0; c < 52; c++) if (res[a][b][c][i]) {
              if (i - 3 >= 0) {
                if (match(a, b)) {
                  res[a][c][p[i - 3]][i - 1] = true;
                }
                if (match(a, p[i - 3])) {
                  res[b][c][a][i - 1] = true;
                }
              } else {
                if (match(a, b)) {
                  res[a][c][0][i - 1] = true;
                }
              }
            }
      }
      boolean ok = false;
      for (int i = 0; i < 52; i++) if (res[i][0][0][0]) {
        ok = true;
      }
      if (ok) System.out.println("YES");
      else System.out.println("NO");
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }

  public static void main(String[] args) {
    new Thread(new Solitair()).start();
  }
}

/**
 * Created by ckboss on 14-9-5.
 */
import java.util.*;

/*
class
*/

public class Solitaire {

    static int[][][][] dp = new int[60][60][60][60];
    static boolean[][][][] vis = new boolean[60][60][60][60];
    static char[] c1=new char[60];
    static char[] c2=new char[60];

    static boolean check(int a,int b){
        if((c1[a]==c1[b])||(c2[a]==c2[b]))
            return true;
        else return false;
    }

    static int dfs(int cur,int a,int b,int c){
        if(vis[cur][a][b][c]==true)
            return dp[cur][a][b][c];
        vis[cur][a][b][c]=true;
        if(cur==1)
            return dp[cur][a][b][c] = 1;
        if(cur==2){
            if(check(a,b)==true){
                return dp[cur][a][b][c] = 1;
            }
            else{
                return dp[cur][a][b][c] = 0;
            }
        }
        int ret=0;
        if(check(a,b)==true){
            ret=dfs(cur-1,a,c,cur-3);
        }
        if(ret==1){
            return dp[cur][a][b][c] = 1;
        }
        if(check(a,cur-3)==true){
            ret=dfs(cur-1,b,c,a);
        }
        return dp[cur][a][b][c]=ret;
    }

    public static void main(String[] args){
        Scanner in=new Scanner(System.in);

        int n=in.nextInt();

        for(int i=1;i<=n;i++){
            String temp=in.next().trim();
            c1[i]=temp.charAt(0);
            c2[i]=temp.charAt(1);
        }

        if(n==1){
            System.out.println("YES");
        }
        else if(dfs(n,n,n-1,n-2)==1){
            System.out.println("YES");
        }
        else{
            System.out.println("NO");
        }
    }
}

/**
 * Created by ckboss on 14-9-5.
 */
import java.util.*;

public class Solitaire {

    static int[][][][] dp = new int[60][60][60][60];
    static boolean[][][][] vis = new boolean[60][60][60][60];
    static char[] c1=new char[60];
    static char[] c2=new char[60];

    static boolean check(int a,int b){
        if((c1[a]==c1[b])||(c2[a]==c2[b]))
            return true;
        else return false;
    }

    static int dfs(int cur,int a,int b,int c){
        if(vis[cur][a][b][c]==true)
            return dp[cur][a][b][c];
        vis[cur][a][b][c]=true;
        if(cur==1)
            return dp[cur][a][b][c] = 1;
        if(cur==2){
            if(check(a,b)==true){
                return dp[cur][a][b][c] = 1;
            }
            else{
                return dp[cur][a][b][c] = 0;
            }
        }
        int ret=0;
        if(check(a,b)==true){
            ret=dfs(cur-1,a,c,cur-3);
        }
        if(ret==1){
            return dp[cur][a][b][c] = 1;
        }
        if(check(a,cur-3)==true){
            ret=dfs(cur-1,b,c,a);
        }
        return dp[cur][a][b][c]=ret;
    }

    public static void main(String[] args){
        Scanner in=new Scanner(System.in);

        int n=in.nextInt();

        for(int i=1;i<=n;i++){
            String temp=in.next().trim();
//            ac[i]=new ACC(temp.charAt(0),temp.charAt(1));
            c1[i]=temp.charAt(0);
            c2[i]=temp.charAt(1);
        }

        //for(int i=1;i<=n;i++) System.out.println(ac[i].c1 + " , " + ac[i].c2);

        if(n==1){
            System.out.println("YES");
        }
        else if(dfs(n,n,n-1,n-2)==1){
            System.out.println("YES");
        }
        else{
            System.out.println("NO");
        }
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;

public class B {

    public static void main(String[] args) throws NumberFormatException,
            IOException {
        BufferedReader buf = new BufferedReader(
                new InputStreamReader(System.in));
        int n = Integer.parseInt(buf.readLine());
        String[] a = buf.readLine().split(" ");
        map = new HashMap<String, Integer>();
        for (int i = 0; i < a.length; i++)
            if (!map.containsKey(a[i]))
                map.put(a[i], i);
        check = false;
        boolean[][][] dp = new boolean[n][n][n];
        dfs(a, dp, a.length - 1);

        if (check)
            System.out.println("YES");
        else
            System.out.println("NO");
    }

    static HashMap<String, Integer> map;

    private static void dfs(String[] a, boolean[][][] dp, int i) {
        if (i == 0)
            check = true;
        else if (i - 2 >= 0 && dp[i][map.get(a[i])][map.get(a[i - 2])])
            return;
        else if (!check) {
            if (i - 2 >= 0)
                dp[i][map.get(a[i])][map.get(a[i - 2])] = true;
            int cnt = 0;
            for (int j = i - 1; j >= 0 && cnt < 2; j -= 2) {
                cnt++;
                String temp = a[j];
                if (a[j].charAt(0) == a[i].charAt(0)
                        || a[j].charAt(1) == a[i].charAt(1)) {
                    a[j] = a[i];

                    dfs(a, dp, i - 1);
                    a[j] = temp;
                }
            }
        }

    }

    static boolean check;

}

import java.util.*;
import java.io.*;

public class B {

	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer st;

	int n;
	String[] s;

	boolean dfs(String[] ss, int d) {

		if (d == 1) {
			return true;
		}
		String[] s2 = new String[ss.length - 1];

		for(int i = 0; i < ss.length; ++i) {
			if (i >= 1 && (ss[i].charAt(0) == ss[i-1].charAt(0) || ss[i].charAt(1) == ss[i-1].charAt(1))) {
				for(int j = 0; j < i; ++j) {
					s2[j] = ss[j];
				}
				for(int j = i+1; j < ss.length; ++j) {
					s2[j-1] = ss[j];
				}
				s2[i-1] = ss[i];
				if (dfs(s2, d-1)) return true;
			}
			if (i >= 3 && (ss[i].charAt(0) == ss[i-3].charAt(0) || ss[i-3].charAt(1) == ss[i-3].charAt(1))) {
				for(int j = 0; j < i; ++j) {
					s2[j] = ss[j];
				}
				for(int j = i+1; j < ss.length; ++j) {
					s2[j-1] = ss[j];
				}
				s2[i-3] = ss[i];
				if (dfs(s2, d-1)) return true;
			}
		}
		return false;
	}

	public void solve() throws IOException {
		n = nextInt();
		s = new String[n];
		for(int i = 0; i < n; ++i) {
			s[i] = next();
		}
		if (dfs(s, n)) {
			out.println("YES");
		}
		else {
			out.println("NO");
		}
	}

	B() throws IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		//in = new BufferedReader(new InputStreamReader(new FileInputStream("Main.in")));
		out = new PrintWriter(System.out);
		eat("");

		solve();

		out.close();
	}

	void eat(String s) {
		st = new StringTokenizer(s);
	}

	String nextLine() {
		try {
			return in.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

	boolean hasNext() {
		while (!st.hasMoreTokens()) {
			String s = nextLine();
			if (s == null)
				return false;
			eat(s);
		}
		return true;
	}

	String next() {
		hasNext();
		return st.nextToken();
	}

	int nextInt() {
		return Integer.parseInt(next());
	}

	long nextLong() {
		return Long.parseLong(next());
	}

	double nextDouble() {
		return Double.parseDouble(next());
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}

	public static void main(String[] args) throws IOException {
		new B();
	}
}

import java.util.*;
import java.io.*;

public class b {
   static Map<String, Boolean> dp = new HashMap<String, Boolean>();
   static boolean[][] vi = new boolean[55][55];

   static String make(String[] pa) {
      String s = "";
      for(String t : pa)
         s += t + " ";
      return s.trim();
   }

   static boolean doit(String s, int k, int p) {
      if(k == 0) return true;
      if(vi[k][p]) return false;
      boolean r = false;
      String[] pa = s.split(" ");
      for(int i = k - 1; i >= 0; --i) {
         vi[k][i] = true;
         if(pa[i].charAt(0) == pa[k].charAt(0) || pa[i].charAt(1) == pa[k].charAt(1)) {
            pa[i] = pa[k];
            r = r | doit(make(pa), k - 1, i);
         }
      }
      return r;
   }

   public static void main(String[] args) throws IOException {
      //BufferedReader br = new BufferedReader(new FileReader("b.in"));
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      String line = br.readLine();
      int n = Integer.parseInt(line);
      line = br.readLine();
      //debug(line);
      boolean r = doit(line, n - 1, n);
      System.out.println((r ? "YES" : "NO"));
   }

   static void debug(Object...o) {
      System.err.println(Arrays.deepToString(o));
   }
}

import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import java.io.*;
import java.math.*;
import java.text.*;
import java.util.*;

/*
br = new BufferedReader(new FileReader("input.txt"));
pw = new PrintWriter(new BufferedWriter(new FileWriter("output.txt")));
br = new BufferedReader(new InputStreamReader(System.in));
pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
 */

public class Main {
  private static BufferedReader br;
  private static StringTokenizer st;
  private static PrintWriter pw;

  static String[] list;

  public static void main(String[] args) throws IOException {
    br = new BufferedReader(new InputStreamReader(System.in));
    pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    //int qq = 1;
    int qq = Integer.MAX_VALUE;
    //int qq = readInt();
    for(int casenum = 1; casenum <= qq; casenum++)  {
      int n = readInt();
      seen = new HashSet<Integer>();
      list = new String[n];
      for(int i = 0; i < n; i++) {
        list[i] = nextToken();
      }
      pw.println(can(n-1) ? "YES" : "NO");
    }
    pw.close();
  }

  public static boolean can(int n) {
    if(n==0) {
      return true;
    }
    int hash = hash(n);
    if(!seen.add(hash)) return false;
    if(list[n].charAt(0) == list[n-1].charAt(0) || list[n].charAt(1) == list[n-1].charAt(1)) {
      String save = list[n-1];
      list[n-1] = list[n];
      if(can(n-1)) {
        return true;
      }
      list[n-1] = save;
    }
    if(n-3 >= 0 && (list[n].charAt(0) == list[n-3].charAt(0) || list[n].charAt(1) == list[n-3].charAt(1))) {
      String save = list[n-3];
      list[n-3] = list[n];
      if(can(n-3)) {
        return true;
      }
      list[n-3] = save;
    }
    return false;
  }

  static Set<Integer> seen;

  public static int hash(int n) {
    int ret = 0;
    for(int i = 0; i <= n; i++) {
      ret *= 3137;
      ret += list[i].hashCode();
    }
    return ret;
  }

  private static void exitImmediately() {
    pw.close();
    System.exit(0);
  }

  private static long readLong() throws IOException {
    return Long.parseLong(nextToken());
  }

  private static double readDouble() throws IOException {
    return Double.parseDouble(nextToken());
  }

  private static int readInt() throws IOException {
    return Integer.parseInt(nextToken());
  }

  private static String nextToken() throws IOException  {
    while(st == null || !st.hasMoreTokens())  {
      if(!br.ready()) {
        exitImmediately();
      }
      st = new StringTokenizer(br.readLine().trim());
    }
    return st.nextToken();
  }
}

import java.util.*;
import java.io.*;
import static java.lang.Math.*;

public class B{
    public static void main(String[] args) throws Exception{
        new B().run();
    }

    int n;
    String[] cards;
    Set<StringArray> ng = new HashSet<StringArray>();
    boolean ok(StringArray sa){
        //System.out.printf("ok(%s)\n", s);
        if(ng.contains(sa))
            return false;
        int cs = sa.ar.length;
        if(cs == 1)return true;
        char num = sa.ar[0].charAt(0);
        char suit = sa.ar[0].charAt(1);
        if(num == sa.ar[1].charAt(0) || suit == sa.ar[1].charAt(1)){
            StringArray next = new StringArray(cs-1);
            next.ar[0] = sa.ar[0];
            for(int i = 2; i < cs; i++)
                next.ar[i-1] = sa.ar[i];
            if(ok(next))
                return true;
        }
        if(cs >= 4 && (num == sa.ar[3].charAt(0) || suit == sa.ar[3].charAt(1))){
            StringArray next = new StringArray(cs-1);
            next.ar[0] = sa.ar[1];
            next.ar[1] = sa.ar[2];
            next.ar[2] = sa.ar[0];
            for(int i = 4; i < cs; i++)
                next.ar[i-1] = sa.ar[i];
            if(ok(next))
                return true;
        }
        ng.add(sa);
        return false;
    }

    void run() throws Exception{
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        cards = new String[n];
        for(int i = 0; i < n; i++)
            cards[i] = sc.next();
        StringArray sa = new StringArray(n);
        for(int i = n-1; i >= 0; i--)
            sa.ar[i] = cards[i];
        System.out.println(ok(sa) ? "YES" : "NO");
    }
}

class StringArray{
    String[] ar;
    StringArray(int n){
        ar = new String[n];
    }
    @Override public int hashCode(){
        return 0;
    }
    @Override public boolean equals(Object o){
        StringArray sa = (StringArray) o;
        if(ar.length != sa.ar.length)
            return false;
        for(int i = 0; i < ar.length; i++)
            if(!ar[i].equals(sa.ar[i]))
                return false;
        return true;
    }
}

import java.io.DataInputStream;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.TreeSet;

public class Solitaire {
	static TreeSet<String> dp ;
	static SL a;
	public static void main(String [] args) throws Exception{
		FS in = new FS(System.in);
		int n = in.nextInt();
		a = new SL();
		dp = new TreeSet<>();
		for(int i = 0 ; i < n ; i++){
			a.add(in.nextString());
		}
		try {
			DFS();
			System.out.println("NO");
		} catch (Exception e) {
			System.out.println("YES");
		}

	}
	static boolean DFS() throws Exception{
		int n = a.size();
		if(n==1){
			throw new ArithmeticException();
		}
		String s = a.toString();
		if(dp.contains(s)){
			return false;
		}
		String x1 ="";
		String x3 ="";
		try{
			x1 = a.get(n-2);
			x3 = a.get(n-4);
		} catch (Exception e) {	}

		for(int i = n-1 ; i < n ; i++){
			if(i!=n-4 && i != n-2){
				String t = a.get(i);
				if(t.charAt(0)==x1.charAt(0) || t.charAt(1)==x1.charAt(1)){
					a.remove(n-2);
					a.add(n-2 , t);
					a.remove(i);
					DFS();
					a.add(i,t);
					a.remove(n-2);
					a.add(n-2,x1);
				}
				if(x3!=""){
					if(t.charAt(0)==x3.charAt(0) || t.charAt(1)==x3.charAt(1)){
						a.remove(n-4);
						a.add(n-4 , t);
						a.remove(i);
						DFS();
						a.add(i,t);
						a.remove(n-4);
						a.add(n-4,x1);
					}
				}
			}
		}
		dp.add(a.toString());
		return false;
	}
}
class SL extends ArrayList<String>{
	@Override
	public String toString() {
		String out = "";
		for(String s : this){
			out+=s+" ";
		}
		return out;
	}
}
class FS
{
   final private int BUFFER_SIZE = 1 << 17;

   private DataInputStream din;
   private byte[] buffer;
   private int bufferPointer, bytesRead;

   public FS(InputStream in)
   {
      din = new DataInputStream(in);
      buffer = new byte[BUFFER_SIZE];
      bufferPointer = bytesRead = 0;
   }
   public String nextString() throws Exception
   {
       StringBuffer sb=new StringBuffer("");
       byte c = read();
       while (c <= ' ') c = read();
       do
       {
           sb.append((char)c);
           c=read();
       }while(c>' ');
       return sb.toString();
   }
   public char nextChar() throws Exception
   {
       byte c=read();
       while(c<=' ') c= read();
       return (char)c;
   }
   public int nextInt() throws Exception
   {
      int ret = 0;
      byte c = read();
      while (c <= ' ') c = read();
      boolean neg = c == '-';
      if (neg) c = read();
      do
      {
          ret = ret * 10 + c - '0';
         c = read();
      } while (c > ' ');
      if (neg) return -ret;
      return ret;
   }
   public long nextLong() throws Exception
   {
      long ret = 0;
      byte c = read();
      while (c <= ' ') c = read();
      boolean neg = c == '-';
      if (neg) c = read();
      do
      {
          ret = ret * 10 + c - '0';
         c = read();
      } while (c > ' ');
      if (neg) return -ret;
      return ret;
   }
   private void fillBuffer() throws Exception
   {
      bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
      if (bytesRead == -1) buffer[0] = -1;
   }

   private byte read() throws Exception
   {
      if (bufferPointer == bytesRead) fillBuffer();
      return buffer[bufferPointer++];
   }
}

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class B130 {
    static boolean [][] isok;
    static int [] index;

    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        while(cin.hasNext()){
            int n = cin.nextInt();
            String [] cards = new String [n];
            Map<String,Integer> count = new HashMap<String,Integer>();
            for( int i = 0 ; i<n;i++){
                cards[i] = cin.next();
                String key = "0"+cards[i].charAt(0);
                int cnt = 0;
                if( count.containsKey(key)){
                    cnt = count.get(key);
                }
                count.put(key, cnt + 1);
                key = "1"+cards[i].charAt(1);
                cnt = 0;
                if( count.containsKey(key)){
                    cnt = count.get(key);
                }
                count.put(key, cnt + 1);

            }
            isok = new boolean[n][n];
            for( int i= 0; i<n ; i ++){
                for( int j=i+1 ; j <n ; j ++){
                    if(cards[i].charAt(0) == cards[j].charAt(0)
                            || cards[i].charAt(1) == cards[j].charAt(1)){
                        isok[i][j] = isok[j][i] = true;
                    }
                }
                isok[i][i] = true;
            }
            boolean ok = true;
            for( int i=0;ok&&i<n;i++){
                if( count.get("0"+cards[i].charAt(0)) == 1
                    && count.get("1"+cards[i].charAt(1)) == 1){
                    ok = false;
                }
            }
            index = new int[n];
            long beg = System.currentTimeMillis();
            System.out.println(ok?new B130().search(n-1)?"YES":"NO":"NO");
            long t = System.currentTimeMillis() - beg;
            System.out.println("time " + t);
        }
        cin.close();
    }

    boolean search( int depth){
        if( depth == 0){
            return true;
        }
        boolean res = false;
        if( isok[index[depth-1]][index[depth]]){
            int tmp = index[depth-1];
            index[depth-1] = index[depth];
            res = search(depth-1);
            index[depth-1] = tmp;
        }
        if( res) return res;
        if( isok[index[depth-3]][index[depth]]){
            int tmp = index[depth-3];
            index[depth-3] = index[depth];
            res = search(depth-1);
            index[depth-3] = tmp;
        }
        return res;
    }

}

import java.util.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

public class  Main  {

	//ArrayList<Integer> lis = new ArrayList<Integer>();
	//ArrayList<String> lis = new ArrayList<String>();
	//ArrayList<test> lis = new ArrayList<test>();
//	static long sum=0;
//	static boolean f=false;
	//static String s[],r="";
//	static int dx[]={1,-1,0,0,1,1,-1,-1};
  //  static int dy[]={0,0,1,-1,1,-1,1,-1},n,m,w=0;
	//static int dp[][][][],co,r=0;
	//throws IOException
	//static char c[][];
	static boolean b=false,me[][][][][];

public  static void main(String[] args)  {
   //googlein.txt C-small-attempt0.in
//	Scanner sc =new Scanner(new File("file.txt"));
	 Scanner sc =new Scanner(System.in);
	  //File file = new File("file.txt");
	//	PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter(file)));
	//	sc.useDelimiter("(\\s)+|[,]");

	  while(sc.hasNext()){
		   //long sum=0;
	//	  int n=sc.nextInt(),m=sc.nextInt(),k=sc.nextInt();
		int   n=sc.nextInt();
		b=false;
	//	db((int)sc.next().charAt(0));
      char  c[][]=new char[2][n];
	 me=new boolean [2][100][100][100][n];
		 for(int i=0;i<n;i++){
			 String s=sc.next();
			 c[0][i]=s.charAt(0);
			 c[1][i]=s.charAt(1);
		 }

		 if( n==1 ){ System.out.println("YES");return;}

		 rep(n-1,c);

	  System.out.println(b? "YES":"NO");

		 }

}
	// db("Case #"+(k)+": "+c);
	 //	pw.println("Case #"+(k)+": "+c);

	 	//pw.flush();
	 	//pw.close();

   static void rep(int a,char p[][]){

	   if( b )return;
	   if(a==0){ b=true; return; }
	  // db(p[0],p[1]);

	   if(3<a && me[0][p[0][a-2]][p[0][a-1]][p[0][a]][a] && me[1][p[1][a-2]][p[1][a-1]][p[1][a]][a] )return;

	   if(  p[0][a]==p[0][a-1]   ||  p[1][a]==p[1][a-1]   ){
	   char np[][]=new char[2][a];
	   for(int i=0;i<a;i++){np[0][i]=p[0][i]; np[1][i]=p[1][i];}  np[0][a-1]=p[0][a];np[1][a-1]=p[1][a];
	     rep(a-1,np ); }

	   if(  0<=a-3 && (  p[0][a]==p[0][a-3]  || p[1][a]==p[1][a-3] ) ){
	   char np[][]=new char[2][a];
	   for(int i=0;i<a;i++){np[0][i]=p[0][i]; np[1][i]=p[1][i];}  np[0][a-3]=p[0][a];np[1][a-3]=p[1][a];
	     rep(a-1,np ); }

	 if(3<a)  me[0][p[0][a-2]][p[0][a-1]][p[0][a]][a] = me[1][p[1][a-2]][p[1][a-1]][p[1][a]][a]=true;

   }

    static void db(Object... os){
	         System.err.println(Arrays.deepToString(os));

	}

}

/*class P implements Comparable<P>{
    int v,vv,t;
	P(int v,int vv,int t){
		this.v=v;
	    this.vv=vv;
	    this.t=t;
	}
	  public int compareTo(P x){
          return t-x.t;
	   }

}*/

import java.util.*;
import java.io.*;

public class b {
   static Map<String, Boolean> dp = new HashMap<String, Boolean>();

   static String make(String[] pa) {
      String s = "";
      for(String t : pa)
         s += t + " ";
      return s.trim();
   }

   static boolean is(String s, String t) {
      return s.charAt(0) == t.charAt(0) || s.charAt(1) == t.charAt(1);
   }

   static boolean doit(String[] pa) {
      if(pa.length == 1) return true;
      String s = make(pa);
      if(dp.get(s) != null) return dp.get(s);
      dp.put(s, true);
      boolean r = false;
      int k = pa.length - 1;
      if(k - 1 > 0 && is(pa[k], pa[k - 1])) {
         String[] ne = new String[k];
         System.arraycopy(pa, 0, ne, 0, k);
         ne[k - 1] = pa[k];
         r = r | doit(ne);
      }
      if(k - 3 > 0 && is(pa[k], pa[k - 3])) {
         String[] ne = new String[k];
         System.arraycopy(pa, 0, ne, 0, k);
         pa[k - 3] = pa[k];
         r = r | doit(ne);
      }
      return r;
   }

   public static void main(String[] args) throws IOException {
      //BufferedReader br = new BufferedReader(new FileReader("b.in"));
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      String line = br.readLine();
      int n = Integer.parseInt(line);
      line = br.readLine();
      boolean r = doit(line.split(" "));
      System.out.println((r ? "YES" : "NO"));
   }

   static void debug(Object...o) {
      System.err.println(Arrays.deepToString(o));
   }
}

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.StringTokenizer;

public class B208{
	static final boolean FILE_IO = false;
	static final String output_file = "output.txt";
	static final String input_file = "input.txt";

	public static void main(String[] args){
		InputReader in = new InputReader();
		PrintWriter out;
		if(FILE_IO){
			try{
				out = new PrintWriter(output_file);
			} catch(FileNotFoundException e){
				throw new RuntimeException(e);
			}
		} else {
			out = new PrintWriter(System.out);
		}
		final long start = System.currentTimeMillis();
		new Task1().solve(in, out);
		final long duration = System.currentTimeMillis()-start;
		out.close();
	}

	static class Task1{
		static boolean answer=false;
		boolean[] visited;

		static class Card{
			char digit;
			char suit;
			public Card(String s){
				digit = s.charAt(0);
				suit = s.charAt(1);
				assert (suit=='S' || suit=='D' || suit=='H' || suit=='C'):("Invalid suit: "+suit);
			}

			public boolean equals(Card x){
				return (digit==x.digit)||(suit==x.suit);
			}
		}

		public void solve(InputReader in, PrintWriter out){
			int n=in.nextInt();
			ArrayList<Card> deck = new ArrayList<Card>();

			for(int i=0; i<n; i++){
				String card = in.next();
				deck.add(new Card(card));
			}

			visited = new boolean[n+1];
			solve(deck, n);
			if(answer){
				out.println("YES");
			} else {
				out.println("NO");
			}
		}

		void solve(ArrayList<Card> deck, int n){
			if(visited[n]) return;
			visited[n]=true;
			if(n==1 || answer){
				answer=true;
				return;
			}

			Card last = deck.remove(n-1);
			if(n>=4 && ( deck.get(n-4).equals(last) )){
				ArrayList<Card> copy3 = new ArrayList<Card>(deck);
				copy3.set(n-4, last);
				solve(copy3, n-1);
			}

			if(answer) return;
			if(deck.get(n-2).equals(last)){
				ArrayList<Card> copy1 = new ArrayList<Card>(deck);
				copy1.set(n-2, last);
				solve(copy1, n-1);
			}
		}
	}

	static class InputReader{
		private BufferedReader reader;
		private StringTokenizer tokenizer;

		public InputReader(){
			if(FILE_IO){
				try{
					reader = new BufferedReader(new FileReader(input_file));
				} catch(FileNotFoundException e){
					throw new RuntimeException(e);
				}
			} else {
				reader = new BufferedReader(new InputStreamReader(System.in));
			}
			tokenizer = null;
		}

		public String next(){
			while(tokenizer==null || !tokenizer.hasMoreTokens()){
				try{
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e){
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public int nextInt(){
			return (int)Integer.parseInt(next());
		}

		public long nextLong(){
			return (long)Long.parseLong(next());
		}

		public double nextDouble(){
			return (double)Double.parseDouble(next());
		}

		public String nextLine(){
			String s = null;
			try{
				s = reader.readLine();
			} catch(Exception e){
				throw new RuntimeException(e);
			}
			return s;
		}
	}
}

import java.util.*;

public class B {

	private static class Card {
		char face;
		char val;

		public Card(String value) {
			val = value.charAt(0);
			face = value.charAt(1);
		}

		public boolean canPile(Card c) {
			return (c.face == this.face || c.val == this.val);
		}

		public String toString() {
			return val + "" + face;
		}
	}

	private static Card[] piles;
	private static int n;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		piles = new Card[n];
		for (int i = 0; i < n; i++) {
			piles[i] = new Card(sc.next());
		}

		Card last = piles[n-1];
		for (int i=0; i<n; i++) {
			if (!last.canPile(piles[i])) {
				System.out.println("NO");
				System.exit(0);
			}
		}
		System.out.println("YES");
		System.exit(0);
	}

}

import java.util.Scanner;

public class B {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String[]s = new String[n+1];
        int[]a = new int[n+1], b = new int[n+1];
        for (int i = 1; i <= n; i++) {
            s[i] = sc.next();
            char q = s[i].charAt(0);
            if (q=='A')
                a[i] = 10;
            if (q=='J')
                a[i] = 11;
            if (q=='Q')
                a[i] = 12;
            if (q=='K')
                a[i] = 13;
            if (q=='A')
                a[i] = 14;
            if (q < 'A')
                a[i] = s[i].codePointAt(0)-48;
            char w = s[i].charAt(1);
            if (w=='S')
                b[i] = 1;
            if (w=='D')
                b[i] = 2;
            if (w=='H')
                b[i] =3;
            if (w=='C')
                b[i] = 4;
        }
        boolean[][][]possible = new boolean[n+1][16][5];
        possible[1][a[1]][b[1]] = true;
        for (int i = 2; i <= n; i++) {
            for (int j = 1; j <= 4; j++) {
                if (possible[i-1][a[i]][j]) {
                    possible[i][a[i]][b[i]] = true;
                }
            }
            for (int j = 2; j <= 9; j++) {
                if (possible[i-1][j][b[i]])
                    possible[i][a[i]][b[i]] = true;
            }
            if (i > 3) {
                for (int j = 1; j <= 4; j++) {
                    if (possible[i-3][a[i]][j]) {
                        possible[i][a[i]][b[i]] = true;
                    }
                }
                for (int j = 2; j <= 9; j++) {
                    if (possible[i-3][j][b[i]])
                        possible[i][a[i]][b[i]] = true;
                }
            }
        }
        if (possible[n][a[n]][b[n]])
            System.out.println("YES");
        else
            System.out.println("NO");
    }

}

import java.io.*;
import java.util.*;

import static java.lang.Math.max;
import static java.lang.Math.min;

public class Code implements Runnable {

    public static void main(String[] args) throws IOException {
        new Thread(new Code()).start();
    }

    String[] cards;
    TreeMap<Character, TreeSet<Character>> used[];

    boolean dfs(int pos, int rem, char[][] last) {
        if(rem == 0)    return true;
        int lastElement = -1;
        for(int i = last.length - 1; i >= 0; --i) {
            if(last[i][0] != 0) {
                lastElement = i;
                break;
            }
        }
        char[][] lastCopy = new char[last.length][2];
        for(int i = 0; i < last.length; ++i)    lastCopy[i] = Arrays.copyOf(last[i], 2);
        if(lastElement < 3) {
            if(lastElement > 0) {
                if(last[lastElement][0] == last[lastElement - 1][0] || last[lastElement][1] == last[lastElement - 1][1]) {
                    last[lastElement - 1] = Arrays.copyOf(last[lastElement], 2);
                    last[lastElement][0] = 0;
                    return dfs(pos - 1, rem - 1, last);
                } else  return false;
            } else  return true;
        }

        if(!(used[pos - 1].containsKey(last[lastElement][0]) && used[pos - 1].get(last[lastElement][0]).contains(last[lastElement][1])) &&
          (cards[pos - 1].charAt(0) == last[lastElement][0] || cards[pos - 1].charAt(1) == last[lastElement][1])) {
            if(lastElement != 0)    last[lastElement - 1] = Arrays.copyOf(last[lastElement], 2);
            if(pos - 4 < 0) last[lastElement][0] = 0;
            else {
                for(int i = last.length - 1; i > 0; --i)    last[i] = Arrays.copyOf(last[i - 1], 2);
                last[0][0] = cards[pos - 4].charAt(0);
                last[0][1] = cards[pos - 4].charAt(1);
            }
            if(used[pos - 1].containsKey(last[lastElement][0])) used[pos - 1].get(last[lastElement][0]).add(last[lastElement][1]);
            else {
                used[pos - 1].put(last[lastElement][0], new TreeSet<Character>());
                used[pos - 1].get(last[lastElement][0]).add(last[lastElement][1]);
            }
            if(dfs(pos - 1, rem - 1, last)) return true;
        }
        if(pos - 3 < 0) return false;
        for(int i = 0; i < last.length; ++i)    last[i] = Arrays.copyOf(lastCopy[i], 2);
        if(/*!(used[pos - 3].containsKey(last[lastElement][0]) && used[pos - 3].get(last[lastElement][0]).contains(last[lastElement][1])) &&*/
          (cards[pos - 3].charAt(0) == last[lastElement][0] || cards[pos - 3].charAt(1) == last[lastElement][1])) {
            last[0] = Arrays.copyOf(last[lastElement], 2);
            if(pos - 4 < 0) last[lastElement][0] = 0;
            else {
                for(int i = last.length - 1; i > 0; --i)    last[i] = Arrays.copyOf(last[i - 1], 2);
                last[0][0] = cards[pos - 4].charAt(0);
                last[0][1] = cards[pos - 4].charAt(1);
            }
            /*if(used[pos - 3].containsKey(last[lastElement][0])) used[pos - 3].get(last[lastElement][0]).add(last[lastElement][1]);
            else {
                used[pos - 3].put(last[lastElement][0], new TreeSet<Character>());
                used[pos - 3].get(last[lastElement][0]).add(last[lastElement][1]);
            }                                          */
            return dfs(pos - 1, rem - 1, last);
        }
        return false;
    }

    private void solve() throws IOException {
        int n = nextInt();

        cards = new String[n];
        for(int i = 0; i < n; ++i)  cards[i] = nextToken();

        char[][] last = new char[min(4, n)][2];
        for(int i = max(n - 4, 0); i < n; ++i) {
            last[i - max(n - 4, 0)][0] = cards[i].charAt(0);
            last[i - max(n - 4, 0)][1] = cards[i].charAt(1);
        }
        used = new TreeMap[n];
        for(int i = 0; i < n; ++i)  used[i] = new TreeMap<Character, TreeSet<Character>>();
        writer.println(dfs(n - 1, n - 1, last) ? "YES" : "NO");
    }

    private class Pair<E extends Comparable, V extends Comparable> implements Comparable<Pair<E, V>> {
        public Pair(E first, V second) {
            this.first = first;
            this.second = second;
        }

        @Override
        public int compareTo(Pair<E, V> obj) {
            if(first == obj.first)  return second.compareTo(obj.second);
            return first.compareTo(obj.first);
        }

        @Override
        public boolean equals(Object obj) {
            Pair other = (Pair)obj;
            return first.equals(other.first) && second.equals(other.second);
        }

        public E first;
        public V second;
    }

    @Override
    public void run() {
        try {
            if(in.equals(""))   reader = new BufferedReader(new InputStreamReader(System.in));
            else    reader = new BufferedReader(new FileReader(in));

            if(out.equals(""))  writer = new PrintWriter(new OutputStreamWriter(System.out));
            else    writer = new PrintWriter(new FileWriter(out));
            solve();
        } catch(IOException e) {
            e.printStackTrace();
        } finally {
            try {
                reader.close();
                writer.close();
            } catch(IOException e) {
                e.printStackTrace();
            }
        }
    }

    private int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    private long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    private double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    private float nextFloat() throws IOException {
        return Float.parseFloat(nextToken());
    }

    private String nextToken() throws IOException {
        while(st == null || !st.hasMoreTokens())    st = new StringTokenizer(reader.readLine());
        return st.nextToken();
    }

    private String in = "", out = "";
    private BufferedReader reader;
    private PrintWriter writer;
    private StringTokenizer st;
}

import java.io.*;
import java.math.BigInteger;
import java.util.HashMap;
import java.util.InputMismatchException;

public class Main {
	public static void main(String[] args) {
		long time_beg = -1;
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		if (args.length > 0 && args[0].equals("outside")) {
			time_beg = System.currentTimeMillis();
			try {
				inputStream = new FileInputStream("io/in.txt");
//				outputStream = new FileOutputStream("io/out.txt");
			} catch (Exception e) {
				System.err.println(e);
				System.exit(1);
			}
		} else {
//			try {
//				inputStream = new FileInputStream("file_name");
//				outputStream = new FileOutputStream("file_name");
//			} catch (Exception e) {
//				System.err.println(e);
//				System.exit(1);
//			}
		}
		Solver s = new Solver();
		s.in = new InputReader(inputStream);
		s.out = new OutputWriter(outputStream);
		s.solve();
		s.out.close();
		if (args.length > 0 && args[0].equals("outside")) {
			System.err.printf("*** Total time: %.3f ***\n", (System.currentTimeMillis() - time_beg) / 1000.0);
		}
	}
}

class OutputWriter {
	private final PrintWriter writer;

	public OutputWriter(OutputStream outputStream) {
		writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
	}

	public OutputWriter(Writer writer) {
		this.writer = new PrintWriter(writer);
	}

	public void print(Object... objects) {
		for (int i = 0; i < objects.length; i++) {
			if (i != 0)
				writer.print(' ');
			writer.print(objects[i]);
		}
	}

	public void printLine(Object... objects) {
		print(objects);
		writer.println();
	}

	public void printLine(char[] array) {
		writer.println(array);
	}

	public void printFormat(String format, Object... objects) {
		writer.printf(format, objects);
	}

	public void close() {
		writer.close();
	}

	public void flush() {
		writer.flush();
	}
}

class InputReader {
	private boolean finished = false;

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	private int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int peek() {
		if (numChars == -1)
			return -1;
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				return -1;
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar];
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public long readLong() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public static boolean isSpaceChar(int c) {
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	private String readLine0() {
		StringBuilder buf = new StringBuilder();
		int c = read();
		while (c != '\n' && c != -1) {
			if (c != '\r')
				buf.appendCodePoint(c);
			c = read();
		}
		return buf.toString();
	}

	public String readLine() {
		String s = readLine0();
		while (s.trim().length() == 0)
			s = readLine0();
		return s;
	}

	public String readLine(boolean ignoreEmptyLines) {
		if (ignoreEmptyLines)
			return readLine();
		else
			return readLine0();
	}

	public BigInteger readBigInteger() {
		try {
			return new BigInteger(readString());
		} catch (NumberFormatException e) {
			throw new InputMismatchException();
		}
	}

	public char readCharacter() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		return (char) c;
	}

	public double readDouble() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		double res = 0;
		while (!isSpaceChar(c) && c != '.') {
			if (c == 'e' || c == 'E')
				return res * Math.pow(10, readInt());
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		}
		if (c == '.') {
			c = read();
			double m = 1;
			while (!isSpaceChar(c)) {
				if (c == 'e' || c == 'E')
					return res * Math.pow(10, readInt());
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				m /= 10;
				res += (c - '0') * m;
				c = read();
			}
		}
		return res * sgn;
	}

	public boolean isExhausted() {
		int value;
		while (isSpaceChar(value = peek()) && value != -1)
			read();
		return value == -1;
	}
}

class Solver {
	InputReader in;
	OutputWriter out;

	void solve() {
		dp = new int[64][64][64][64];
		fill(dp, -1);

		char[] a = {'2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A'};
		char[] b = {'S', 'D', 'H', 'C'};
		MAP = new HashMap<>();
		RMAP = new HashMap<>();
		for (int j = 0; j < a.length; ++j)
			for (int i = 0; i < b.length; ++i) {
				String s = String.valueOf(a[j]) + String.valueOf(b[i]);
				MAP.put(s, j * b.length + i);
				RMAP.put(j * b.length + i, s);
			}

		int n = in.readInt();
		mas = new int[n];
		for (int i = 0; i < n; ++i)
			mas[i] = MAP.get(in.readString());

		if (mas.length < 3) {
			if (mas.length == 1) out.printLine("YES");
			else {
				if (RMAP.get(mas[0]).charAt(0) == RMAP.get(mas[1]).charAt(0)
						|| RMAP.get(mas[0]).charAt(1) == RMAP.get(mas[1]).charAt(1))
					out.printLine("YES");
				else out.printLine("NO");
			}
			return;
		}

		if (rec(n - 1, mas[n - 3], mas[n - 2], mas[n - 1]) == 1) out.printLine("YES");
		else out.printLine("NO");
	}

	HashMap<String, Integer> MAP;
	HashMap<Integer, String> RMAP;
	int[] mas;

	int rec(int pos, int v1, int v2, int v3) {
		if (dp[pos][v1][v2][v3] != -1) return dp[pos][v1][v2][v3];
		if (pos == 0) return dp[pos][v1][v2][v3] = 1;

		String s1 = RMAP.get(mas[pos]);
		// -1
		String s2 = RMAP.get(v3);
		if (s1.charAt(0) == s2.charAt(0) || s1.charAt(1) == s2.charAt(1)) {
			int nv1 = v1;
			if (pos >= 3) nv1 = mas[pos - 3];
			int nv2 = v2;
			if (pos >= 2) nv2 = mas[pos - 2];
			int nv3 = mas[pos];
			if (rec(pos - 1, nv1, nv2, nv3) == 1)
				return dp[pos][v1][v2][v3] = 1;
		}

		// -3
		if (pos >= 3) {
			s2 = RMAP.get(mas[pos - 3]);
			if (s1.charAt(0) == s2.charAt(0) || s1.charAt(1) == s2.charAt(1)) {
				int nv1 = mas[pos];
				int nv2 = mas[pos - 2];
				int nv3 = mas[pos - 1];
				if (rec(pos - 1, nv1, nv2, nv3) == 1)
					return dp[pos][v1][v2][v3] = 1;
			}
		}

		return dp[pos][v1][v2][v3] = 0;
	}

	int[][][][] dp;

	public static void fill(int[] array, int value) {
		for (int i = 0; i < array.length; ++i)
			array[i] = value;
	}

	public static void fill(int[][] array, int value) {
		for (int i = 0; i < array.length; ++i)
			fill(array[i], value);
	}

	public static void fill(int[][][] array, int value) {
		for (int i = 0; i < array.length; ++i)
			fill(array[i], value);
	}

	public static void fill(int[][][][] array, int value) {
		for (int i = 0; i < array.length; ++i)
			fill(array[i], value);
	}
}

import java.io.*;
import java.util.*;

import static java.lang.Math.cos;
import static java.lang.Math.max;
import static java.lang.Math.min;

public class Code implements Runnable {

    public static void main(String[] args) throws IOException {
        new Thread(new Code()).start();
    }

    String[] cards;

    boolean dfs(int pos, int rem, char[][] last) {
        if(rem == 0)    return true;
        boolean res = false;
        int lastElement = -1;
        for(int i = last.length - 1; i >= 0; --i) {
            if(last[i][0] != 0) {
                lastElement = i;
                break;
            }
        }
        char[][] lastCopy = new char[last.length][2];
        for(int i = 0; i < last.length; ++i)    lastCopy[i] = Arrays.copyOf(last[i], 2);

        if(cards[pos - 1].charAt(0) == last[lastElement][0] || cards[pos - 1].charAt(1) == last[lastElement][1]) {
            if(lastElement != 0)    last[lastElement - 1] = Arrays.copyOf(last[lastElement], 2);
            if(pos - 4 < 0) last[lastElement][0] = 0;
            else {
                for(int i = last.length - 1; i > 0; --i)    last[i] = Arrays.copyOf(last[i - 1], 2);
                last[0][0] = cards[pos - 4].charAt(0);
                last[0][1] = cards[pos - 4].charAt(1);
            }
            res = dfs(pos - 1, rem - 1, last);
        }
        if(res) return true;
        if(pos - 3 < 0) return false;
        for(int i = 0; i < last.length; ++i)    last[i] = Arrays.copyOf(lastCopy[i], 2);
        if(cards[pos - 3].charAt(0) == last[lastElement][0] || cards[pos - 3].charAt(1) == last[lastElement][1]) {
            last[0] = Arrays.copyOf(last[lastElement], 2);
            if(pos - 4 < 0) last[lastElement][0] = 0;
            else {
                for(int i = last.length - 1; i > 0; --i)    last[i] = Arrays.copyOf(last[i - 1], 2);
                last[0][0] = cards[pos - 3].charAt(0);
                last[0][1] = cards[pos - 3].charAt(1);
            }
            return dfs(pos - 1, rem - 1, last);
        }
        return false;
    }

    private void solve() throws IOException {
        int n = nextInt();

        cards = new String[n];
        for(int i = 0; i < n; ++i)  cards[i] = nextToken();

        char[][] last = new char[min(4, n)][2];
        for(int i = max(n - 4, 0); i < n; ++i) {
            last[i - max(n - 4, 0)][0] = cards[i].charAt(0);
            last[i - max(n - 4, 0)][1] = cards[i].charAt(1);
        }
        writer.println(dfs(n - 1, n - 1, last) ? "YES" : "NO");
    }

    private class Pair<E extends Comparable, V extends Comparable> implements Comparable<Pair<E, V>> {
        public Pair(E first, V second) {
            this.first = first;
            this.second = second;
        }

        @Override
        public int compareTo(Pair<E, V> obj) {
            if(first == obj.first)  return second.compareTo(obj.second);
            return first.compareTo(obj.first);
        }

        @Override
        public boolean equals(Object obj) {
            Pair other = (Pair)obj;
            return first.equals(other.first) && second.equals(other.second);
        }

        public E first;
        public V second;
    }

    @Override
    public void run() {
        try {
            if(in.equals(""))   reader = new BufferedReader(new InputStreamReader(System.in));
            else    reader = new BufferedReader(new FileReader(in));

            if(out.equals(""))  writer = new PrintWriter(new OutputStreamWriter(System.out));
            else    writer = new PrintWriter(new FileWriter(out));
            solve();
        } catch(IOException e) {
            e.printStackTrace();
        } finally {
            try {
                reader.close();
                writer.close();
            } catch(IOException e) {
                e.printStackTrace();
            }
        }
    }

    private int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    private long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    private double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    private float nextFloat() throws IOException {
        return Float.parseFloat(nextToken());
    }

    private String nextToken() throws IOException {
        while(st == null || !st.hasMoreTokens())    st = new StringTokenizer(reader.readLine());
        return st.nextToken();
    }

    private String in = "", out = "";
    private BufferedReader reader;
    private PrintWriter writer;
    private StringTokenizer st;
}

import java.util.*;

public class T208B {
	public static Set<String> mem;

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n_cards = in.nextInt();
		String cards = "";
		for (int i = 0; i < n_cards; ++i) cards += in.next();
		mem = new TreeSet<String>();
		if (recurse(cards, n_cards * 2)) System.out.println("YES");
		else System.out.println("NO");
	}

	public static boolean recurse(String s, int n) {
		if (n == 2) return true;
		if (mem.contains(s)) return false;
		mem.add(s);

		if (n >= 4)
			if (s.charAt(n - 2) == s.charAt(n - 4) || s.charAt(n - 1) == s.charAt(n - 3)) {
				String nx = s.substring(0, n - 4) + s.substring(n - 2);
				if (recurse(nx, n - 2)) return true;
			}
		if (n >= 8)
			if (s.charAt(n - 2) == s.charAt(n - 8) || s.charAt(n - 1) == s.charAt(n - 7)) {
				String nx = s.substring(0, n - 7) + s.substring(n - 2) + s.substring(n - 6, n - 2);
				if (recurse(nx, n - 2)) return true;
			}

		return false;
	}
}

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Round130_B {
    static int N;
    static String[] a;
    static Boolean dp[][][][];

    public static boolean go(int cur, int a, int b, int c) {
        if (cur == 1)
            return (ch(c, b));

        if (dp[cur][a][b][c] != null)
            return dp[cur][a][b][c];

        boolean ret = false;
        if (cur > 2 && ch(cur - 3, c))
            ret = go(cur - 1, c, a, b);
        if (ret)
            return dp[cur][a][b][c] = ret;

        if (ch(c, b))
            ret = go(cur - 1, cur - 3, a, b);

        return dp[cur][a][b][c] = ret;

    }

    private static boolean ch(int i, int j) {
        return a[i].charAt(0) == a[j].charAt(0)
                || a[i].charAt(1) == a[j].charAt(1);

    }

    public static void main(String[] args) throws Exception {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

        N = Integer.parseInt(in.readLine());
        a = in.readLine().split(" ");
        if (N == 1)
            System.out.println("YES");
        else {
            dp = new Boolean[N + 2][N + 2][N + 2][N + 2];

            System.out.println((go(N - 1, N - 3, N - 2, N - 1) ? "YES" : "NO"));
        }

    }
}

import sun.reflect.generics.tree.Tree;

import java.util.Scanner;
import java.util.*;

public class Main
{
    static Scanner in = new Scanner( System.in );

    static class State
    {
        int size;
        String first;
        String second;
        String third;
        State( int arg1, String arg2, String arg3, String arg4 )
        {
            size = arg1;
            first = arg2;
            second = arg3;
            third = arg4;
        }
    }

    static boolean equals( String arg1, String arg2 )
    {
        if ( arg1.charAt( 0 ) == arg2.charAt( 0 ) || arg1.charAt( 1 ) == arg2.charAt( 1 ) ) return true;
        else return false;
    }

    static class StateComparator implements Comparator < State >
    {
        public int compare( State arg1, State arg2 )
        {
            if ( arg1.size != arg2.size ) return arg1.size - arg2.size;
            else if ( arg1.first.compareTo( arg2.first ) != 0 ) return arg1.first.compareTo( arg2.first );
            else if ( arg1.second.compareTo( arg2.second ) != 0 ) return arg1.second.compareTo( arg2.second );
            else return arg1.third.compareTo( arg2.third );
        }
    }

    public static void main( String[] args )
    {
        int cardsN = Integer.parseInt(in.nextLine());
        List < String > cards = new ArrayList();
        StringTokenizer input = new StringTokenizer( in.nextLine() );
        for ( int i = 0; i < cardsN; i++ )
        {
            cards.add( input.nextToken() );
        }

        Queue < List < String > > workQ = new LinkedList();
        Map < State, Boolean > states = new TreeMap( new StateComparator() );
        workQ.offer( cards );

        if ( cards.size() < 4 ) if ( equals(cards.get(0), cards.get(cards.size() - 1)) ) { System.out.println( "YES" ); return; }
        else { System.out.println( "NO" ); return; }

        states.put( new State( cardsN, cards.get( cardsN - 3 ), cards.get( cardsN - 2 ), cards.get( cardsN - 1 ) ), true );

        while ( !workQ.isEmpty() )
        {
            List < String > curList1 = new LinkedList < String > ();
            List < String > curList2 = new LinkedList < String > ();
            for ( String element : workQ.poll() )
            {
                curList1.add( new String( element ) );
                curList2.add( new String( element ) );
            }
            if ( curList1.size() == 1 ) { System.out.println( "YES" ); return; }

            if ( curList1.size() - 2 >= 0 && curList1.size() > 3 && equals( curList1.get( curList1.size() - 1 ), curList1.get( curList1.size() - 2 ) ) )
            {
                int s = curList1.size();
                curList1.add( s - 2, curList1.get(s - 1) );
                curList1.remove( s - 1 );
                curList1.remove( s - 1 ); s--;
                State curState = new State( s, curList1.get( s - 3 ), curList1.get( s - 2 ), curList1.get( s - 1 ) );
                if ( states.get( curState ) == null )
                {
                    states.put( curState, true );
                    workQ.offer( curList1 );
                }
            }
            if ( curList2.size() - 4 >= 0 && curList2.size() > 3 && equals( curList2.get( curList2.size() - 1 ), curList2.get( curList2.size() - 4 ) ) )
            {
                int s = curList2.size();
                curList2.add( s - 4, curList2.get(s - 1) );
                curList2.remove( s - 3 );
                curList2.remove( s - 1 ); s--;
                State curState = new State( s, curList2.get( s - 3 ), curList2.get( s - 2 ), curList2.get( s - 1 ) );
                if ( states.get( curState ) == null )
                {
                    states.put( curState, true );
                    workQ.offer( curList2 );
                }
            }
            if ( curList1.size() < 4 ) if ( equals( curList1.get( 0 ), curList1.get( 2 ) ) ) { System.out.println( "YES" ); return; }
            if ( curList2.size() < 4 ) if ( equals( curList2.get( 0 ), curList2.get( 2 ) ) ) { System.out.println( "YES" ); return; }
        }
        System.out.println("NO");
    }
}

import java.util.*;

public class B {

	private static class Card {
		char face;
		char val;

		public Card(String value) {
			val = value.charAt(0);
			face = value.charAt(1);
		}

		public Card(Card c) {
			this.val = new Character(c.val);
			this.face = new Character(c.face);
		}

		public boolean canPile(Card c) {
			return (c.face == this.face || c.val == this.val);
		}

		public String toString() {
			return val + "" + face;
		}
	}

	private static Card[] piles;
	private static int n;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		piles = new Card[n];
		for (int i = 0; i < n; i++) {
			piles[i] = new Card(sc.next());
		}

		//Do x-1 as much as possible.
		int found = 0;
		for (int i=n-1; i>=0; i--) {
			if (i-1 >= 0) {
				if (piles[i].canPile(piles[i-1])) {
					piles[i-1] = piles[i];
					found++;
				}
			}
		}
		piles = Arrays.copyOfRange(piles,0,n-found);
		n = n-found;

		dfs(0, n - 1);
		System.out.println("NO");
		System.exit(0);
	}

	private static void dfs(int count, int idx) {
		if (idx < 0) {
			return;
		}

		if (count == n - 1) {
			System.out.println("YES");
			System.exit(0);
		}

		if (idx - 1 > -1 && piles[idx - 1] != null) {
			if (piles[idx].canPile(piles[idx - 1])) {
				Card B = piles[idx - 1];
				piles[idx - 1] = piles[idx];
				piles[idx] = null;
				dfs(count + 1, idx - 1);
				piles[idx] = piles[idx - 1];
				piles[idx - 1] = B;
			}
		}

		if (idx - 3 > -1 && piles[idx - 3] != null) {
			if (piles[idx].canPile(piles[idx - 3])) {
				Card B = piles[idx - 3];
				piles[idx - 3] = piles[idx];
				piles[idx] = null;
				dfs(count + 1, idx - 1);
				piles[idx] = piles[idx - 3];
				piles[idx - 3] = B;
			}
		}
	}
}

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.StringTokenizer;

public class B208{
	static final boolean FILE_IO = false;
	static final String output_file = "output.txt";
	static final String input_file = "input.txt";

	public static void main(String[] args){
		InputReader in = new InputReader();
		PrintWriter out;
		if(FILE_IO){
			try{
				out = new PrintWriter(output_file);
			} catch(FileNotFoundException e){
				throw new RuntimeException(e);
			}
		} else {
			out = new PrintWriter(System.out);
		}
		final long start = System.currentTimeMillis();
		new Task1().solve(in, out);
		final long duration = System.currentTimeMillis()-start;
		out.close();
	}

	static class Task1{
		static boolean answer=false;
		HashMap<Marker, Boolean> visited;

		static class Marker{
			String last, preLast, prepreLast;
			Integer size, hash;

			public Marker(int size, String last, String preLast){
				this.size=size;
				this.last=last;
				this.preLast=preLast;
				//this.prepreLast=prepreLast;
			}

			public int hashCode(){
				if(hash!=null) return hash;
				hash = size;
				hash = hash*31 + last.hashCode();
				hash = hash*31 + preLast.hashCode();
				//hash = hash*31 + prepreLast.hashCode();
				return hash;
			}

			public boolean equals(Object temp){
				Marker o = (Marker)temp;
				return(
						size.equals(o.size) &&
						last.equals(o.last) &&
						preLast.equals(o.preLast)
					);
			}
		}

		public void solve(InputReader in, PrintWriter out){
			int n=in.nextInt();
			ArrayList<String> deck = new ArrayList<String>();

			for(int i=0; i<n; i++){
				deck.add(in.next());
			}

			visited = new HashMap<Marker, Boolean>();
			solve(deck, n);
			if(answer){
				out.println("YES");
			} else {
				out.println("NO");
			}
		}

		boolean match(String a, String b){
			return (a.charAt(0)==b.charAt(0) || a.charAt(1)==b.charAt(1));
		}

		void solve(ArrayList<String> deck, int n){
			if(n==1 || answer){
				answer=true;
				return;
			}

			Marker mm;
			String last = deck.remove(n-1);
			if(n>1){
				String _preLast = deck.get(n-2);
				mm = new Marker(n, last, _preLast);
			}
			else {
				mm = new Marker(n, last, "");
			}
			if(visited.containsKey(mm)){
				return;
			}
			visited.put(mm, true);

			if(n>1 && match(deck.get(n-2),last)){
				ArrayList<String> copy1 = new ArrayList<String>(deck);
				copy1.set(n-2, last);
				solve(copy1, n-1);
			}

			if(n>3 && match(deck.get(n-4),last) ){
				ArrayList<String> copy3 = new ArrayList<String>(deck);
				copy3.set(n-4, last);
				solve(copy3, n-1);
			}
		}
	}

	static class InputReader{
		private BufferedReader reader;
		private StringTokenizer tokenizer;

		public InputReader(){
			if(FILE_IO){
				try{
					reader = new BufferedReader(new FileReader(input_file));
				} catch(FileNotFoundException e){
					throw new RuntimeException(e);
				}
			} else {
				reader = new BufferedReader(new InputStreamReader(System.in));
			}
			tokenizer = null;
		}

		public String next(){
			while(tokenizer==null || !tokenizer.hasMoreTokens()){
				try{
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e){
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public int nextInt(){
			return (int)Integer.parseInt(next());
		}

		public long nextLong(){
			return (long)Long.parseLong(next());
		}

		public double nextDouble(){
			return (double)Double.parseDouble(next());
		}

		public String nextLine(){
			String s = null;
			try{
				s = reader.readLine();
			} catch(Exception e){
				throw new RuntimeException(e);
			}
			return s;
		}
	}
}

import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import java.io.*;
import java.math.*;
import java.text.*;
import java.util.*;

/*
br = new BufferedReader(new FileReader("input.txt"));
pw = new PrintWriter(new BufferedWriter(new FileWriter("output.txt")));
br = new BufferedReader(new InputStreamReader(System.in));
pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
 */

public class Main {
  private static BufferedReader br;
  private static StringTokenizer st;
  private static PrintWriter pw;

  static String[] list;

  public static void main(String[] args) throws IOException {
    br = new BufferedReader(new InputStreamReader(System.in));
    pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    //int qq = 1;
    int qq = Integer.MAX_VALUE;
    //int qq = readInt();
    for(int casenum = 1; casenum <= qq; casenum++)  {
      int n = readInt();
      seen = new HashSet<Integer>();
      list = new String[n];
      for(int i = 0; i < n; i++) {
        list[i] = nextToken();
      }
      pw.println(can(n-1) ? "YES" : "NO");
    }
    pw.close();
  }

  public static boolean can(int n) {
    if(n==0) {
      return true;
    }
    int hash = hash(n);
    if(!seen.add(hash)) return false;
    if(list[n].charAt(0) == list[n-1].charAt(0) || list[n].charAt(1) == list[n-1].charAt(1)) {
      String save = list[n-1];
      list[n-1] = list[n];
      if(can(n-1)) {
        return true;
      }
      list[n-1] = save;
    }
    if(n-3 >= 0 && (list[n].charAt(0) == list[n-3].charAt(0) || list[n].charAt(1) == list[n-3].charAt(1))) {
      String save = list[n-3];
      list[n-3] = list[n];
      if(can(n-3)) {
        return true;
      }
      list[n-3] = save;
    }
    return false;
  }

  static Set<Integer> seen;

  public static int hash(int n) {
    int ret = 0;
    for(int i = 0; i <= n; i++) {
      ret *= 3137;
      ret += list[i].hashCode();
    }
    return ret;
  }

  private static void exitImmediately() {
    pw.close();
    System.exit(0);
  }

  private static long readLong() throws IOException {
    return Long.parseLong(nextToken());
  }

  private static double readDouble() throws IOException {
    return Double.parseDouble(nextToken());
  }

  private static int readInt() throws IOException {
    return Integer.parseInt(nextToken());
  }

  private static String nextToken() throws IOException  {
    while(st == null || !st.hasMoreTokens())  {
      if(!br.ready()) {
        exitImmediately();
      }
      st = new StringTokenizer(br.readLine().trim());
    }
    return st.nextToken();
  }
}

import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.BufferedWriter;
import java.util.Locale;
import java.util.InputMismatchException;
import java.io.OutputStream;
import java.util.ArrayDeque;
import java.io.PrintWriter;
import java.io.Writer;
import java.util.Queue;
import java.util.Collection;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Jacob Jiang
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		OutputWriter out = new OutputWriter(outputStream);
		TaskB solver = new TaskB();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskB {
	public void solve(int testNumber, InputReader in, OutputWriter out) {
        int n = in.nextInt();
        String[] cards = in.nextStringArray(n);
        tag:
        for (int i = 1; i < n; i++) {
            String current = cards[i];
            Queue<Integer> queue = new ArrayDeque<Integer>();
            boolean[] visited = new boolean[n];
            queue.offer(i);
            visited[i] = true;
            while (!queue.isEmpty()) {
                int pos = queue.poll();
                visited[pos] = false;
                if (pos == 0) {
                    continue tag;
                }
                if (pos >= 1 && match(current, cards[pos - 1])) {
                    queue.add(pos - 1);
                    visited[pos - 1] = true;
                }
                if (pos >= 3 && match(current, cards[pos - 3])) {
                    queue.add(pos - 3);
                    visited[pos - 3] = true;
                }
            }
            out.println("NO");
            return;
        }
        out.println("YES");
    }

    private boolean match(String s1, String s2) {
        return s1.charAt(0) == s2.charAt(0) || s1.charAt(1) == s2.charAt(1);
    }

}

class InputReader {

    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;

    public InputReader(InputStream stream) {
        this.stream = stream;
    }

    public int read() {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    public int nextInt() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        int res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c & 15;
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public String next() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        StringBuilder res = new StringBuilder();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isSpaceChar(c));
        return res.toString();
    }

    public static boolean isSpaceChar(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    public String[] nextStringArray(int count) {
        String[] result = new String[count];
        for (int i = 0; i < count; i++) {
            result[i] = next();
        }
        return result;
    }

    }

class OutputWriter {
    private PrintWriter writer;

    public OutputWriter(OutputStream stream) {
        writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(stream)));
    }

    public OutputWriter(Writer writer) {
        this.writer = new PrintWriter(writer);
    }

    public void println(String x) {
        writer.println(x);
    }

    public void close() {
        writer.close();
    }

    }

import java.util.*;
import java.io.*;
public class a {
  static long mod  = 1000000007;
public static void main(String[] args) throws IOException
{
  input.init(System.in);
  PrintWriter out = new PrintWriter(new PrintStream(System.out));
  //input.init(new FileInputStream(new File("input.txt")));
  //PrintWriter out = new PrintWriter(new File("output.txt"));
  int n = input.nextInt();
  char[] nums = new char[n];
  char[] suits = new char[n];
  for(int i = 0; i<n; i++)
  {
    String s = input.next();
    nums[i] = s.charAt(0);
    suits[i] = s.charAt(1);
  }
  boolean okay = true;
  for(int i = 0; i<n; i++)
  {
    int cn = 0, cs = 0;
    for(int j = 0; j<n; j++)
    {
      if(nums[i] == nums[j]) cn++;
      if(suits[i] == suits[j]) cs++;
    }
    okay &= (cn>1 || cs>1);
  }
  out.println(okay?"YES":"NO");

  out.close();
}
static class Person implements Comparable<Person>
{
  String name;
  int h;
  public Person(String n, int hh)
  {
    name = n;
    h = hh;
  }
  /* (non-Javadoc)
   * @see java.lang.Comparable#compareTo(java.lang.Object)
   */
  @Override
  public int compareTo(Person o) {
    // TODO(mkirsche): Auto-generated method stub
    return this.h - o.h;
  }
}
static long[][] comb(int n)
{
  long[][] res = new long[n+1][n+1];
  Arrays.fill(res[0], 0);
  for(int i = 0; i<=n; i++) res[i][0] = 1;
  for(int i = 1; i<=n; i++)
    for(int j = 1; j<=n; j++)
      res[i][j] = (res[i-1][j-1] + res[i-1][j])%mod;
  return res;
}
static long gcd(long a, long b)
{
  if(b==0) return a;
  return gcd(b, a%b);
}
static long pow(long a, long p)
{
  if(p<=0) return 1;
  if((p&1) == 0)
  {
    long sqrt = pow(a, p/2);
    return (sqrt*sqrt)%mod;
  }
  else
    return (a*pow(a,p-1))%mod;
}
static class input {
  static BufferedReader reader;
  static StringTokenizer tokenizer;

  /** call this method to initialize reader for InputStream */
  static void init(InputStream input) {
      reader = new BufferedReader(
                   new InputStreamReader(input) );
      tokenizer = new StringTokenizer("");
  }

  /**
   * @return
   */
  public static boolean hasNext() {
    // TODO(mkirsche): Auto-generated method stub
    return tokenizer.hasMoreTokens();
  }

  /** get next word */
  static String next() throws IOException {
      while ( ! tokenizer.hasMoreTokens() ) {
          //TODO add check for eof if necessary
          tokenizer = new StringTokenizer(
                 reader.readLine() );
      }
      return tokenizer.nextToken();
  }

  static int nextInt() throws IOException {
      return Integer.parseInt( next() );
  }
  static long nextLong() throws IOException {
    return Long.parseLong( next() );
}

  static double nextDouble() throws IOException {
      return Double.parseDouble( next() );
  }
  static String nextLine() throws IOException {
    return reader.readLine();
  }
}
}

import java.io.*;

public class CF208B {
	static int translate(char c) {
		switch (c) {
			case 'S': return 0;
			case 'D': return 1;
			case 'H': return 2;
			case 'C': return 3;
			case 'T': return 10;
			case 'J': return 11;
			case 'Q': return 12;
			case 'K': return 0;
			case 'A': return 1;
			default: return c - '0';
		}
	}
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		char[] aa = br.readLine().toCharArray();
		int[] vv = new int[n];
		int[] ss = new int[n];
		for (int i = 0; i < n; i++) {
			vv[i] = translate(aa[i * 3]);
			ss[i] = translate(aa[i * 3 + 1]);
		}
		if (n == 1) {
			System.out.println("YES");
			return;
		}
		if (n == 2) {
			System.out.println(vv[0] == vv[1] || ss[0] == ss[1] ? "YES" : "NO");
			return;
		}
		boolean[][][][][][][] dp = new boolean[n][13][4][13][4][13][4];
		for (int v2 = 0; v2 < 13; v2++)
			for (int s2 = 0; s2 < 4; s2++)
				for (int v1 = 0; v1 < 13; v1++)
					for (int s1 = 0; s1 < 4; s1++)
						for (int v0 = 0; v0 < 13; v0++)
							for (int s0 = 0; s0 < 4; s0++)
								dp[2][v2][s2][v1][s1][v0][s0] = (v1 == v0 || s1 == s0) && (v2 == v0 || s2 == s0);
		for (int i = 3; i < n; i++) {
			int v3 = vv[i - 3];
			int s3 = ss[i - 3];
			for (int v2 = 0; v2 < 13; v2++)
				for (int s2 = 0; s2 < 4; s2++)
					for (int v1 = 0; v1 < 13; v1++)
						for (int s1 = 0; s1 < 4; s1++)
							for (int v0 = 0; v0 < 13; v0++)
								for (int s0 = 0; s0 < 4; s0++)
									dp[i][v2][s2][v1][s1][v0][s0] = dp[i - 1][v3][s3][v2][s2][v0][s0] || dp[i - 1][v0][s0][v2][s2][v1][s1];
		}
		System.out.println(dp[n - 1][vv[n - 3]][ss[n - 3]][vv[n - 2]][ss[n - 2]][vv[n - 1]][ss[n - 1]] ? "YES" : "NO");
	}
}

import java.io.*;
import java.util.*;

import static java.lang.Math.max;
import static java.lang.Math.min;

public class Code implements Runnable {

    public static void main(String[] args) throws IOException {
        new Thread(new Code()).start();
    }

    String[] cards;
    TreeMap<Character, TreeSet<Character>> used[];

    boolean dfs(int pos, int rem, char[][] last) {
        if(rem == 0)    return true;
        int lastElement = -1;
        for(int i = last.length - 1; i >= 0; --i) {
            if(last[i][0] != 0) {
                lastElement = i;
                break;
            }
        }
        char[][] lastCopy = new char[last.length][2];
        for(int i = 0; i < last.length; ++i)    lastCopy[i] = Arrays.copyOf(last[i], 2);
        if(lastElement < 3) {
            if(lastElement > 0) {
                if(last[lastElement][0] == last[lastElement - 1][0] || last[lastElement][1] == last[lastElement - 1][1]) {
                    last[lastElement - 1] = Arrays.copyOf(last[lastElement], 2);
                    last[lastElement][0] = 0;
                    return dfs(pos - 1, rem - 1, last);
                } else  return false;
            } else  return true;
        }

        if(!(used[pos - 1].containsKey(last[lastElement][0]) && used[pos - 1].get(last[lastElement][0]).contains(last[lastElement][1])) &&
          (cards[pos - 1].charAt(0) == last[lastElement][0] || cards[pos - 1].charAt(1) == last[lastElement][1])) {
            if(lastElement != 0)    last[lastElement - 1] = Arrays.copyOf(last[lastElement], 2);
            if(pos - 4 < 0) last[lastElement][0] = 0;
            else {
                for(int i = last.length - 1; i > 0; --i)    last[i] = Arrays.copyOf(last[i - 1], 2);
                last[0][0] = cards[pos - 4].charAt(0);
                last[0][1] = cards[pos - 4].charAt(1);
            }
            if(used[pos - 1].containsKey(last[lastElement][0])) used[pos - 1].get(last[lastElement][0]).add(last[lastElement][1]);
            else {
                used[pos - 1].put(last[lastElement][0], new TreeSet<Character>());
                used[pos - 1].get(last[lastElement][0]).add(last[lastElement][1]);
            }
            if(dfs(pos - 1, rem - 1, last)) return true;
        }
        if(pos - 3 < 0) return false;
        for(int i = 0; i < last.length; ++i)    last[i] = Arrays.copyOf(lastCopy[i], 2);
        if(!(used[pos - 3].containsKey(last[lastElement][0]) && used[pos - 3].get(last[lastElement][0]).contains(last[lastElement][1])) &&
          (cards[pos - 3].charAt(0) == last[lastElement][0] || cards[pos - 3].charAt(1) == last[lastElement][1])) {
            last[0] = Arrays.copyOf(last[lastElement], 2);
            if(pos - 4 < 0) last[lastElement][0] = 0;
            else {
                for(int i = last.length - 1; i > 0; --i)    last[i] = Arrays.copyOf(last[i - 1], 2);
                last[0][0] = cards[pos - 4].charAt(0);
                last[0][1] = cards[pos - 4].charAt(1);
            }
            if(used[pos - 3].containsKey(last[lastElement][0])) used[pos - 3].get(last[lastElement][0]).add(last[lastElement][1]);
            else {
                used[pos - 3].put(last[lastElement][0], new TreeSet<Character>());
                used[pos - 3].get(last[lastElement][0]).add(last[lastElement][1]);
            }
            return dfs(pos - 1, rem - 1, last);
        }
        return false;
    }

    private void solve() throws IOException {
        int n = nextInt();

        cards = new String[n];
        for(int i = 0; i < n; ++i)  cards[i] = nextToken();

        char[][] last = new char[min(4, n)][2];
        for(int i = max(n - 4, 0); i < n; ++i) {
            last[i - max(n - 4, 0)][0] = cards[i].charAt(0);
            last[i - max(n - 4, 0)][1] = cards[i].charAt(1);
        }
        used = new TreeMap[n];
        for(int i = 0; i < n; ++i)  used[i] = new TreeMap<Character, TreeSet<Character>>();
        writer.println(dfs(n - 1, n - 1, last) ? "YES" : "NO");
    }

    private class Pair<E extends Comparable, V extends Comparable> implements Comparable<Pair<E, V>> {
        public Pair(E first, V second) {
            this.first = first;
            this.second = second;
        }

        @Override
        public int compareTo(Pair<E, V> obj) {
            if(first == obj.first)  return second.compareTo(obj.second);
            return first.compareTo(obj.first);
        }

        @Override
        public boolean equals(Object obj) {
            Pair other = (Pair)obj;
            return first.equals(other.first) && second.equals(other.second);
        }

        public E first;
        public V second;
    }

    @Override
    public void run() {
        try {
            if(in.equals(""))   reader = new BufferedReader(new InputStreamReader(System.in));
            else    reader = new BufferedReader(new FileReader(in));

            if(out.equals(""))  writer = new PrintWriter(new OutputStreamWriter(System.out));
            else    writer = new PrintWriter(new FileWriter(out));
            solve();
        } catch(IOException e) {
            e.printStackTrace();
        } finally {
            try {
                reader.close();
                writer.close();
            } catch(IOException e) {
                e.printStackTrace();
            }
        }
    }

    private int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    private long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    private double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    private float nextFloat() throws IOException {
        return Float.parseFloat(nextToken());
    }

    private String nextToken() throws IOException {
        while(st == null || !st.hasMoreTokens())    st = new StringTokenizer(reader.readLine());
        return st.nextToken();
    }

    private String in = "", out = "";
    private BufferedReader reader;
    private PrintWriter writer;
    private StringTokenizer st;
}

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.SortedSet;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

/**
 * #
 *
 * @author pttrung
 */
public class B_Round_130_Div2 {

	public static long MOD = 1000000007;

	public static void main(String[] args) throws FileNotFoundException {
		// PrintWriter out = new PrintWriter(new FileOutputStream(new File(
		// "output.txt")));
		PrintWriter out = new PrintWriter(System.out);
		Scanner in = new Scanner();
		int n = in.nextInt();
		String[] data = new String[n];
		for (int i = 0; i < n; i++) {
			data[i] = in.next();
		}
		boolean v = cal(n - 1, data);
		if (v) {
			out.println("YES");
		} else {
			out.println("NO");
		}
		out.close();
	}

	static boolean cal(int index, String[] data) {
		if (index == 0) {
			return true;
		}
		boolean result = false;
		if(!isMatch(data[index], data[index - 1])){
			return false;
		}
		if (isMatch(data[index], data[index - 1])) {
			data[index - 1] = data[index];
			result = cal(index - 1, data);
			if(result){
				return true;
			}
		}

		return result;
	}

	static boolean isMatch(String a, String b) {
		if (a.charAt(0) == b.charAt(0)) {
			return true;
		}
		return a.charAt(1) == b.charAt(1);
	}

	public static int[] KMP(String val) {
		int i = 0;
		int j = -1;
		int[] result = new int[val.length() + 1];
		result[0] = -1;
		while (i < val.length()) {
			while (j >= 0 && val.charAt(j) != val.charAt(i)) {
				j = result[j];
			}
			j++;
			i++;
			result[i] = j;
		}
		return result;

	}

	public static boolean nextPer(int[] data) {
		int i = data.length - 1;
		while (i > 0 && data[i] < data[i - 1]) {
			i--;
		}
		if (i == 0) {
			return false;
		}
		int j = data.length - 1;
		while (data[j] < data[i - 1]) {
			j--;
		}
		int temp = data[i - 1];
		data[i - 1] = data[j];
		data[j] = temp;
		Arrays.sort(data, i, data.length);
		return true;
	}

	public static int digit(long n) {
		int result = 0;
		while (n > 0) {
			n /= 10;
			result++;
		}
		return result;
	}

	public static double dist(long a, long b, long x, long y) {
		double val = (b - a) * (b - a) + (x - y) * (x - y);
		val = Math.sqrt(val);
		double other = x * x + a * a;
		other = Math.sqrt(other);
		return val + other;

	}

	public static class Point implements Comparable<Point> {

		int x, y;

		public Point(int start, int end) {
			this.x = start;
			this.y = end;
		}

		@Override
		public int hashCode() {
			int hash = 5;
			hash = 47 * hash + this.x;
			hash = 47 * hash + this.y;
			return hash;
		}

		@Override
		public boolean equals(Object obj) {
			if (obj == null) {
				return false;
			}
			if (getClass() != obj.getClass()) {
				return false;
			}
			final Point other = (Point) obj;
			if (this.x != other.x) {
				return false;
			}
			if (this.y != other.y) {
				return false;
			}
			return true;
		}

		@Override
		public int compareTo(Point o) {
			return x - o.x;
		}
	}

	public static class FT {

		long[] data;

		FT(int n) {
			data = new long[n];
		}

		public void update(int index, long value) {
			while (index < data.length) {
				data[index] += value;
				index += (index & (-index));
			}
		}

		public long get(int index) {
			long result = 0;
			while (index > 0) {
				result += data[index];
				index -= (index & (-index));
			}
			return result;

		}
	}

	public static long gcd(long a, long b) {
		if (b == 0) {
			return a;
		}
		return gcd(b, a % b);
	}

	public static long pow(long a, long b) {
		if (b == 0) {
			return 1;
		}
		if (b == 1) {
			return a;
		}
		long val = pow(a, b / 2);
		if (b % 2 == 0) {
			return val * val % MOD;
		} else {
			return val * (val * a % MOD) % MOD;

		}
	}

	static class Scanner {

		BufferedReader br;
		StringTokenizer st;

		public Scanner() throws FileNotFoundException {
			// System.setOut(new PrintStream(new
			// BufferedOutputStream(System.out), true));
			br = new BufferedReader(new InputStreamReader(System.in));
			// br = new BufferedReader(new InputStreamReader(new
			// FileInputStream(new File("input.txt"))));
		}

		public String next() {

			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception e) {
					throw new RuntimeException();
				}
			}
			return st.nextToken();
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public String nextLine() {
			st = null;
			try {
				return br.readLine();
			} catch (Exception e) {
				throw new RuntimeException();
			}
		}

		public boolean endLine() {
			try {
				String next = br.readLine();
				while (next != null && next.trim().isEmpty()) {
					next = br.readLine();
				}
				if (next == null) {
					return true;
				}
				st = new StringTokenizer(next);
				return st.hasMoreTokens();
			} catch (Exception e) {
				throw new RuntimeException();
			}
		}
	}
}

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner r = new Scanner(System.in);

        int N = r.nextInt();

        char[][] a = new char[N][];

        for(int i = 0; i < N; i++)
            a[i] = r.next().toCharArray();

        boolean[][] g = new boolean[N][N];
        for(int i = 0; i < N; i++)
            g[i][i] = true;
        for(int i = 0; i < N; i++){
            if(i + 1 < N && (a[i][0] == a[i + 1][0] || a[i][1] == a[i + 1][1]))g[i][i + 1] = true;
            if(i + 3 < N && (a[i][0] == a[i + 3][0] || a[i][1] == a[i + 3][1]))g[i][i + 3] = true;
        }

        for(int k = 0; k < N; k++)
        for(int i = 0; i < N; i++)
        for(int j = 0; j < N; j++)
            g[i][j] |= g[i][k] && g[k][j];

        for(int i = 0; i < N; i++)
            if(g[i][N - 1] == false){
                System.out.println("NO");
                return;
            }

        System.out.println("YES");
    }
}

import java.util.*;

public class b208{
     //public static int[] dp;
	public static HashMap<Character,Integer> has;
  b208(){

  }
  boolean rec(String[] arr,int n) throws Exception
  {
 //  System.out.println("sdsd");
    boolean[][][] temp = new boolean[60][20][10];
    for(int i=0;i<n;i++)
    {
      int a = has.get(arr[i].charAt(0));
      int b =  has.get(arr[i].charAt(1));

  // System.out.println(a);

   //System.out.println(b);
      temp[i][a][b]=true;
    }
    for(int i=n-1;i>0;i--)
    {
      boolean flag=false;
      if(i-1>=0 )
      {
        for(int x=0;x<13;x++)
        {
          for(int y=0;y<4;y++)
          {
              if(temp[i-1][x][y]==true)
              {
for(int a=0;a<4;a++)
{
  if(temp[i][x][a]==true)
  {
    flag=true;
    temp[i-1][x][a]=true;
  }
}
for(int a=0;a<13;a++)
{
  if(temp[i][a][y]==true)
  {
flag=true;
temp[i-1][a][y]=true;
  }
}
              }
          }
        }
      }
    if(i-3>=0 )
      {
        for(int x=0;x<13;x++)
        {
          for(int y=0;y<4;y++)
          {
              if(temp[i-3][x][y]==true)
              {
for(int a=0;a<4;a++)
{
  if(temp[i][x][a]==true)
  {
    flag=true;
    temp[i-3][x][a]=true;
  }
}
for(int a=0;a<13;a++)
{
  if(temp[i][a][y]==true)
  {
flag=true;
temp[i-3][a][y]=true;
  }
}
              }
          }
        }
      }
if(flag==false)
  return false;
    }
  //  System.out.println("tr");
        return true;
  }
	public static void main(String arg[])
	{
    try{
		Scanner sc =new Scanner(System.in);
		int n= sc.nextInt();
		//int b= sc.nextInt();
		//String t = sc.nextLine();
		//dp = new int[n];
		//for(int i=0;i<n;i++)
         //dp[i]=-1;
		String[] arr= new String[n];
		for(int i=0;i<n;i++)
		{arr[i]= sc.next();
			//System.out.println("yo" + arr[i]);
		}
    int j=0;
     has = new HashMap<Character,Integer>();
    for(char  i='2';i<='9';i++,j++)
      has.put(i,j);
    has.put('T',j++);
    has.put('J',j++);
    has.put('Q',j++);
    has.put('K',j++);
    has.put('A',j++);
    has.put('S',0);
    has.put('D',1);
    has.put('H',2);
    has.put('C',3);
    b208 obj = new b208();
  //  System.out.println(j);
        if(obj.rec(arr,n))
        	System.out.println("YES");
       else
        	System.out.println("NO");
  }catch(Exception e){System.out.println(e);}
	}
}

import java.io.*;
import java.util.*;
import java.math.*;

public class Main {
    static boolean find = false;
    static HashSet<String> set = new HashSet<>();
    public static void main(String[] args) throws Exception {
        PrintWriter out = new PrintWriter(System.out,true);
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(in.readLine());
        String[] mas = new String[n];
        StringTokenizer st = new StringTokenizer(in.readLine());
        for(int i = 0;i < n;i++) mas[i] = st.nextToken();
        func(mas,n-1);
        if(find) {
            out.println("YES");
        }else{
            out.println("NO");
        }
    }

    public static void func(String[] mas, int last) {
        String d = Arrays.toString(mas);
        if(set.contains(d)) return;
        set.add(d);
        if(last == 0 || find) find = true;
        if(last > 0 && (mas[last-1].charAt(0) == mas[last].charAt(0) || mas[last-1].charAt(1) == mas[last].charAt(1))) {
            String a = mas[last-1];
            mas[last-1] = mas[last];
            mas[last] = "";
            func(mas,last-1);
            mas[last] = mas[last-1];
            mas[last-1] = a;
        }
        if(last > 2 && (mas[last-3].charAt(0) == mas[last].charAt(0) || mas[last-3].charAt(1) == mas[last].charAt(1))) {
            String a = mas[last-3];
            mas[last-3] = mas[last];
            mas[last] = "";
            func(mas,last-1);
            mas[last] = mas[last-1];
            mas[last-3] = a;
        }
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;

public class B {

    public static void main(String[] args) throws NumberFormatException,
            IOException {
        BufferedReader buf = new BufferedReader(
                new InputStreamReader(System.in));
        int n = Integer.parseInt(buf.readLine());
        String[] a = buf.readLine().split(" ");
        map = new HashMap<String, Integer>();
        for (int i = 0; i < a.length; i++)
            if (!map.containsKey(a[i]))
                map.put(a[i], i);
        check = false;
        boolean[][][] dp = new boolean[n][n][n];
        dfs(a, dp, a.length - 1);

        if (check)
            System.out.println("YES");
        else
            System.out.println("NO");
    }

    static HashMap<String, Integer> map;

    private static void dfs(String[] a, boolean[][][] dp, int i) {
        if (i == 0)
            check = true;
        else if (i - 2 >= 0 && dp[i][map.get(a[i])][map.get(a[i - 2])])
            return;
        else if (!check) {
            if (i - 2 >= 0)
                dp[i][map.get(a[i])][map.get(a[i - 2])] = true;
            int cnt = 0;
            for (int j = i - 1; j >= 0 && cnt < 2; j -= 2) {
                cnt++;
                String temp = a[j];
                if (a[j].charAt(0) == a[i].charAt(0)
                        || a[j].charAt(1) == a[i].charAt(1)) {
                    a[j] = a[i];

                    dfs(a, dp, i - 1);
                    a[j] = temp;
                }
            }
        }

    }

    static boolean check;

}

import java.util.*;
import java.io.*;

public class b {
   static Map<String, Boolean> dp = new HashMap<String, Boolean>();

   static String make(String[] pa) {
      String s = "";
      for(String t : pa)
         s += t + " ";
      return s.trim();
   }

   static boolean doit(String s, int k) {
      if(k == 0) return true;
      if(dp.get(s) != null) return dp.get(s);
      boolean r = false;
      String[] pa = s.split(" ");
      for(int i = k - 1; i >= 0; --i) {
         if(pa[i].charAt(0) == pa[k].charAt(0) && pa[i].charAt(1) == pa[k].charAt(1)) {
            pa[i] = pa[k];
            r = r | doit(make(pa), k - 1);
         }
      }
      dp.put(s, r);
      return r;
   }

   public static void main(String[] args) throws IOException {
      //BufferedReader br = new BufferedReader(new FileReader("b.in"));
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      String line = br.readLine();
      int n = Integer.parseInt(line);
      line = br.readLine();

      boolean r = doit(line, n - 1);
      System.out.println((r ? "YES" : "NO"));
   }

   static void debug(Object...o) {
      System.err.println(Arrays.deepToString(o));
   }
}

import java.util.*;

public class B {

	private static class Card {
		char face;
		char val;

		public Card(String value) {
			val = value.charAt(0);
			face = value.charAt(1);
		}

		public boolean canPile(Card c) {
			return (c.face == this.face || c.val == this.val);
		}

		public String toString() {
			return val + "" + face;
		}
	}

	private static ArrayList<Card>[] piles;
	private static int n;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		piles = new ArrayList[n];
		for (int i = 0; i < n; i++) {
			piles[i] = new ArrayList<Card>();
			piles[i].add(new Card(sc.next()));
		}

		dfs(0, n - 1);
		System.out.println("NO");
		System.exit(0);
	}

	private static void dfs(int count, int idx) {
		if (idx < 0 || piles[idx].isEmpty()) {
			return;
		}

		if (count == n - 1) {
			System.out.println("YES");
			System.exit(0);
		}

		if (idx - 1 > -1 && !piles[idx - 1].isEmpty()) {
			if (piles[idx].get(0).canPile(piles[idx - 1].get(0))) {
				ArrayList<Card> A = new ArrayList<Card>(piles[idx]);
				ArrayList<Card> B = new ArrayList<Card>(piles[idx - 1]);
				piles[idx].addAll(piles[idx - 1]);
				piles[idx - 1] = piles[idx];
				piles[idx] = new ArrayList<Card>();
				dfs(count + 1, idx - 1);
				piles[idx] = A;
				piles[idx - 1] = B;
			}
		}

		if (idx - 3 > -1 && !piles[idx - 3].isEmpty()) {
			if (piles[idx].get(0).canPile(piles[idx - 3].get(0))) {
				ArrayList<Card> A = new ArrayList<Card>(piles[idx]);
				ArrayList<Card> B = new ArrayList<Card>(piles[idx - 3]);
				piles[idx].addAll(piles[idx - 3]);
				piles[idx - 3] = piles[idx];
				piles[idx].clear();
				dfs(count + 1, idx - 1);
				piles[idx] = A;
				piles[idx - 3] = B;
			}
		}
	}
}

import java.io.*;
import java.util.StringTokenizer;

public class Main {
    FastScanner in;
    PrintWriter out;

    public static void main(String[] args) throws Exception {
        (new Main()).run();
    }

    private void run() throws Exception {
        in = new FastScanner(System.in);
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }

    private void solve() throws Exception {
        int n = in.nextInt();
        int[] cards = new int[n];
        for (int i = 0; i < n; i++) {
            cards[i] = getCardNumber(in.next());
        }
        out.println(getAnswer(cards) ? "YES" : "NO");
    }

    private boolean getAnswer(int[] cards) {
        int n = cards.length;
        if (n == 1) {
            return true;
        }
        if (n == 2) {
            return canMove(cards[0], cards[1]);
        }
        Boolean[][][][] dp = new Boolean[n + 1][52][52][52];
        int last = cards[n - 1];
        int prelast = cards[n - 2];
        int preprelast = cards[n - 3];
        return getAnswer(cards, dp, n, last, prelast, preprelast);
    }

    private boolean getAnswer(int[] cards, Boolean[][][][] dp, int n, int last, int prelast, int preprelast) {
        if (dp[n][last][prelast][preprelast] != null) {
            return dp[n][last][prelast][preprelast];
        }
        if (n == 3) {
            return dp[n][last][prelast][preprelast] = canMove(last, prelast) && canMove(last, preprelast);
        }
        return dp[n][last][prelast][preprelast] = (canMove(last, prelast) && getAnswer(cards, dp, n - 1, last, preprelast, cards[n - 4]))
                || (canMove(last, cards[n - 4]) && getAnswer(cards, dp, n - 1, prelast, preprelast, last));
    }

    private boolean canMove(int card1Number, int card2Number) {
        return (card1Number / 13) == (card2Number / 13) || (card1Number % 13) == (card2Number % 13);
    }

    private int getCardNumber(String cardName) {
        char rank = cardName.charAt(0);
        char suit = cardName.charAt(1);
        int rankNumber = 12;
        if (Character.isDigit(rank)) {
            rankNumber = rank - '0';
        } else {
            switch (rank) {
                case 'J':
                    rankNumber = 9;
                    break;
                case 'Q':
                    rankNumber = 10;
                    break;
                case 'K':
                    rankNumber = 11;
                    break;
            }
        }
        int suitNumber = 0;
        switch (suit) {
            case 'D':
                suitNumber = 1;
                break;
            case 'H':
                suitNumber = 2;
                break;
            case 'C':
                suitNumber = 3;
                break;
        }
        return suitNumber * 13 + rankNumber;
    }

    private class FastScanner {
        BufferedReader bufferedReader;
        StringTokenizer stringTokenizer;

        public FastScanner(InputStream inputStream) {
            this.bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
        }

        public String next() throws IOException {
            while (stringTokenizer == null || !stringTokenizer.hasMoreTokens()) {
                String line = bufferedReader.readLine();
                if (line == null) {
                    throw new EOFException("End of input stream is reached.");
                }
                stringTokenizer = new StringTokenizer(line);
            }
            return stringTokenizer.nextToken();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }
    }
}

import java.util.*;
import java.io.*;

public class b {
   static Map<String, Boolean> dp = new HashMap<String, Boolean>();
   static boolean[][] vi = new boolean[55][55];

   static String make(String[] pa) {
      String s = "";
      for(String t : pa)
         s += t + " ";
      return s.trim();
   }

   static boolean doit(String s, int k, int p) {
      if(k == 0) return true;
      if(vi[k][p]) return false;
      boolean r = false;
      String[] pa = s.split(" ");
      for(int i = k - 1; i >= 0; --i) {
         vi[k][i] = true;
         if(pa[i].charAt(0) == pa[k].charAt(0) || pa[i].charAt(1) == pa[k].charAt(1)) {
            pa[i] = pa[k];
            r = r | doit(make(pa), k - 1, i);
         }
      }
      return r;
   }

   public static void main(String[] args) throws IOException {
      //BufferedReader br = new BufferedReader(new FileReader("b.in"));
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      String line = br.readLine();
      int n = Integer.parseInt(line);
      line = br.readLine();
      //debug(line);
      boolean r = doit(line, n - 1, n);
      System.out.println((r ? "YES" : "NO"));
   }

   static void debug(Object...o) {
      System.err.println(Arrays.deepToString(o));
   }
}

import java.util.Scanner;

public class B {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String[]s = new String[n+1];
        int[]a = new int[n+1], b = new int[n+1];
        for (int i = 1; i <= n; i++) {
            s[i] = sc.next();
            char q = s[i].charAt(0);
            if (q=='A')
                a[i] = 10;
            if (q=='J')
                a[i] = 11;
            if (q=='Q')
                a[i] = 12;
            if (q=='K')
                a[i] = 13;
            if (q=='A')
                a[i] = 14;
            if (q < 'A')
                a[i] = s[i].codePointAt(0)-48;
            char w = s[i].charAt(1);
            if (w=='S')
                b[i] = 1;
            if (w=='D')
                b[i] = 2;
            if (w=='H')
                b[i] =3;
            if (w=='C')
                b[i] = 4;
        }
        boolean[][][]possible = new boolean[n+1][16][5];
        possible[1][a[1]][b[1]] = true;
        for (int i = 2; i <= n; i++) {
            for (int j = 1; j <= 4; j++) {
                if (possible[i-1][a[i]][j]) {
                    possible[i][a[i]][b[i]] = true;
                }
            }
            for (int j = 2; j <= 9; j++) {
                if (possible[i-1][j][b[i]])
                    possible[i][a[i]][b[i]] = true;
            }
            if (i > 3) {
                for (int j = 1; j <= 4; j++) {
                    if (possible[i-3][a[i]][j]) {
                        possible[i][a[i]][b[i]] = true;
                    }
                }
                for (int j = 2; j <= 9; j++) {
                    if (possible[i-3][j][b[i]])
                        possible[i][a[i]][b[i]] = true;
                }
            }
        }
        if (possible[n][a[n]][b[n]])
            System.out.println("YES");
        else
            System.out.println("NO");
    }

}

import sun.reflect.generics.tree.Tree;

import java.util.Scanner;
import java.util.*;

public class Main
{
    static Scanner in = new Scanner( System.in );

    static class State
    {
        int size;
        String first;
        String second;
        String third;
        State( int arg1, String arg2, String arg3, String arg4 )
        {
            size = arg1;
            first = arg2;
            second = arg3;
            third = arg4;
        }
    }

    static boolean equals( String arg1, String arg2 )
    {
        if ( arg1.charAt( 0 ) == arg2.charAt( 0 ) || arg1.charAt( 1 ) == arg2.charAt( 1 ) ) return true;
        else return false;
    }

    static class StateComparator implements Comparator < State >
    {
        public int compare( State arg1, State arg2 )
        {
            if ( arg1.size != arg2.size ) return arg1.size - arg2.size;
            else if ( arg1.first.compareTo( arg2.first ) != 0 ) return arg1.first.compareTo( arg2.first );
            else if ( arg1.second.compareTo( arg2.second ) != 0 ) return arg1.second.compareTo( arg2.second );
            else return arg1.third.compareTo( arg2.third );
        }
    }

    public static void main( String[] args )
    {
        int cardsN = Integer.parseInt(in.nextLine());
        List < String > cards = new ArrayList();
        StringTokenizer input = new StringTokenizer( in.nextLine() );
        for ( int i = 0; i < cardsN; i++ )
        {
            cards.add( input.nextToken() );
        }

        Queue < List < String > > workQ = new LinkedList();
        Map < State, Boolean > states = new TreeMap( new StateComparator() );
        workQ.offer( cards );

        if ( cards.size() < 4 ) if ( equals(cards.get(0), cards.get(cards.size() - 1)) ) { System.out.println( "YES" ); return; }
        else { System.out.println( "NO" ); return; }

        states.put( new State( cardsN, cards.get( cardsN - 1 ), cards.get( cardsN - 2 ), cards.get( cardsN - 3 ) ), true );

        while ( !workQ.isEmpty() )
        {
            List < String > curList1 = new LinkedList < String > ();
            List < String > curList2 = new LinkedList < String > ();
            for ( String element : workQ.poll() )
            {
                curList1.add( new String( element ) );
                curList2.add( new String( element ) );
            }
            if ( curList1.size() == 1 ) { System.out.println( "YES" ); return; }

            if ( curList1.size() - 2 >= 0 && curList1.size() > 3 && equals( curList1.get( curList1.size() - 1 ), curList1.get( curList1.size() - 2 ) ) )
            {
                int s = curList1.size();
                curList1.add( s - 2, curList1.get(s - 1) );
                curList1.remove( s - 1 );
                curList1.remove( s - 1 ); s--;
                State curState = new State( s, curList1.get( s - 1 ), curList1.get( s - 2 ), curList1.get( s - 3 ) );
                if ( states.get( curState ) == null )
                {
                    states.put( curState, true );
                    workQ.offer( curList1 );
                }
            }
            if ( curList2.size() - 4 >= 0 && curList2.size() > 3 && equals( curList2.get( curList2.size() - 1 ), curList2.get( curList2.size() - 4 ) ) )
            {
                int s = curList2.size();
                curList2.add( s - 2, curList2.get(s - 1) );
                curList2.remove( s - 1 );
                curList2.remove( s - 1 ); s--;
                State curState = new State( s, curList2.get( s - 1 ), curList2.get( s - 2 ), curList2.get( s - 3 ) );
                if ( states.get( curState ) == null )
                {
                    states.put( curState, true );
                    workQ.offer( curList2 );
                }
            }
            if ( curList1.size() < 4 ) if ( equals( curList1.get( 0 ), curList1.get( 2 ) ) ) { System.out.println( "YES" ); return; }
            if ( curList2.size() < 4 ) if ( equals( curList2.get( 0 ), curList2.get( 2 ) ) ) { System.out.println( "YES" ); return; }
        }
        System.out.println("NO");
    }
}

import java.util.*;
import java.io.*;

public class Main{

	int n;
	String a[];
	Map<Character, Integer> mast, dost;
	boolean [][]f1,f2;

	public void run(){
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		a = new String[n];
		for(int i=0;i<n;i++) a[i] = in.next();

		init();
		f1 = new boolean[n][4];
		f2 = new boolean[n][13];

		int idx = mast.get(a[n-1].charAt(1));
		f1[n-1][idx] = true;
		idx = dost.get(a[n-1].charAt(0));
		f2[n-1][idx] = true;

		for(int i=n-2;i>=0;i--){
			if (i + 3 < n){
				update(i, i + 3);
			}
			update(i, i + 1);
		}
		int m = mast.get(a[0].charAt(1));
		int d = dost.get(a[0].charAt(0));
		if (f1[0][m] || f2[0][d]){
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}
	}

	private void update(int c, int i){
		int cm = mast.get(a[c].charAt(1));
		int cd = dost.get(a[c].charAt(0));

		int om = mast.get(a[i].charAt(1));
		int od = dost.get(a[i].charAt(0));

		if (cm == om){
			if (f1[i][om]){
				f1[c][om] = true;
				f2[c][od] = true;
			}
		}
		if (cd == od){
			if (f2[i][od]){
				f1[c][om] = true;
				f2[c][od] = true;
			}
		}
	}

	private void init(){
		mast = new HashMap<Character, Integer>();
		dost = new HashMap<Character, Integer>();

		mast.put('S', 0);mast.put('D', 1);
		mast.put('H', 2);mast.put('C', 3);

		dost.put('2', 0);dost.put('3', 1);
		dost.put('4', 2);dost.put('5', 3);
		dost.put('6', 4);dost.put('7', 5);
		dost.put('8', 6);dost.put('9', 7);
		dost.put('T', 8);dost.put('J', 9);
		dost.put('Q', 10);dost.put('K', 11);
		dost.put('A', 12);
	}

	public static void main(String[] args){
		new Main().run();
	}
}

/* Codeforces Template */

import java.io.*;
import java.util.*;

import static java.lang.Math.*;
import static java.util.Arrays.fill;
import static java.util.Arrays.binarySearch;
import static java.util.Arrays.sort;

public class Main {

	static long initTime;
	static final Random rnd = new Random(7777L);

	public static void main(String[] args) throws IOException {
		initTime = System.currentTimeMillis();
		new Thread(null, new Runnable() {
			public void run() {
				try {
					try {
						if (new File("input.txt").exists())
							System.setIn(new FileInputStream("input.txt"));
					} catch (SecurityException e) {}
//					long prevTime = System.currentTimeMillis();
					new Main().run();
//					System.err.println("Total time: " + (System.currentTimeMillis() - prevTime) + " ms");
//					System.err.println("Memory status: " + memoryStatus());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}, "1", 1L << 24).start();
	}

	void run() throws IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		solve();
		out.close();
		in.close();
	}

	/***************************************************************
	 * Solution
	 **************************************************************/

	int n;
	int[] cards;
	Set<Integer> was = new TreeSet<Integer>();

	void solve() throws IOException  {

		n = nextInt();
		cards = new int [n];

		for (int i = 0; i < n; i++) {
			cards[i] = code(nextToken());
		}

		boolean ok = false;

		if (n < 3) {
			ok = solveSmall(cards, n);
		} else {
			ok = dfs(n - 4, cards[n - 3], cards[n - 2], cards[n - 1]);
		}

		out.println(ok ? "YES" : "NO");
	}

	int[] tmp = new int [3];

	boolean dfs(int pos, int c1, int c2, int c3) {

		if (pos < 0) {
			tmp[0] = c1;
			tmp[1] = c2;
			tmp[2] = c3;
			return solveSmall(tmp, 3);
		}

		int state = codeState(pos, c1, c2, c3);

		if (was.contains(state)) {
			return false;
		}

		was.add(state);

		if (can(c2, c3) && dfs(pos - 1, cards[pos], c1, c3)) {
			return true;
		}

		if (can(cards[pos], c3) && dfs(pos - 1, c3, c1, c2)) {
			return false;
		}

		return false;
	}

	boolean can(int c1, int c2) {
		return s(c1) == s(c2) || v(c1) == v(c2);
	}

	int codeState(int pos, int c1, int c2, int c3) {
		return ((pos * 52 + c1) * 52 + c2) * 52 + c3;
	}

	boolean solveSmall(int[] cards, int cnt) {
		if (cnt <= 1) return true;
		if (cnt == 2) return can(cards[0], cards[1]);
		return can(cards[2], cards[1]) && can(cards[2], cards[0]);
	}

	int s(int c) {
		return c / 13;
	}

	int v(int c) {
		return c % 13;
	}

	int code(String s) {
		return vn(s.charAt(0)) + 13 * sn(s.charAt(1));
	}

	int sn(char c) {
		if (c == 'S') return 0;
		if (c == 'D') return 1;
		if (c == 'H') return 2;
		if (c == 'C') return 3;
		return -1;
	}

	int vn(char c) {
		if ('2' <= c && c <= '9') return (c - '2');
		if (c == 'A') return 8;
		if (c == 'J') return 9;
		if (c == 'Q') return 10;
		if (c == 'K') return 11;
		if (c == 'T') return 12;
		return -1;
	}

	/***************************************************************
	 * Input
	 **************************************************************/
	BufferedReader in;
	PrintWriter out;
	StringTokenizer st = new StringTokenizer("");

	String nextToken() throws IOException {
		while (!st.hasMoreTokens())
			st = new StringTokenizer(in.readLine());
		return st.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	int[] nextIntArray(int size) throws IOException {
		int[] ret = new int [size];
		for (int i = 0; i < size; i++)
			ret[i] = nextInt();
		return ret;
	}

	long[] nextLongArray(int size) throws IOException {
		long[] ret = new long [size];
		for (int i = 0; i < size; i++)
			ret[i] = nextLong();
		return ret;
	}

	double[] nextDoubleArray(int size) throws IOException {
		double[] ret = new double [size];
		for (int i = 0; i < size; i++)
			ret[i] = nextDouble();
		return ret;
	}

	String nextLine() throws IOException {
		st = new StringTokenizer("");
		return in.readLine();
	}

	boolean EOF() throws IOException {
		while (!st.hasMoreTokens()) {
			String s = in.readLine();
			if (s == null)
				return true;
			st = new StringTokenizer(s);
		}
		return false;
	}

	/***************************************************************
	 * Output
	 **************************************************************/
	void printRepeat(String s, int count) {
		for (int i = 0; i < count; i++)
			out.print(s);
	}

	void printArray(int[] array) {
		if (array == null || array.length == 0)
			return;
		for (int i = 0; i < array.length; i++) {
			if (i > 0) out.print(' ');
			out.print(array[i]);
		}
		out.println();
	}

	void printArray(long[] array) {
		if (array == null || array.length == 0)
			return;
		for (int i = 0; i < array.length; i++) {
			if (i > 0) out.print(' ');
			out.print(array[i]);
		}
		out.println();
	}

	void printArray(double[] array) {
		if (array == null || array.length == 0)
			return;
		for (int i = 0; i < array.length; i++) {
			if (i > 0) out.print(' ');
			out.print(array[i]);
		}
		out.println();
	}

	void printArray(double[] array, String spec) {
		if (array == null || array.length == 0)
			return;
		for (int i = 0; i < array.length; i++) {
			if (i > 0) out.print(' ');
			out.printf(Locale.US, spec, array[i]);
		}
		out.println();
	}

	void printArray(Object[] array) {
		if (array == null || array.length == 0)
			return;
		boolean blank = false;
		for (Object x : array) {
			if (blank) out.print(' '); else blank = true;
			out.print(x);
		}
		out.println();
	}

	@SuppressWarnings("rawtypes")
	void printCollection(Collection collection) {
		if (collection == null || collection.isEmpty())
			return;
		boolean blank = false;
		for (Object x : collection) {
			if (blank) out.print(' '); else blank = true;
			out.print(x);
		}
		out.println();
	}

	/***************************************************************
	 * Utility
	 **************************************************************/
	static String memoryStatus() {
		return (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory() >> 20) + "/" + (Runtime.getRuntime().totalMemory() >> 20) + " MB";
	}

	static void checkMemory() {
		System.err.println(memoryStatus());
	}

	static long prevTimeStamp = Long.MIN_VALUE;

	static void updateTimer() {
		prevTimeStamp = System.currentTimeMillis();
	}

	static long elapsedTime() {
		return (System.currentTimeMillis() - prevTimeStamp);
	}

	static void checkTimer() {
		System.err.println(elapsedTime() + " ms");
	}
}

import java.io.*;
import java.util.*;
import static java.lang.Math.*;

public class B {

	boolean fl = false;

	boolean take(String s1, String s2) {
		return (s1.charAt(0) == s2.charAt(0) || s1.charAt(1) == s2.charAt(1));
	}

	String[] a;
	HashSet<String> pos;

	void find(int n, String l1, String l2, String l3) {
		String indpos = n + "" + l1 + l2 + l3;
		if (pos.contains(indpos)) {
			return;
		}
		if (n == 3) {
			fl = fl || (take(l3, l2) && take(l3, l1));
			return;
		}
		if (!fl && take(l3, a[n - 3])) {
			find(n - 1, l3, l1, l2);
		}
		if (!fl && take(l3, l2)) {
			find(n - 1, a[n - 3], l1, l3);
		}
	}

	void count() throws IOException {
		int n = nextInt();
		a = new String[n];
		pos = new HashSet<String>();
		for (int i = 0; i < n; i++) {
			a[i] = nextToken();
		}
		if (n == 1) {
			out.println("YES");
			return;
		}
		if (n == 2) {
			if (take(a[0], a[1])) {
				out.println("YES");
			} else {
				out.println("NO");
			}
			return;
		}
		find(n, a[n - 3], a[n - 2], a[n - 1]);

		if (fl) {
			out.println("YES");
		} else {
			out.println("NO");
		}
	}

	BufferedReader in;
	PrintWriter out;
	StringTokenizer str;
	String readline;

	String nextToken() throws IOException {
		while (str == null || !str.hasMoreTokens()) {
			readline = in.readLine();
			if (readline == null) {
				return null;
			} else {
				str = new StringTokenizer(readline);
			}
		}
		return str.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	void run() throws IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		count();
		out.close();
	}

	public static void main(String[] args) throws IOException {
		new B().run();
	}
}

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.SortedSet;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

/**
 * #
 *
 * @author pttrung
 */
public class B_Round_130_Div2 {

	public static long MOD = 1000000007;
	static HashSet<String> set = new HashSet();

	public static void main(String[] args) throws FileNotFoundException {
		// PrintWriter out = new PrintWriter(new FileOutputStream(new File(
		// "output.txt")));
		PrintWriter out = new PrintWriter(System.out);
		Scanner in = new Scanner();
		int n = in.nextInt();
		String[] data = new String[n];
		for (int i = 0; i < n; i++) {
			data[i] = in.next();
		}
		boolean v = cal(n - 1, data);
		if (v) {
			out.println("YES");
		} else {
			out.println("NO");
		}
		out.close();
	}

	static boolean cal(int index, String[] data) {

		if (index == 0) {
			return true;
		}
		if(set.contains(Arrays.toString(data))){
			return false;
		}
		boolean result = false;

		if (isMatch(data[index], data[index - 1])) {

			String tmp = data[index - 1];
			data[index - 1] = data[index];
			result = cal(index - 1, data);
			if (result) {
				return true;
			}
			data[index - 1] = tmp;
		}
		if(index >= 3 && isMatch(data[index], data[index - 3])) {
			data[index - 3] = data[index];
			result = cal(index - 1, data);
			if (result) {
				return true;
			}

		}
		set.add(Arrays.toString(data));
		return false;
	}

	static boolean isMatch(String a, String b) {
		if (a.charAt(0) == b.charAt(0)) {
			return true;
		}
		return a.charAt(1) == b.charAt(1);
	}

	public static int[] KMP(String val) {
		int i = 0;
		int j = -1;
		int[] result = new int[val.length() + 1];
		result[0] = -1;
		while (i < val.length()) {
			while (j >= 0 && val.charAt(j) != val.charAt(i)) {
				j = result[j];
			}
			j++;
			i++;
			result[i] = j;
		}
		return result;

	}

	public static boolean nextPer(int[] data) {
		int i = data.length - 1;
		while (i > 0 && data[i] < data[i - 1]) {
			i--;
		}
		if (i == 0) {
			return false;
		}
		int j = data.length - 1;
		while (data[j] < data[i - 1]) {
			j--;
		}
		int temp = data[i - 1];
		data[i - 1] = data[j];
		data[j] = temp;
		Arrays.sort(data, i, data.length);
		return true;
	}

	public static int digit(long n) {
		int result = 0;
		while (n > 0) {
			n /= 10;
			result++;
		}
		return result;
	}

	public static double dist(long a, long b, long x, long y) {
		double val = (b - a) * (b - a) + (x - y) * (x - y);
		val = Math.sqrt(val);
		double other = x * x + a * a;
		other = Math.sqrt(other);
		return val + other;

	}

	public static class Point implements Comparable<Point> {

		int x, y;

		public Point(int start, int end) {
			this.x = start;
			this.y = end;
		}

		@Override
		public int hashCode() {
			int hash = 5;
			hash = 47 * hash + this.x;
			hash = 47 * hash + this.y;
			return hash;
		}

		@Override
		public boolean equals(Object obj) {
			if (obj == null) {
				return false;
			}
			if (getClass() != obj.getClass()) {
				return false;
			}
			final Point other = (Point) obj;
			if (this.x != other.x) {
				return false;
			}
			if (this.y != other.y) {
				return false;
			}
			return true;
		}

		@Override
		public int compareTo(Point o) {
			return x - o.x;
		}
	}

	public static class FT {

		long[] data;

		FT(int n) {
			data = new long[n];
		}

		public void update(int index, long value) {
			while (index < data.length) {
				data[index] += value;
				index += (index & (-index));
			}
		}

		public long get(int index) {
			long result = 0;
			while (index > 0) {
				result += data[index];
				index -= (index & (-index));
			}
			return result;

		}
	}

	public static long gcd(long a, long b) {
		if (b == 0) {
			return a;
		}
		return gcd(b, a % b);
	}

	public static long pow(long a, long b) {
		if (b == 0) {
			return 1;
		}
		if (b == 1) {
			return a;
		}
		long val = pow(a, b / 2);
		if (b % 2 == 0) {
			return val * val % MOD;
		} else {
			return val * (val * a % MOD) % MOD;

		}
	}

	static class Scanner {

		BufferedReader br;
		StringTokenizer st;

		public Scanner() throws FileNotFoundException {
			// System.setOut(new PrintStream(new
			// BufferedOutputStream(System.out), true));
			br = new BufferedReader(new InputStreamReader(System.in));
			// br = new BufferedReader(new InputStreamReader(new
			// FileInputStream(new File("input.txt"))));
		}

		public String next() {

			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception e) {
					throw new RuntimeException();
				}
			}
			return st.nextToken();
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public String nextLine() {
			st = null;
			try {
				return br.readLine();
			} catch (Exception e) {
				throw new RuntimeException();
			}
		}

		public boolean endLine() {
			try {
				String next = br.readLine();
				while (next != null && next.trim().isEmpty()) {
					next = br.readLine();
				}
				if (next == null) {
					return true;
				}
				st = new StringTokenizer(next);
				return st.hasMoreTokens();
			} catch (Exception e) {
				throw new RuntimeException();
			}
		}
	}
}

import java.util.*;
import java.io.*;
import static java.lang.Math.*;

public class B{
    public static void main(String[] args) throws Exception{
        new B().run();
    }

    int n;
    String[] cards;
    Set<StringArray> ng = new HashSet<StringArray>();
    boolean ok(StringArray sa){
        //System.out.printf("ok(%s)\n", s);
        if(ng.contains(sa))
            return false;
        int cs = sa.ar.length;
        if(cs == 1)return true;
        char num = sa.ar[0].charAt(0);
        char suit = sa.ar[0].charAt(1);
        if(num == sa.ar[1].charAt(0) || suit == sa.ar[1].charAt(1)){
            StringArray next = new StringArray(cs-1);
            next.ar[0] = sa.ar[0];
            for(int i = 2; i < cs; i++)
                next.ar[i-1] = sa.ar[i];
            if(ok(next))
                return true;
        }
        if(cs >= 4 && (num == sa.ar[3].charAt(0) || suit == sa.ar[3].charAt(1))){
            StringArray next = new StringArray(cs-1);
            next.ar[0] = sa.ar[1];
            next.ar[1] = sa.ar[2];
            next.ar[2] = sa.ar[0];
            for(int i = 4; i < cs; i++)
                next.ar[i-1] = sa.ar[i];
            if(ok(next))
                return true;
        }
        ng.add(sa);
        return false;
    }

    void run() throws Exception{
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        cards = new String[n];
        for(int i = 0; i < n; i++)
            cards[i] = sc.next();
        StringArray sa = new StringArray(n);
        for(int i = n-1; i >= 0; i--)
            sa.ar[i] = cards[i];
        System.out.println(ok(sa) ? "YES" : "NO");
    }
}

class StringArray{
    String[] ar;
    StringArray(int n){
        ar = new String[n];
    }
    @Override public int hashCode(){
        return 0;
    }
    @Override public boolean equals(Object o){
        StringArray sa = (StringArray) o;
        if(ar.length != sa.ar.length)
            return false;
        for(int i = 0; i < ar.length; i++)
            if(!ar[i].equals(sa.ar[i]))
                return false;
        return true;
    }
}

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Round130_B {
    static int N;
    static int a[][];

    public static void main(String[] args) throws Exception {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

        N = Integer.parseInt(in.readLine());
        a = new int[N][2];
        char[] c = new char[26];
        c['T' - 'A'] = 10;
        c['J' - 'A'] = 11;
        c['Q' - 'A'] = 12;
        c['K' - 'A'] = 13;
        c['A' - 'A'] = 14;
        c['S' - 'A'] = 0;
        c['D' - 'A'] = 1;
        c['H' - 'A'] = 2;
        c['C' - 'A'] = 3;
        StringTokenizer tk = new StringTokenizer(in.readLine());
        for (int i = 0; i < N; i++) {
            String s = tk.nextToken();
            char c1 = s.charAt(0);
            if (c1 >= '0' && c1 <= '9')
                a[i][0] = c1 - '0';
            else
                a[i][0] = c[c1 - 'A'];
            a[i][1] = c[s.charAt(1) - 'A'];
        }

        boolean g[][] = new boolean[N][N];
        for (int i = N - 1; i > 2; i--) {
            if ((a[i][0] == a[i - 1][0] || a[i][1] == a[i - 1][1]))
                g[i][i - 1] = g[i - 1][i] = true;
            if ((a[i][0] == a[i - 3][0] || a[i][1] == a[i - 3][1]))
                g[i][i - 3] = g[i - 3][i] = true;
        }
        for(int i = Math.min(2, N-1);i > 0;i--){
        if ((a[i][0] == a[i - 1][0] || a[i][1] == a[i - 1][1]))
            g[i][i - 1] = g[i - 1][i] = true;
        }
        for (int k = 0; k < N; k++)
            for (int i = 0; i < N; i++)
                for (int j = 0; j < N; j++)
                    if (g[i][k] && g[k][j])
                        g[i][j] = true;

        if (g[0][N - 1] || g[N - 1][0])
            System.out.println("YES");
        else
            System.out.println("NO");
    }
}

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.Properties;
import java.util.Stack;

/**
 * Works good for CF
 * @author cykeltillsalu
 */
public class D130 {

	//some local config
	static boolean test = false;
	static String testDataFile = "testdata.txt";
	static String feedFile = "feed.txt";
	CompetitionType type = CompetitionType.CF;
	private static String ENDL = "\n";

	class S {
		int[] cards;

		public S(int[] cards) {
			this.cards = cards;
		}

		@Override
		public String toString() {
			return "S [cards=" + Arrays.toString(cards) + "]";
		}
	}

	// solution
	private void solve() throws Throwable {
		works = false;
		int n = iread();
		int[] card = new int[n];
		cache = new boolean[53][53][53][53];

		for (int i = 0; i < n; i++) {
			String wread = wread();
			int val = toSuite(wread.charAt(1) + "") + toValue(wread.charAt(0));
			card[i] = val;
		}

		rec(card, n - 1);
		if(works){
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
		out.flush();
	}

	private int toValue(char c) {
		switch (c) {
		case 'T':
			return 10;
		case 'J':
			return 11;
		case 'Q':
			return 12;
		case 'K':
			return 13;
		case 'A':
			return 1;

		}
		return c - '0';
	}

	boolean[][][][] cache;
	boolean works = false;

	private void rec(int[] card, int i) {
		int cnt = 0;
		for (int j = i; j >= 0; j--) {
			if(card[j] >= 0){
				cnt ++;
			}
			if(cnt > 1){
				break;
			}
		}
		if(cnt == 1){
			works = true;
			return;
		}
		if(i <= 0){
			return;
		}
		if(card[i] == -1 && i > 0){
			rec(card, i-1);
		}
		if(i >= 2){
			if(cache[i][card[i]+1][card[i-1]+1][card[i-2]+1]){
				return;
			}
			cache[i][card[i]+1][card[i-1]+1][card[i-2]+1] = true;
		}

		int suiteA = suite(card[i]);
		int valueA = value(card[i]);
		if(i >= 3){
			int suiteB = suite(card[i-3]);
			int valueB = value(card[i-3]);
			if(suiteA == suiteB || valueA == valueB){
				int tmp = card[i];
				int tmp2 = card[i-3];
				card[i-3] = card[i];
				card[i] = -1;
				rec(card, i-1);
				card[i-3] = tmp2;
				card[i] = tmp;
			}
		}

		if(suiteA == suite(card[i-1]) || valueA == value(card[i-1])){
			int tmp = card[i];
			int tmp2 = card[i-1];
			card[i-1] = card[i];
			card[i] = -1;
			rec(card, i-1);
			card[i-1] = tmp2;
			card[i] = tmp;
		}
	}

	private int value(int i) {
		return i - suite(i)*13;
	}

	private int suite(int i) {
		return (i/13);
	}

	private int toSuite(String string) {
		if(string.equals("S")){
			return 0;
		}
		if(string.equals("D")){
			return 13*1;
		}
		if(string.equals("H")){
			return 13*2;
		}
		if(string.equals("C")){
			return 13*3;
		}
		return 0;
	}

	public int iread() throws Exception {
		return Integer.parseInt(wread());
	}

	public double dread() throws Exception {
		return Double.parseDouble(wread());
	}

	public long lread() throws Exception {
		return Long.parseLong(wread());
	}

	public String wread() throws IOException {
		StringBuilder b = new StringBuilder();
		int c;
		c = in.read();
		while (c >= 0 && c <= ' ')
			c = in.read();
		if (c < 0)
			return "";
		while (c > ' ') {
			b.append((char) c);
			c = in.read();
		}
		return b.toString();
	}

	public static void main(String[] args) throws Throwable {

		if(test){ //run all cases from testfile:
			BufferedReader testdataReader = new BufferedReader(new FileReader(testDataFile));
			String readLine = testdataReader.readLine();
			int casenr = 0;
			out: while (true) {
				BufferedWriter w = new BufferedWriter(new FileWriter(feedFile));
				if(!readLine.equalsIgnoreCase("input")){
					break;
				}
				while (true) {
					readLine = testdataReader.readLine();
					if(readLine.equalsIgnoreCase("output")){
						break;
					}
					w.write(readLine + "\n");
				}
				w.close();
				System.out.println("Answer on case "+(++casenr)+": ");

				new D130().solve();
				System.out.println("Expected answer: ");

				while (true) {
					readLine = testdataReader.readLine();

					if(readLine == null){
						break out;
					}
					if(readLine.equalsIgnoreCase("input")){
						break;
					}
					System.out.println(readLine);
				}
				System.out.println("----------------");
			}
			testdataReader.close();
		} else { // run on server
			new D130().solve();
		}
		out.close();
	}

	public D130() throws Throwable {
		if (test) {
			in = new BufferedReader(new FileReader(new File(feedFile)));
		}
	}

	InputStreamReader inp = new InputStreamReader(System.in);
	BufferedReader in = new BufferedReader(inp);
	static BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out));

	enum CompetitionType {CF, OTHER};
}

import java.util.*;

public class B {

	private static class Card {
		char face;
		char val;

		public Card(String value) {
			val = value.charAt(0);
			face = value.charAt(1);
		}

		public boolean canPile(Card c) {
			return (c.face == this.face || c.val == this.val);
		}

	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		ArrayList<Card>[] piles = new ArrayList[n];
		for (int i = 0; i < n; i++) {
			piles[i] = new ArrayList<Card>();
			piles[i].add(new Card(sc.next()));
		}

		for (int i = n-1; i >= 1; i--) {
			if (piles[i].isEmpty())
				continue;

			boolean success = false;
			if (i - 1 > -1 && piles[i-1].size() > 0) {
				if (piles[i].get(0).canPile(piles[i - 1].get(0))) {
					piles[i].addAll(piles[i - 1]);
					piles[i - 1] = piles[i];
					piles[i].clear();
					success = true;
				}
			}

			if (!success)
				if (i - 3 > -1  && piles[i-3].size() > 0) {
					if (piles[i].get(0).canPile(piles[i - 3].get(0))) {
						piles[i].addAll(piles[i - 3]);
						piles[i - 3] = piles[i];
						piles[i].clear();
						success = true;
					}
				}

			if (!success) {
				System.out.println("NO");
				System.exit(0);
			}
		}
		System.out.println("YES");
		System.exit(0);
	}
}

import java.util.*;
import java.io.*;

public class Main {
    public static void main(String arg[])
    {
        new Main();
    }
    private TreeMap<State,Boolean> f;
    private class State implements Comparable<State>
    {
        private int x;
        String last_three_cards[];
        public State(String cards[],int x)
        {
            this.last_three_cards=new String[3];
            for (int i=0;i<3;i++)
            {
                if (x-3+i>=0) this.last_three_cards[i]=cards[x-3+i];
                else this.last_three_cards[i]=null;
            }
            this.x=x;
        }
        public String toString()
        {
            String s=new String();
            for (int i=0;i<3;i++)
            {
                if (last_three_cards[i]!=null)
                    s+=last_three_cards[i];
            }
            s+="|"+x;
            return s;
        }
        public int compareTo(State other)
        {
            return toString().compareTo(other.toString());
        }
    }
    private boolean dfs(String cards[],int x)
    {
        State s=new State(cards,x);
        if (f.get(s)==null)
        {
            if (x>=4)
            {
                if (cards[x-1].charAt(0)==cards[x-4].charAt(0)||cards[x-1].charAt(1)==cards[x-4].charAt(1))
                {
                    cards[x-4]=cards[x-1];
                    String backup=cards[x-4];
                    if (dfs(cards,x-1)) f.put(s,true);
                    cards[x-4]=backup;
                }
                if (f.get(s)==null&&cards[x-1].charAt(0)==cards[x-2].charAt(0)||cards[x-1].charAt(1)==cards[x-2].charAt(1))
                {
                    cards[x-2]=cards[x-1];
                    String backup=cards[x-2];
                    if (dfs(cards,x-1)) f.put(s,true);
                    cards[x-2]=backup;
                }
                if (f.get(s)==null) f.put(s,false);
            }
            else if (x>=2)
            {
                if (cards[x-1].charAt(0)==cards[x-2].charAt(0)||cards[x-1].charAt(1)==cards[x-2].charAt(1))
                {
                    cards[x-2]=cards[x-1];
                    String backup=cards[x-2];
                    if (dfs(cards,x-1)) f.put(s,true);
                    cards[x-2]=backup;
                }
                if (f.get(s)==null) f.put(s,false);
            }
            else f.put(s,true);
        }
        return f.get(s);
    }
    public Main()
    {
        Scanner cin=new Scanner(new BufferedInputStream(System.in));
        int x=cin.nextInt();
        String cards[]=new String[x];
        for (int i=0;i<x;i++)
            cards[i]=cin.next();
        f=new TreeMap<State,Boolean>();
        System.out.println(dfs(cards,x)?"YES":"NO");
        cin.close();
    }
}

import java.util.*;

public class B {

	private static class Card {
		char face;
		char val;

		public Card(String value) {
			val = value.charAt(0);
			face = value.charAt(1);
		}

		public Card(Card c) {
			this.val = new Character(c.val);
			this.face = new Character(c.face);
		}

		public boolean canPile(Card c) {
			return (c.face == this.face || c.val == this.val);
		}

		public String toString() {
			return val + "" + face;
		}
	}

	private static Card[] piles;
	private static int n;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		piles = new Card[n];
		for (int i = 0; i < n; i++) {
			piles[i] = new Card(sc.next());
		}

		//Do x-1 as much as possible.
		int found = 0;
		for (int i=n-1; i>=0; i--) {
			if (i-1 >= 0) {
				if (piles[i].canPile(piles[i-1])) {
					piles[i-1] = piles[i];
					found++;
				}
			}
		}
		piles = Arrays.copyOfRange(piles,0,n-found);
		n = n-found;

		dfs(0, n - 1);
		System.out.println("NO");
		System.exit(0);
	}

	private static void dfs(int count, int idx) {
		if (idx < 0) {
			return;
		}

		if (count == n - 1) {
			System.out.println("YES");
			System.exit(0);
		}

		if (idx - 1 > -1 && piles[idx - 1] != null) {
			if (piles[idx].canPile(piles[idx - 1])) {
				Card B = piles[idx - 1];
				piles[idx - 1] = piles[idx];
				piles[idx] = null;
				dfs(count + 1, idx - 1);
				piles[idx] = piles[idx - 1];
				piles[idx - 1] = B;
			}
		}

		if (idx - 3 > -1 && piles[idx - 3] != null) {
			if (piles[idx].canPile(piles[idx - 3])) {
				Card B = piles[idx - 3];
				piles[idx - 3] = piles[idx];
				piles[idx] = null;
				dfs(count + 1, idx - 1);
				piles[idx] = piles[idx - 3];
				piles[idx - 3] = B;
			}
		}
	}
}

import java.util.*;
import java.io.*;
public class a {
  static long mod  = 1000000007;
public static void main(String[] args) throws IOException
{
  input.init(System.in);
  PrintWriter out = new PrintWriter(new PrintStream(System.out));
  //input.init(new FileInputStream(new File("input.txt")));
  //PrintWriter out = new PrintWriter(new File("output.txt"));
  int n = input.nextInt();
  char[] nums = new char[n];
  char[] suits = new char[n];
  for(int i = 0; i<n; i++)
  {
    String s = input.next();
    nums[i] = s.charAt(0);
    suits[i] = s.charAt(1);
  }
  dp = new short[n][n][n][n];
  for(short[][][] A:dp)
    for(short[][] B:A)
      for(short[]C:B)
        Arrays.fill(C, (short)-1);
  out.println(go(n, n-1, n-2, n-3, suits, nums) > 0 ? "YES" : "NO");

  out.close();
}
static short[][][][] dp;
static short go(int num, int top, int second, int third, char[] suits, char[] nums)
{
  if(num==1) return 1;
  if(num == 2)
    return (short) ((nums[top] == nums[second] || suits[top] == suits[second]) ? 1 : 0);
  if(num==3)
    return (short) (((nums[top] == nums[second] || suits[top] == suits[second])
        && (nums[top] == nums[third] || suits[top] == suits[third])) ? 1 : 0);
  if(dp[num-1][top][second][third] != -1) return dp[num-1][top][second][third];
  if((nums[top] == nums[second] || suits[top] == suits[second]) && go(num-1,top,num-2, num-3, suits, nums)>0)
    return dp[num-1][top][second][third]=1;
  if(num >= 3)
    if((nums[top] == nums[second] || suits[top] == suits[second]) && go(num-1,second,third, top, suits, nums)>0)
      return dp[num-1][top][second][third]=1;
  return dp[num-1][top][second][third]=0;
}
static long[][] comb(int n)
{
  long[][] res = new long[n+1][n+1];
  Arrays.fill(res[0], 0);
  for(int i = 0; i<=n; i++) res[i][0] = 1;
  for(int i = 1; i<=n; i++)
    for(int j = 1; j<=n; j++)
      res[i][j] = (res[i-1][j-1] + res[i-1][j])%mod;
  return res;
}
static long gcd(long a, long b)
{
  if(b==0) return a;
  return gcd(b, a%b);
}
static long pow(long a, long p)
{
  if(p<=0) return 1;
  if((p&1) == 0)
  {
    long sqrt = pow(a, p/2);
    return (sqrt*sqrt)%mod;
  }
  else
    return (a*pow(a,p-1))%mod;
}
static class input {
  static BufferedReader reader;
  static StringTokenizer tokenizer;

  /** call this method to initialize reader for InputStream */
  static void init(InputStream input) {
      reader = new BufferedReader(
                   new InputStreamReader(input) );
      tokenizer = new StringTokenizer("");
  }
  public static boolean hasNext() {
    // TODO(mkirsche): Auto-generated method stub
    return tokenizer.hasMoreTokens();
  }

  /** get next word */
  static String next() throws IOException {
      while ( ! tokenizer.hasMoreTokens() ) {
          //TODO add check for eof if necessary
          tokenizer = new StringTokenizer(
                 reader.readLine() );
      }
      return tokenizer.nextToken();
  }

  static int nextInt() throws IOException {
      return Integer.parseInt( next() );
  }
  static long nextLong() throws IOException {
    return Long.parseLong( next() );
}

  static double nextDouble() throws IOException {
      return Double.parseDouble( next() );
  }
  static String nextLine() throws IOException {
    return reader.readLine();
  }
}
}

import java.util.*;

public class T208B {
	public static Set<String> mem;

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n_cards = in.nextInt();
		String cards = "";
		for (int i = 0; i < n_cards; ++i) cards += in.next();
		mem = new TreeSet<String>();
		if (recurse(cards, n_cards * 2)) System.out.println("YES");
		else System.out.println("NO");
	}

	public static boolean recurse(String s, int n) {
		if (n == 2) return true;
		if (mem.contains(s)) return false;
		mem.add(s);

		if (n >= 4)
			if (s.charAt(n - 2) == s.charAt(n - 4) || s.charAt(n - 1) == s.charAt(n - 3)) {
				String nx = s.substring(0, n - 4) + s.substring(n - 2);
				if (recurse(nx, n - 2)) return true;
			}
		if (n >= 8)
			if (s.charAt(n - 2) == s.charAt(n - 8) || s.charAt(n - 1) == s.charAt(n - 7)) {
				String nx = s.substring(0, n - 7) + s.substring(n - 2) + s.substring(n - 6, n - 2);
				if (recurse(nx, n - 2)) return true;
			}

		return false;
	}
}

import java.util.*;
import java.io.*;

public class Main{

	int n;
	String s[];
	int dp[][][][];
	public void run(){
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		s = new String[n];
		for(int i=0;i<n;i++) s[i] = in.next();
		dp = new int[n+1][n+1][n+1][n+1];
		for(int i=0;i<=n;i++)
			for(int j=0;j<=n;j++)
				for(int k=0;k<=n;k++)
					Arrays.fill(dp[i][j][k], -1);

		if (dfs(n-1, n-3, n-2, n-1) == 1){
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}
	}

	private int dfs(int at, int a, int b, int c){
		if (at == 1){
			if (isOk(b, c))
				return 1;
			return 0;
		}
		if (a < 0 || b < 0 || c < 0)
			return 0;
		if (dp[at][a][b][c] != -1)
			return dp[at][a][b][c];
		int ret = 0;
		if (isOk(b, c)){
			ret = Math.max(ret, dfs(at-1, at-3,a,c));
		}

		if (isOk(c, at-3)){
			ret = Math.max(ret, dfs(at-1, c, a, b));
		}
		return dp[at][a][b][c] = ret;
	}

	private boolean isOk(int a, int b){
		if (a < 0 || b < 0)
			return false;
		return s[a].charAt(0) == s[b].charAt(0) || s[a].charAt(1) == s[b].charAt(1);
	}

	public static void main(String[] args){
		new Main().run();
	}
}

import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.BufferedWriter;
import java.util.Locale;
import java.util.InputMismatchException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Jacob Jiang
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		OutputWriter out = new OutputWriter(outputStream);
		TaskB solver = new TaskB();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskB {
	public void solve(int testNumber, InputReader in, OutputWriter out) {
        int n = in.nextInt();
        String[] cards = in.nextStringArray(n);
        boolean[][] graph = new boolean[n][n];
        for (int i = 0; i < n; i++) {
            if (i >= 1 && match(cards[i], cards[i - 1])) {
                graph[i][i - 1] = true;
            }
            if (i >= 3 && match(cards[i], cards[i - 3])) {
                graph[i][i - 3] = true;
            }
        }
        for (int k = 0; k < n; k++) {
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n; j++) {
                    graph[i][j] |= graph[i][k] && graph[k][j];
                }
            }
        }
        for (int i = 1; i < n; i++) {
            if (!graph[i][0]) {
                out.println("NO");
                return;
            }
        }
        out.print("YES");
    }

    private boolean match(String s1, String s2) {
        return s1.charAt(0) == s2.charAt(0) || s1.charAt(1) == s2.charAt(1);
    }

}

class InputReader {

    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;

    public InputReader(InputStream stream) {
        this.stream = stream;
    }

    public int read() {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    public int nextInt() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        int res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c & 15;
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public String next() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        StringBuilder res = new StringBuilder();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isSpaceChar(c));
        return res.toString();
    }

    public static boolean isSpaceChar(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    public String[] nextStringArray(int count) {
        String[] result = new String[count];
        for (int i = 0; i < count; i++) {
            result[i] = next();
        }
        return result;
    }

    }

class OutputWriter {
    private PrintWriter writer;

    public OutputWriter(OutputStream stream) {
        writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(stream)));
    }

    public OutputWriter(Writer writer) {
        this.writer = new PrintWriter(writer);
    }

    public void println(String x) {
        writer.println(x);
    }

    public void close() {
        writer.close();
    }

    public void print(String s) {
        writer.print(s);
    }

    }

import java.io.*;
import java.util.*;
import java.math.*;

public class Main {
    static boolean find = false;
    static HashSet<String> set = new HashSet<>();
    public static void main(String[] args) throws Exception {
        PrintWriter out = new PrintWriter(System.out,true);
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(in.readLine());
        String[] mas = new String[n];
        StringTokenizer st = new StringTokenizer(in.readLine());
        for(int i = 0;i < n;i++) mas[i] = st.nextToken();
        func(mas,n-1);
        if(find) {
            out.println("YES");
        }else{
            out.println("NO");
        }
    }

    public static void func(String[] mas, int last) {
        String d = Arrays.toString(mas);
        if(set.contains(d)) return;
        set.add(d);
        if(last == 0 || find) find = true;
        if(last > 0 && (mas[last-1].charAt(0) == mas[last].charAt(0) || mas[last-1].charAt(1) == mas[last].charAt(1))) {
            String a = mas[last-1];
            mas[last-1] = mas[last];
            mas[last] = "";
            func(mas,last-1);
            mas[last] = mas[last-1];
            mas[last-1] = a;
        }
        if(last > 2 && (mas[last-3].charAt(0) == mas[last].charAt(0) || mas[last-3].charAt(1) == mas[last].charAt(1))) {
            String a = mas[last-3];
            mas[last-3] = mas[last];
            mas[last] = "";
            func(mas,last-1);
            mas[last] = mas[last-1];
            mas[last-3] = a;
        }
    }
}

import java.io.*;
import java.util.*;
import java.math.*;

public class Main {
    static boolean find = false;
    static TreeSet<Integer> set = new TreeSet<>();
    public static void main(String[] args) throws Exception {
        PrintWriter out = new PrintWriter(System.out,true);
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(in.readLine());
        String[] mas = new String[n];
        StringTokenizer st = new StringTokenizer(in.readLine());
        for(int i = 0;i < n;i++) mas[i] = st.nextToken();
        func(mas,n-1);
        if(find) {
            out.println("YES");
        }else{
            out.println("NO");
        }
    }

    public static void func(String[] mas, int last) {
        int d = (Arrays.toString(mas)+last).hashCode();
        if(set.contains(d)) return;
        set.add(d);
        if(last == 0 || find) find = true;
        if(last > 0 && (mas[last-1].charAt(0) == mas[last].charAt(0) || mas[last-1].charAt(1) == mas[last].charAt(1))) {
            String a = mas[last-1];
            mas[last-1] = mas[last];
            mas[last] = "";
            func(mas,last-1);
            mas[last] = mas[last-1];
            mas[last-1] = a;
        }
        if(last > 2 && (mas[last-3].charAt(0) == mas[last].charAt(0) || mas[last-3].charAt(1) == mas[last].charAt(1))) {
            String a = mas[last-3];
            mas[last-3] = mas[last];
            mas[last] = "";
            func(mas,last-1);
            mas[last] = mas[last-1];
            mas[last-3] = a;
        }
    }
}

import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import java.io.*;
import java.math.*;
import java.text.*;
import java.util.*;

/*
br = new BufferedReader(new FileReader("input.txt"));
pw = new PrintWriter(new BufferedWriter(new FileWriter("output.txt")));
br = new BufferedReader(new InputStreamReader(System.in));
pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
 */

public class Main {
  private static BufferedReader br;
  private static StringTokenizer st;
  private static PrintWriter pw;

  static String[] list;

  public static void main(String[] args) throws IOException {
    br = new BufferedReader(new InputStreamReader(System.in));
    pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    //int qq = 1;
    int qq = Integer.MAX_VALUE;
    //int qq = readInt();
    for(int casenum = 1; casenum <= qq; casenum++)  {
      int n = readInt();
      seen = new HashSet<Integer>();
      list = new String[n];
      for(int i = 0; i < n; i++) {
        list[i] = nextToken();
      }
      pw.println(can(n-1) ? "YES" : "NO");
    }
    pw.close();
  }

  public static boolean can(int n) {
    if(n==0) {
      return true;
    }
    int hash = hash(n);
    if(!seen.add(hash)) return false;
    if(list[n].charAt(0) == list[n-1].charAt(0) || list[n].charAt(1) == list[n-1].charAt(1)) {
      String save = list[n-1];
      list[n-1] = list[n];
      if(can(n-1)) {
        return true;
      }
      list[n-1] = save;
    }
    if(n-3 >= 0 && (list[n].charAt(0) == list[n-3].charAt(0) || list[n].charAt(1) == list[n-3].charAt(1))) {
      String save = list[n-3];
      list[n-3] = list[n];
      if(can(n-3)) {
        return true;
      }
      list[n-3] = save;
    }
    return false;
  }

  static Set<Integer> seen;

  public static int hash(int n) {
    int ret = 0;
    for(int i = 0; i <= n; i++) {
      ret *= 3137;
      ret += list[i].hashCode();
    }
    return ret;
  }

  private static void exitImmediately() {
    pw.close();
    System.exit(0);
  }

  private static long readLong() throws IOException {
    return Long.parseLong(nextToken());
  }

  private static double readDouble() throws IOException {
    return Double.parseDouble(nextToken());
  }

  private static int readInt() throws IOException {
    return Integer.parseInt(nextToken());
  }

  private static String nextToken() throws IOException  {
    while(st == null || !st.hasMoreTokens())  {
      if(!br.ready()) {
        exitImmediately();
      }
      st = new StringTokenizer(br.readLine().trim());
    }
    return st.nextToken();
  }
}

import java.io.*;

public class B {
	int map[];
	int dp[][][][];
	int n;
	String[] rawCards;
	int[] cards;

	int getState(String s){
		int num = map[s.charAt(0)], suit = map[s.charAt(1)];
		return num*5 + suit + 1;
	}

	void init(){
		map = new int[256];
		map['J'] = 8;
		map['Q'] = 9;
		map['K'] = 10;
		map['A'] = 11;
		map['T'] = 12;
		map['S'] = 0;
		map['D'] = 1;
		map['H'] = 2;
		map['C'] = 3;
		for(char ch = '2'; ch <='9'; ch++)
			map[ch] = ch - '2';
	}

	boolean isValid(int s1, int s2){
		if(s2 == 0) return false;
		return s1/5 == s2/5 || s1%5 == s2%5;
	}

	boolean solve(int pos, int a, int b, int c, int d){
		if(pos == 0) return true;
		if(pos<0) return false;

		if(dp[a][b][c][d] != 0)
			return dp[a][b][c][d] == 1;

		int aa = pos-4>=0? cards[pos-4]:0;
		if(isValid(d, a)){
			dp[a][b][c][d] = solve(pos-1, aa, d, b, c)? 1:2;
		}

		if(dp[a][b][c][d]!=1 && isValid(d, c)){
			dp[a][b][c][d] = solve(pos-1, aa, a, b, d)? 1:2;
		}

		return dp[a][b][c][d]==1;
	}

	void run() throws IOException{
		init();
		dp = new int[70][70][70][70];

		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		n = Integer.parseInt(bf.readLine());
		rawCards = bf.readLine().trim().split("[ ]+");

//		String[] arg1 = new String[]{"2","3","4","5","6","7","8","9","J","Q","K","A"};
//		String[] arg2 = new String[]{"S","D","H","C"};
//		n = 48;
//		int sz=0;
//		rawCards = new String[n];
//		for(int i=0; i<arg1.length; i++){
//			for(int j=0; j<4; j++){
//				rawCards[sz++] = arg1[i]+arg2[j];
//				System.out.print(rawCards[sz-1] + ", ");
//			}System.out.println();
//		}System.out.println(sz);
		cards = new int[n];
		for(int i=0; i<n; i++) cards[i] = getState(rawCards[i]);

		int a, b, c, d;
		a = n<4? 0:cards[n-4];
		b = n<3? 0:cards[n-3];
		c = n<2? 0:cards[n-2];
		d = cards[n-1];
		System.out.println(solve(n-1, a, b, c, d)? "YES" : "NO");
//		for(int i=0; i<n; i++) System.out.println(cards[i]/12 + ", " + cards[i]%12);
	}

	public static void main(String[] args) throws IOException{
		new B().run();
	}
}

import java.util.*;
import java.io.*;

public class B {

	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer st;

	int n;
	String[] s;
	Map<String[], Boolean> cache;

	boolean dfs(String[] ss, int d) {

		if (d == 1) {
			return true;
		}
		if (cache.containsKey(ss)) {
			return cache.get(ss);
		}

		String[] s2 = new String[ss.length - 1];

		int i = ss.length - 1;
		if (i >= 1
				&& (ss[i].charAt(0) == ss[i - 1].charAt(0) || ss[i].charAt(1) == ss[i - 1]
						.charAt(1))) {

			for(int j = 0; j < i; ++j) {
				s2[j] = ss[j];
			}
			s2[i - 1] = ss[i];
			if (dfs(s2, d - 1)) {
				cache.put(ss, true);
				return true;
			}
		}
		if (i >= 3
				&& (ss[i].charAt(0) == ss[i - 3].charAt(0) || ss[i]
						.charAt(1) == ss[i - 3].charAt(1))) {

			for(int j = 0; j < i; ++j) {
				s2[j] = ss[j];
			}
			s2[i - 3] = ss[i];
			if (dfs(s2, d - 1)) {
				cache.put(ss, true);
				return true;
			}
		}
		cache.put(ss, false);
		return false;
	}

	public void solve() throws IOException {
		n = nextInt();
//		n = 50;
		s = new String[n];
		cache = new HashMap<String[], Boolean>();
//		Random rng = new Random();
		for (int i = 0; i < n; ++i) {
			s[i] = next();
//			s[i] = "";
//			s[i] += rng.nextInt(10);
//			s[i] += rng.nextInt(10);
		}
//		debug(s);
		if (dfs(s, n)) {
			out.println("YES");
		} else {
			out.println("NO");
		}
	}

	B() throws IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		//in = new BufferedReader(new InputStreamReader(new FileInputStream("Main.in")));
		out = new PrintWriter(System.out);
		eat("");

		solve();

		out.close();
	}

	void eat(String s) {
		st = new StringTokenizer(s);
	}

	String nextLine() {
		try {
			return in.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

	boolean hasNext() {
		while (!st.hasMoreTokens()) {
			String s = nextLine();
			if (s == null)
				return false;
			eat(s);
		}
		return true;
	}

	String next() {
		hasNext();
		return st.nextToken();
	}

	int nextInt() {
		return Integer.parseInt(next());
	}

	long nextLong() {
		return Long.parseLong(next());
	}

	double nextDouble() {
		return Double.parseDouble(next());
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}

	public static void main(String[] args) throws IOException {
		new B();
	}
}

import java.util.*;
import java.io.*;

public class b {
   static Map<String, Boolean> dp = new HashMap<String, Boolean>();

   static String make(String[] pa) {
      String s = "";
      for(String t : pa)
         s += t + " ";
      return s.trim();
   }

   static boolean is(String s, String t) {
      return s.charAt(0) == t.charAt(0) || s.charAt(1) == t.charAt(1);
   }

   static boolean doit(String[] pa) {
      if(pa.length == 1) return true;
      String s = make(pa);
      if(dp.get(s) != null) return dp.get(s);
      boolean r = false;
      int k = pa.length - 1;
      if(k - 1 > 0 && is(pa[k], pa[k - 1])) {
         String[] ne = new String[k];
         System.arraycopy(pa, 0, ne, 0, k);
         ne[k - 1] = pa[k];
         r = r | doit(ne);
      }
      if(k - 3 > 0 && is(pa[k], pa[k - 3])) {
         String[] ne = new String[k];
         System.arraycopy(pa, 0, ne, 0, k);
         pa[k - 3] = pa[k];
         r = r | doit(ne);
      }
      dp.put(s, r);
      return r;
   }

   public static void main(String[] args) throws IOException {
      //BufferedReader br = new BufferedReader(new FileReader("b.in"));
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      String line = br.readLine();
      int n = Integer.parseInt(line);
      line = br.readLine();
      boolean r = doit(line.split(" "));
      System.out.println((r ? "YES" : "NO"));
   }

   static void debug(Object...o) {
      System.err.println(Arrays.deepToString(o));
   }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Scanner;
import java.util.TreeMap;
import java.util.TreeSet;

import sun.reflect.generics.tree.Tree;

import static java.lang.Math.*;

public class A {

    HashMap<Deck, Boolean> decs = new HashMap<Deck, Boolean>();

    boolean can(List<Card> deck) {
        if (deck.size() == 1)
            return true;
        Deck ddeck = new Deck(deck);
        if (decs.containsKey(ddeck))
            return decs.get(ddeck);

        Card last = deck.get(deck.size() - 1);

        boolean cc = false;
        if (deck.get(deck.size() - 2).can(last)) {
            List<Card> deck2 = new ArrayList<Card>();
            deck2.addAll(deck);
            deck2.set(deck.size() - 2, last);
            deck2.remove(last);
            cc |= can(deck2);
        }
        if (deck.size() > 3 && deck.get(deck.size() - 4).can(last)) {
            List<Card> deck2 = new ArrayList<Card>();
            deck2.addAll(deck);
            deck2.set(deck.size() - 4, last);
            deck2.remove(last);
            cc |= can(deck2);
        }

        decs.put(ddeck, cc);
        return cc;

    }

    public void run() throws IOException {

        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));

        int n = Integer.parseInt(bf.readLine());

        String[] s = bf.readLine().split(" ");
        List<Card> cards = new ArrayList<Card>();
        for (int i = 0; i < s.length; i++)
            cards.add(new Card(s[i]));
        System.out.println(can(cards) ? "YES" : "NO");

    }

    public static void main(String[] args) throws IOException {
        A a = new A();
        a.run();
    }
}

class Card {
    char[] c;

    public Card(String s) {
        c = s.toCharArray();
    }

    public boolean can(Card d) {
        return d.c[0] == c[0] || d.c[1] == c[1];
    }

    @Override
    public String toString() {
        return new String(c);
    }

    @Override
    public boolean equals(Object obj) {
        return new String(c).equals(new String(((Card) obj).c));
    }

    @Override
    public int hashCode() {
        return new String(c).hashCode();
    }
}

class Deck {
    List<Card> cards;

    public Deck(List<Card> cards_) {
        this.cards = new ArrayList<Card>();
        this.cards.addAll(cards_);
    }

    @Override
    public boolean equals(Object arg0) {
        List<Card> cards2 = ((Deck) arg0).cards;
        if (cards2.size() != cards.size())
            return false;
        for (int i = 0; i < cards2.size(); i++)
            if (!cards2.get(i).equals(cards.get(i)))
                return false;
        return true;
    }

    @Override
    public int hashCode() {
        int hashCode = 1;
        for (Card e : this.cards)
            hashCode = 31 * hashCode + (e == null ? 0 : e.hashCode());
        return hashCode;
    }
}

import java.util.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

public class  Main  {

	//ArrayList<Integer> lis = new ArrayList<Integer>();
	//ArrayList<String> lis = new ArrayList<String>();
	//ArrayList<test> lis = new ArrayList<test>();
//	static long sum=0;
//	static boolean f=false;
	//static String s[],r="";
//	static int dx[]={1,-1,0,0,1,1,-1,-1};
  //  static int dy[]={0,0,1,-1,1,-1,1,-1},n,m,w=0;
	//static int dp[][][][],co,r=0;
	//throws IOException
	//static char c[][];
	static boolean b=false,me[][][][][];

public  static void main(String[] args)  {
   //googlein.txt C-small-attempt0.in
//	Scanner sc =new Scanner(new File("file.txt"));
	 Scanner sc =new Scanner(System.in);
	  //File file = new File("file.txt");
	//	PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter(file)));
	//	sc.useDelimiter("(\\s)+|[,]");

	  while(sc.hasNext()){
		   //long sum=0;
	//	  int n=sc.nextInt(),m=sc.nextInt(),k=sc.nextInt();
		int   n=sc.nextInt();
		b=false;
	//	db((int)sc.next().charAt(0));
      char  c[][]=new char[2][n];
	 me=new boolean [2][100][100][100][n];
		 for(int i=0;i<n;i++){
			 String s=sc.next();
			 c[0][i]=s.charAt(0);
			 c[1][i]=s.charAt(1);
		 }

		 if( n==1 ){ System.out.println("YES");return;}

		 rep(n-1,c);

	  System.out.println(b? "YES":"NO");

		 }

}
	// db("Case #"+(k)+": "+c);
	 //	pw.println("Case #"+(k)+": "+c);

	 	//pw.flush();
	 	//pw.close();

   static void rep(int a,char p[][]){

	   if( b )return;
	   if(a==0){ b=true; return; }
	  // db(p[0],p[1]);

	   if(2<a && me[0][p[0][a-2]][p[0][a-1]][p[0][a]][a] && me[1][p[1][a-2]][p[1][a-1]][p[1][a]][a] )return;

	   if(  p[0][a]==p[0][a-1]   ||  p[1][a]==p[1][a-1]   ){
	   char np[][]=new char[2][a];
	   for(int i=0;i<a;i++){np[0][i]=p[0][i]; np[1][i]=p[1][i];}  np[0][a-1]=p[0][a];np[1][a-1]=p[1][a];
	     rep(a-1,np ); }

	   if(  0<=a-3 && (  p[0][a]==p[0][a-3]  || p[1][a]==p[1][a-3] ) ){
	   char np[][]=new char[2][a];
	   for(int i=0;i<a;i++){np[0][i]=p[0][i]; np[1][i]=p[1][i];}  np[0][a-3]=p[0][a];np[1][a-3]=p[1][a];
	     rep(a-1,np ); }

	 if(2<a)  me[0][p[0][a-2]][p[0][a-1]][p[0][a]][a] = me[1][p[1][a-2]][p[1][a-1]][p[1][a]][a]=true;

   }

    static void db(Object... os){
	         System.err.println(Arrays.deepToString(os));

	}

}

/*class P implements Comparable<P>{
    int v,vv,t;
	P(int v,int vv,int t){
		this.v=v;
	    this.vv=vv;
	    this.t=t;
	}
	  public int compareTo(P x){
          return t-x.t;
	   }

}*/

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Scanner;
import java.util.TreeMap;
import java.util.TreeSet;

import sun.reflect.generics.tree.Tree;

import static java.lang.Math.*;

public class A {

    HashMap<Deck, Boolean> decs = new  HashMap<Deck, Boolean>();
    boolean can(List<Card> deck) {
        if (deck.size() == 1)
            return true;
        Deck ddeck = new Deck(deck);
        if(decs.containsKey(ddeck))
            return decs.get(ddeck);

        Card last = deck.get(deck.size() - 1);

        boolean cc = false;
        if (deck.get(deck.size() - 2).can(last)) {
            List<Card> deck2 = new ArrayList<Card>();
            deck2.addAll(deck);
            deck2.set(deck.size() - 2, last);
            deck2.remove(last);
            cc |= can(deck2);
        }
        if (deck.size() > 3 && deck.get(deck.size() - 4).can(last)) {
            List<Card> deck2 = new ArrayList<Card>();
            deck2.addAll(deck);
            deck2.set(deck.size() - 4, last);
            deck2.remove(last);
            cc |= can(deck2);
        }

        decs.put(ddeck, cc);
        return cc;

    }

    public void run() throws IOException {

        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));

        int n = Integer.parseInt(bf.readLine());

        String[] s = bf.readLine().split(" ");
        List<Card> cards = new ArrayList<Card>();
        for(int i=0; i<s.length; i++)
            cards.add(new  Card(s[i]));
        System.out.println(can(cards) ? "YES" :  "NO");

    }

    public static void main(String[] args) throws IOException {
        A a = new A();
        a.run();
    }
}

class Card {
    char[] c;

    public Card(String s) {
        c = s.toCharArray();
    }

    public boolean can(Card d) {
        return d.c[0] == c[0] || d.c[1] == c[1];
    }

    @Override
    public String toString() {
        return new String(c);
    }
    @Override
    public boolean equals(Object obj) {
        return super.equals(obj);
    }

    @Override
    public int hashCode() {
        return new String(c).hashCode();
    }
}

class Deck{
    List<Card> cards;
    public Deck(List<Card> cards_){
        this.cards = new ArrayList<Card>();
        this.cards.addAll(cards_);
    }

    @Override
    public boolean equals(Object arg0) {
        List<Card> cards2  = ((Deck) arg0).cards;
        if(cards2.size()!=cards.size()) return false;
        for(int i=0; i<cards2.size(); i++)
            if(!cards2.get(i).equals(cards.get(i)))
                return false;
        return true;
    }

    @Override
    public int hashCode() {

        return cards.hashCode();
    }
}

import java.util.*;
import java.io.*;

public class B {

	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer st;

	int n;
	String[] s;

	boolean dfs(String[] ss, int d) {

		if (d == 1) {
			return true;
		}
		String[] s2 = new String[ss.length - 1];

		for(int i = 0; i < ss.length; ++i) {
			if (i >= 1 && (ss[i].charAt(0) == ss[i-1].charAt(0) || ss[i].charAt(1) == ss[i-1].charAt(1))) {
				for(int j = 0; j < i; ++j) {
					s2[j] = ss[j];
				}
				for(int j = i+1; j < ss.length; ++j) {
					s2[j-1] = ss[j];
				}
				s2[i-1] = ss[i];
				if (dfs(s2, d-1)) return true;
			}
			if (i >= 3 && (ss[i].charAt(0) == ss[i].charAt(0) || ss[i-3].charAt(1) == ss[i-3].charAt(1))) {
				for(int j = 0; j < i; ++j) {
					s2[j] = ss[j];
				}
				for(int j = i+1; j < ss.length; ++j) {
					s2[j-1] = ss[j];
				}
				s2[i-3] = ss[i];
				if (dfs(s2, d-1)) return true;
			}
		}
		return false;
	}

	public void solve() throws IOException {
		n = nextInt();
		s = new String[n];
		for(int i = 0; i < n; ++i) {
			s[i] = next();
		}
		if (dfs(s, n)) {
			out.println("YES");
		}
		else {
			out.println("NO");
		}
	}

	B() throws IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		//in = new BufferedReader(new InputStreamReader(new FileInputStream("Main.in")));
		out = new PrintWriter(System.out);
		eat("");

		solve();

		out.close();
	}

	void eat(String s) {
		st = new StringTokenizer(s);
	}

	String nextLine() {
		try {
			return in.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

	boolean hasNext() {
		while (!st.hasMoreTokens()) {
			String s = nextLine();
			if (s == null)
				return false;
			eat(s);
		}
		return true;
	}

	String next() {
		hasNext();
		return st.nextToken();
	}

	int nextInt() {
		return Integer.parseInt(next());
	}

	long nextLong() {
		return Long.parseLong(next());
	}

	double nextDouble() {
		return Double.parseDouble(next());
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}

	public static void main(String[] args) throws IOException {
		new B();
	}
}

import java.io.*;
import java.util.*;

import static java.lang.Math.max;
import static java.lang.Math.min;

public class Code implements Runnable {

    public static void main(String[] args) throws IOException {
        new Thread(new Code()).start();
    }

    String[] cards;
    TreeMap<Character, TreeSet<Character>> used[];

    boolean dfs(int pos, int rem, char[][] last) {
        if(rem == 0)    return true;
        int lastElement = -1;
        for(int i = last.length - 1; i >= 0; --i) {
            if(last[i][0] != 0) {
                lastElement = i;
                break;
            }
        }
        char[][] lastCopy = new char[last.length][2];
        for(int i = 0; i < last.length; ++i)    lastCopy[i] = Arrays.copyOf(last[i], 2);
        if(lastElement < 3) {
            if(lastElement > 0) {
                if(last[lastElement][0] == last[lastElement - 1][0] || last[lastElement][1] == last[lastElement - 1][1]) {
                    last[lastElement - 1] = Arrays.copyOf(last[lastElement], 2);
                    last[lastElement][0] = 0;
                    return dfs(pos - 1, rem - 1, last);
                } else  return false;
            } else  return true;
        }

        if(/*!(used[pos - 1].containsKey(last[lastElement][0]) && used[pos - 1].get(last[lastElement][0]).contains(last[lastElement][1])) &&*/
          (cards[pos - 1].charAt(0) == last[lastElement][0] || cards[pos - 1].charAt(1) == last[lastElement][1])) {
            if(lastElement != 0)    last[lastElement - 1] = Arrays.copyOf(last[lastElement], 2);
            if(pos - 4 < 0) last[lastElement][0] = 0;
            else {
                for(int i = last.length - 1; i > 0; --i)    last[i] = Arrays.copyOf(last[i - 1], 2);
                last[0][0] = cards[pos - 4].charAt(0);
                last[0][1] = cards[pos - 4].charAt(1);
            }
            /*if(used[pos - 1].containsKey(last[lastElement][0])) used[pos - 1].get(last[lastElement][0]).add(last[lastElement][1]);
            else {
                used[pos - 1].put(last[lastElement][0], new TreeSet<Character>());
                used[pos - 1].get(last[lastElement][0]).add(last[lastElement][1]);
            }                          */
            if(dfs(pos - 1, rem - 1, last)) return true;
        }
        if(pos - 3 < 0) return false;
        for(int i = 0; i < last.length; ++i)    last[i] = Arrays.copyOf(lastCopy[i], 2);
        if(!(used[pos - 3].containsKey(last[lastElement][0]) && used[pos - 3].get(last[lastElement][0]).contains(last[lastElement][1])) &&
          (cards[pos - 3].charAt(0) == last[lastElement][0] || cards[pos - 3].charAt(1) == last[lastElement][1])) {
            last[0] = Arrays.copyOf(last[lastElement], 2);
            if(pos - 4 < 0) last[lastElement][0] = 0;
            else {
                for(int i = last.length - 1; i > 0; --i)    last[i] = Arrays.copyOf(last[i - 1], 2);
                last[0][0] = cards[pos - 4].charAt(0);
                last[0][1] = cards[pos - 4].charAt(1);
            }
            if(used[pos - 3].containsKey(last[lastElement][0])) used[pos - 3].get(last[lastElement][0]).add(last[lastElement][1]);
            else {
                used[pos - 3].put(last[lastElement][0], new TreeSet<Character>());
                used[pos - 3].get(last[lastElement][0]).add(last[lastElement][1]);
            }
            return dfs(pos - 1, rem - 1, last);
        }
        return false;
    }

    private void solve() throws IOException {
        int n = nextInt();

        cards = new String[n];
        for(int i = 0; i < n; ++i)  cards[i] = nextToken();

        char[][] last = new char[min(4, n)][2];
        for(int i = max(n - 4, 0); i < n; ++i) {
            last[i - max(n - 4, 0)][0] = cards[i].charAt(0);
            last[i - max(n - 4, 0)][1] = cards[i].charAt(1);
        }
        used = new TreeMap[n];
        for(int i = 0; i < n; ++i)  used[i] = new TreeMap<Character, TreeSet<Character>>();
        writer.println(dfs(n - 1, n - 1, last) ? "YES" : "NO");
    }

    private class Pair<E extends Comparable, V extends Comparable> implements Comparable<Pair<E, V>> {
        public Pair(E first, V second) {
            this.first = first;
            this.second = second;
        }

        @Override
        public int compareTo(Pair<E, V> obj) {
            if(first == obj.first)  return second.compareTo(obj.second);
            return first.compareTo(obj.first);
        }

        @Override
        public boolean equals(Object obj) {
            Pair other = (Pair)obj;
            return first.equals(other.first) && second.equals(other.second);
        }

        public E first;
        public V second;
    }

    @Override
    public void run() {
        try {
            if(in.equals(""))   reader = new BufferedReader(new InputStreamReader(System.in));
            else    reader = new BufferedReader(new FileReader(in));

            if(out.equals(""))  writer = new PrintWriter(new OutputStreamWriter(System.out));
            else    writer = new PrintWriter(new FileWriter(out));
            solve();
        } catch(IOException e) {
            e.printStackTrace();
        } finally {
            try {
                reader.close();
                writer.close();
            } catch(IOException e) {
                e.printStackTrace();
            }
        }
    }

    private int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    private long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    private double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    private float nextFloat() throws IOException {
        return Float.parseFloat(nextToken());
    }

    private String nextToken() throws IOException {
        while(st == null || !st.hasMoreTokens())    st = new StringTokenizer(reader.readLine());
        return st.nextToken();
    }

    private String in = "", out = "";
    private BufferedReader reader;
    private PrintWriter writer;
    private StringTokenizer st;
}

import java.util.*;

public class B {

	private static class Card {
		char face;
		char val;

		public Card(String value) {
			val = value.charAt(0);
			face = value.charAt(1);
		}

		public Card(Card c) {
			this.val = new Character(c.val);
			this.face = new Character(c.face);
		}

		public boolean canPile(Card c) {
			return (c.face == this.face || c.val == this.val);
		}

		public String toString() {
			return val + "" + face;
		}
	}

	private static Card[] piles;
	private static int n;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		piles = new Card[n];
		for (int i = 0; i < n; i++) {
			piles[i] = new Card(sc.next());
		}

		//Do x-1 as much as possible.
		int found = 0;
		for (int i=n-1; i>=0; i--) {
			if (i-1 >= 0) {
				if (piles[i].canPile(piles[i-1])) {
					piles[i-1] = piles[i];
					found++;
				}
			}
		}
		piles = Arrays.copyOfRange(piles,0,n-found);
		n = n-found;

		dfs(0, n - 1);
		System.out.println("NO");
		System.exit(0);
	}

	private static void dfs(int count, int idx) {
		if (idx < 0) {
			return;
		}

		if (count == n - 1) {
			System.out.println("YES");
			System.exit(0);
		}

		if (idx - 1 > -1 && piles[idx - 1] != null) {
			if (piles[idx].canPile(piles[idx - 1])) {
				Card B = piles[idx - 1];
				piles[idx - 1] = piles[idx];
				piles[idx] = null;
				dfs(count + 1, idx - 1);
				piles[idx] = piles[idx - 1];
				piles[idx - 1] = B;
			}
		}

		if (idx - 3 > -1 && piles[idx - 3] != null) {
			if (piles[idx].canPile(piles[idx - 3])) {
				Card B = piles[idx - 3];
				piles[idx - 3] = piles[idx];
				piles[idx] = null;
				dfs(count + 1, idx - 1);
				piles[idx] = piles[idx - 3];
				piles[idx - 3] = B;
			}
		}
	}
}

import java.util.*;

public class B {

	private static class Card {
		char face;
		char val;

		public Card(String value) {
			val = value.charAt(0);
			face = value.charAt(1);
		}

		public boolean canPile(Card c) {
			return (c.face == this.face || c.val == this.val);
		}

		public String toString() {
			return val + "" + face;
		}
	}

	private static Card[] piles;
	private static int n;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		piles = new Card[n];
		for (int i = 0; i < n; i++) {
			piles[i] = new Card(sc.next());
		}

		Card last = piles[n-1];
		for (int i=0; i<n; i++) {
			if (!last.canPile(piles[i])) {
				System.out.println("NO");
				System.exit(0);
			}
		}
		System.out.println("YES");
		System.exit(0);
	}

}

/*
 * @author derrick20
 */
import java.io.*;
import java.util.*;

public class solitaire {
    public static void main(String args[]) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int N = sc.nextInt();

        char[] suit = new char[N];
        int[] val = new int[N];
        for (int i = 0; i < N; i++) {
            String s = sc.next();
            val[i] = Character.getNumericValue(s.charAt(0));
            suit[i] = s.charAt(1);
        }

        // dp[i] stores whether it is possible to make solitaire from the i indexed card down
        boolean[] dp = new boolean[N];
        dp[0] = true;
        for (int i = 1; i < N; i++) {
            dp[i] = val[i] == val[i - 1] || suit[i] == suit[i - 1];
            if (i >= 3) {
                dp[i] = val[i] == val[i - 3] || suit[i] == suit[i - 3];
            }
        }
        out.println(dp[N - 1] ? "YES" : "NO");
        out.close();
    }

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        FastScanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        FastScanner(FileReader s) {
            br = new BufferedReader(s);
        }

        String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        String nextLine() throws IOException {
            return br.readLine();
        }

        double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }

        int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        long nextLong() throws IOException {
            return Long.parseLong(next());
        }
    }
}

import java.util.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

public class  Main  {

	//ArrayList<Integer> lis = new ArrayList<Integer>();
	//ArrayList<String> lis = new ArrayList<String>();
	//ArrayList<test> lis = new ArrayList<test>();
//	static long sum=0;
//	static boolean f=false;
	//static String s[],r="";
//	static int dx[]={1,-1,0,0,1,1,-1,-1};
  //  static int dy[]={0,0,1,-1,1,-1,1,-1},n,m,w=0;
	//static int dp[][][][],co,r=0;
	//throws IOException
	//static char c[][];
	static boolean b=false;

public  static void main(String[] args)  {
   //googlein.txt C-small-attempt0.in
//	Scanner sc =new Scanner(new File("file.txt"));
	 Scanner sc =new Scanner(System.in);
	  //File file = new File("file.txt");
	//	PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter(file)));
	//	sc.useDelimiter("(\\s)+|[,]");

	  while(sc.hasNext()){
		   //long sum=0;
	//	  int n=sc.nextInt(),m=sc.nextInt(),k=sc.nextInt();
		int   n=sc.nextInt();
		b=false;
      char  c[][]=new char[2][n];

		 for(int i=0;i<n;i++){
			 String s=sc.next();
			 c[0][i]=s.charAt(0);
			 c[1][i]=s.charAt(1);
		 }

		 if( n==1 ){ System.out.println("YES");return;}

		 rep(n-1,c);

	  System.out.println(b? "YES":"NO");

		 }

}
	// db("Case #"+(k)+": "+c);
	 //	pw.println("Case #"+(k)+": "+c);

	 	//pw.flush();
	 	//pw.close();

   static void rep(int a,char p[][]){

	   if( b )return;
	   if(a==0){ b=true; return; }

	   if(  p[0][a]==p[0][a-1]   ||  p[1][a]==p[1][a-1]   ){ char np[][]=new char[2][p[0].length];
	   for(int i=0;i<p[0].length;i++){np[0][i]=p[0][i]; np[1][i]=p[1][i];}  np[0][a-1]=p[0][a];np[1][a-1]=p[1][a];
	     rep(a-1,np ); }

	   else  if(  0<=a-3 && (  p[0][a]==p[0][a-3]  || p[1][a]==p[1][a-3] ) ){ char np[][]=new char[2][p[0].length];
	   for(int i=0;i<p[0].length;i++){np[0][i]=p[0][i]; np[1][i]=p[1][i];}  np[0][a-3]=p[0][a];np[1][a-3]=p[1][a];
	     rep(a-1,np ); }

   }

    static void db(Object... os){
	         System.err.println(Arrays.deepToString(os));

	}

}

/*class P implements Comparable<P>{
    int v,vv,t;
	P(int v,int vv,int t){
		this.v=v;
	    this.vv=vv;
	    this.t=t;
	}
	  public int compareTo(P x){
          return t-x.t;
	   }

}*/

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class CodeD
{
	static class Scanner
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		public String nextLine()
		{
			try
			{
				return br.readLine();
			}
			catch(Exception e)
			{
				throw(new RuntimeException());
			}
		}

		public String next()
		{
			while(!st.hasMoreTokens())
			{
				String l = nextLine();
				if(l == null)
					return null;
				st = new StringTokenizer(l);
			}
			return st.nextToken();
		}

		public int nextInt()
		{
			return Integer.parseInt(next());
		}

		public long nextLong()
		{
			return Long.parseLong(next());
		}

		public double nextDouble()
		{
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n)
		{
			int[] res = new int[n];
			for(int i = 0; i < res.length; i++)
				res[i] = nextInt();
			return res;
		}

		public long[] nextLongArray(int n)
		{
			long[] res = new long[n];
			for(int i = 0; i < res.length; i++)
				res[i] = nextLong();
			return res;
		}

		public double[] nextDoubleArray(int n)
		{
			double[] res = new double[n];
			for(int i = 0; i < res.length; i++)
				res[i] = nextLong();
			return res;
		}
		public void sortIntArray(int[] array)
		{
			Integer[] vals = new Integer[array.length];
			for(int i = 0; i < array.length; i++)
				vals[i] = array[i];
			Arrays.sort(vals);
			for(int i = 0; i < array.length; i++)
				array[i] = vals[i];
		}

		public void sortLongArray(long[] array)
		{
			Long[] vals = new Long[array.length];
			for(int i = 0; i < array.length; i++)
				vals[i] = array[i];
			Arrays.sort(vals);
			for(int i = 0; i < array.length; i++)
				array[i] = vals[i];
		}

		public void sortDoubleArray(double[] array)
		{
			Double[] vals = new Double[array.length];
			for(int i = 0; i < array.length; i++)
				vals[i] = array[i];
			Arrays.sort(vals);
			for(int i = 0; i < array.length; i++)
				array[i] = vals[i];
		}

		public String[] nextStringArray(int n)
		{
			String[] vals = new String[n];
			for(int i = 0; i < n; i++)
				vals[i] = next();
			return vals;
		}
	}

	static String valores = "23456789TJQKA";
	static String pintas = "SDHC";

	static class Carta
	{
		int pinta;
		int valor;

		Carta(String s)
		{
			valor = valores.indexOf(s.charAt(0));
			pinta = pintas.indexOf(s.charAt(1));
		}
	}

	static Carta[] cartas;
	static Boolean[][][][] dp = new Boolean[52][52][52][52];

	static boolean dp(int n, int primera, int segunda, int tercera)
	{
		if(dp[n][primera][segunda][tercera] != null)
			return dp[n][primera][segunda][tercera];
		if(n == 3)
			return dp[n][primera][segunda][tercera] = esPosible(primera, segunda, tercera);
		if(compatibles(primera, segunda) && dp(n - 1, primera, tercera, n - 3))
			return dp[n][primera][segunda][tercera] = true;
		if(compatibles(primera, n - 3) && dp(n - 1, segunda, tercera, primera))
			return dp[n][primera][segunda][tercera] = true;
		return dp[n][primera][segunda][tercera] = false;
	}

	private static boolean compatibles(int primera, int segunda)
	{
		return (cartas[primera].pinta == cartas[segunda].pinta) || (cartas[primera].valor == cartas[segunda].valor);
	}

	private static boolean esPosible(int primera, int segunda, int tercera)
	{
		return compatibles(primera, segunda) && compatibles(primera, tercera);
	}

	public static void main(String[] args)
	{
		Scanner sc = new Scanner();
		int n = sc.nextInt();
		cartas = new Carta[n];
		for(int i = 0; i < n; i++)
			cartas[i] = new Carta(sc.next());
		boolean resultado = n <= 3 ? chequearEspecial(n) : dp(n - 1, n - 1, n - 2, n - 3);
		System.out.println(resultado ? "YES" : "NO");
	}

	private static boolean chequearEspecial(int n)
	{
		if(n == 3)
			return esPosible(n - 1, n - 2, n - 3);
		else if(n == 2)
			return compatibles(n - 1, n - 2);
		else
			return true;
	}

}

import java.util.*;
import java.io.*;

public class B {

	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer st;

	int n;
	String[] s;

	boolean dfs(String[] ss, int d) {

		if (d == 1) {
			return true;
		}
		String[] s2 = new String[ss.length - 1];

		int i = ss.length - 1;
		if (i >= 1
				&& (ss[i].charAt(0) == ss[i - 1].charAt(0) || ss[i].charAt(1) == ss[i - 1]
						.charAt(1))) {
//			for (int j = 0; j < i; ++j) {
//				s2[j] = ss[j];
//			}
//			for (int j = i + 1; j < ss.length; ++j) {
//				s2[j - 1] = ss[j];
//			}
			for(int j = 0; j < i; ++j) {
				s2[j] = ss[j];
			}
			s2[i - 1] = ss[i];
			if (dfs(s2, d - 1))
				return true;
		}
		if (i >= 3
				&& (ss[i].charAt(0) == ss[i - 3].charAt(0) || ss[i - 3]
						.charAt(1) == ss[i - 3].charAt(1))) {
//			for (int j = 0; j < i; ++j) {
//				s2[j] = ss[j];
//			}
//			for (int j = i + 1; j < ss.length; ++j) {
//				s2[j - 1] = ss[j];
//			}
			for(int j = 0; j < i; ++j) {
				s2[j] = ss[j];
			}
			s2[i - 3] = ss[i];
			if (dfs(s2, d - 1))
				return true;
		}

		return false;
	}

	public void solve() throws IOException {
		n = nextInt();
		s = new String[n];
		for (int i = 0; i < n; ++i) {
			s[i] = next();
		}
		if (dfs(s, n)) {
			out.println("YES");
		} else {
			out.println("NO");
		}
	}

	B() throws IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		//in = new BufferedReader(new InputStreamReader(new FileInputStream("Main.in")));
		out = new PrintWriter(System.out);
		eat("");

		solve();

		out.close();
	}

	void eat(String s) {
		st = new StringTokenizer(s);
	}

	String nextLine() {
		try {
			return in.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

	boolean hasNext() {
		while (!st.hasMoreTokens()) {
			String s = nextLine();
			if (s == null)
				return false;
			eat(s);
		}
		return true;
	}

	String next() {
		hasNext();
		return st.nextToken();
	}

	int nextInt() {
		return Integer.parseInt(next());
	}

	long nextLong() {
		return Long.parseLong(next());
	}

	double nextDouble() {
		return Double.parseDouble(next());
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}

	public static void main(String[] args) throws IOException {
		new B();
	}
}

import java.io.*;
import java.math.BigInteger;
import java.util.HashMap;
import java.util.InputMismatchException;

public class Main {
	public static void main(String[] args) {
		long time_beg = -1;
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		if (args.length > 0 && args[0].equals("outside")) {
			time_beg = System.currentTimeMillis();
			try {
				inputStream = new FileInputStream("io/in.txt");
//				outputStream = new FileOutputStream("io/out.txt");
			} catch (Exception e) {
				System.err.println(e);
				System.exit(1);
			}
		} else {
//			try {
//				inputStream = new FileInputStream("file_name");
//				outputStream = new FileOutputStream("file_name");
//			} catch (Exception e) {
//				System.err.println(e);
//				System.exit(1);
//			}
		}
		Solver s = new Solver();
		s.in = new InputReader(inputStream);
		s.out = new OutputWriter(outputStream);
		s.solve();
		s.out.close();
		if (args.length > 0 && args[0].equals("outside")) {
			System.err.printf("*** Total time: %.3f ***\n", (System.currentTimeMillis() - time_beg) / 1000.0);
		}
	}
}

class OutputWriter {
	private final PrintWriter writer;

	public OutputWriter(OutputStream outputStream) {
		writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
	}

	public OutputWriter(Writer writer) {
		this.writer = new PrintWriter(writer);
	}

	public void print(Object... objects) {
		for (int i = 0; i < objects.length; i++) {
			if (i != 0)
				writer.print(' ');
			writer.print(objects[i]);
		}
	}

	public void printLine(Object... objects) {
		print(objects);
		writer.println();
	}

	public void printLine(char[] array) {
		writer.println(array);
	}

	public void printFormat(String format, Object... objects) {
		writer.printf(format, objects);
	}

	public void close() {
		writer.close();
	}

	public void flush() {
		writer.flush();
	}
}

class InputReader {
	private boolean finished = false;

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	private int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int peek() {
		if (numChars == -1)
			return -1;
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				return -1;
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar];
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public long readLong() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public static boolean isSpaceChar(int c) {
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	private String readLine0() {
		StringBuilder buf = new StringBuilder();
		int c = read();
		while (c != '\n' && c != -1) {
			if (c != '\r')
				buf.appendCodePoint(c);
			c = read();
		}
		return buf.toString();
	}

	public String readLine() {
		String s = readLine0();
		while (s.trim().length() == 0)
			s = readLine0();
		return s;
	}

	public String readLine(boolean ignoreEmptyLines) {
		if (ignoreEmptyLines)
			return readLine();
		else
			return readLine0();
	}

	public BigInteger readBigInteger() {
		try {
			return new BigInteger(readString());
		} catch (NumberFormatException e) {
			throw new InputMismatchException();
		}
	}

	public char readCharacter() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		return (char) c;
	}

	public double readDouble() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		double res = 0;
		while (!isSpaceChar(c) && c != '.') {
			if (c == 'e' || c == 'E')
				return res * Math.pow(10, readInt());
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		}
		if (c == '.') {
			c = read();
			double m = 1;
			while (!isSpaceChar(c)) {
				if (c == 'e' || c == 'E')
					return res * Math.pow(10, readInt());
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				m /= 10;
				res += (c - '0') * m;
				c = read();
			}
		}
		return res * sgn;
	}

	public boolean isExhausted() {
		int value;
		while (isSpaceChar(value = peek()) && value != -1)
			read();
		return value == -1;
	}
}

class Solver {
	InputReader in;
	OutputWriter out;

	void solve() {
		dp = new int[64][64][64][64];
		fill(dp, -1);

		char[] a = {'2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A'};
		char[] b = {'S', 'D', 'H', 'C'};
		MAP = new HashMap<>();
		RMAP = new HashMap<>();
		for (int j = 0; j < a.length; ++j)
			for (int i = 0; i < b.length; ++i) {
				String s = String.valueOf(a[j]) + String.valueOf(b[i]);
				MAP.put(s, j * b.length + i);
				RMAP.put(j * b.length + i, s);
			}

		int n = in.readInt();
		mas = new int[n];
		for (int i = 0; i < n; ++i)
			mas[i] = MAP.get(in.readString());

		if (mas.length < 3) {
			if (mas.length == 1) out.printLine("YES");
			else {
				if (RMAP.get(mas[0]).charAt(0) == RMAP.get(mas[1]).charAt(0)
						|| RMAP.get(mas[0]).charAt(1) == RMAP.get(mas[1]).charAt(1))
					out.printLine("YES");
				else out.printLine("NO");
			}
			return;
		}

		if (rec(n - 1, mas[n - 3], mas[n - 2], mas[n - 1]) == 1) out.printLine("YES");
		else out.printLine("NO");
	}

	HashMap<String, Integer> MAP;
	HashMap<Integer, String> RMAP;
	int[] mas;

	int rec(int pos, int v1, int v2, int v3) {
		if (dp[pos][v1][v2][v3] != -1) return dp[pos][v1][v2][v3];
		if (pos == 0) return dp[pos][v1][v2][v3] = 1;

		String s1 = RMAP.get(v3);
		// -1
		String s2 = RMAP.get(v2);
		if (s1.charAt(0) == s2.charAt(0) || s1.charAt(1) == s2.charAt(1)) {
			int nv1 = v1;
			if (pos >= 3) nv1 = mas[pos - 3];
			int nv2 = v2;
			if (pos >= 2) nv2 = mas[pos - 2];
			int nv3 = mas[pos];
			if (rec(pos - 1, nv1, nv2, nv3) == 1)
				return dp[pos][v1][v2][v3] = 1;
		}

		// -3
		if (pos >= 3) {
			s2 = RMAP.get(mas[pos - 3]);
			if (s1.charAt(0) == s2.charAt(0) || s1.charAt(1) == s2.charAt(1)) {
				int nv1 = mas[pos];
				int nv2 = mas[pos - 2];
				int nv3 = mas[pos - 1];
				if (rec(pos - 1, nv1, nv2, nv3) == 1)
					return dp[pos][v1][v2][v3] = 1;
			}
		}

		return dp[pos][v1][v2][v3] = 0;
	}

	int[][][][] dp;

	public static void fill(int[] array, int value) {
		for (int i = 0; i < array.length; ++i)
			array[i] = value;
	}

	public static void fill(int[][] array, int value) {
		for (int i = 0; i < array.length; ++i)
			fill(array[i], value);
	}

	public static void fill(int[][][] array, int value) {
		for (int i = 0; i < array.length; ++i)
			fill(array[i], value);
	}

	public static void fill(int[][][][] array, int value) {
		for (int i = 0; i < array.length; ++i)
			fill(array[i], value);
	}
}

import java.util.*;

public class B {

	private static class Card {
		char face;
		char val;

		public Card(String value) {
			val = value.charAt(0);
			face = value.charAt(1);
		}

		public boolean canPile(Card c) {
			return (c.face == this.face || c.val == this.val);
		}
		public String toString() {
			return val+""+face;
		}
	}

	private static ArrayList<Card>[] piles;
	private static int n;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		piles = new ArrayList[n];
		for (int i = 0; i < n; i++) {
			piles[i] = new ArrayList<Card>();
			piles[i].add(new Card(sc.next()));
		}

		dfs(0,n-1);
		System.out.println("NO");
		System.exit(0);
	}

	private static void dfs(int count, int idx) {
		if (idx < 0 || piles[idx].isEmpty()) {
			return;
		}

		if (count==n-1) {
			System.out.println("YES");
			System.exit(0);
		}

		if (idx-1 > -1 && !piles[idx-1].isEmpty()) {
			ArrayList<Card> A = new ArrayList<Card>(piles[idx]);
			ArrayList<Card> B = new ArrayList<Card>(piles[idx-1]);
			piles[idx].addAll(piles[idx-1]);
			piles[idx-1] = piles[idx];
			piles[idx] = new ArrayList<Card>();
			dfs(count+1,idx-1);
			piles[idx] = A;
			piles[idx-1] = B;
		}

		if (idx-3 > -1 && !piles[idx-3].isEmpty()) {
			ArrayList<Card> A = new ArrayList<Card>(piles[idx]);
			ArrayList<Card> B = new ArrayList<Card>(piles[idx-3]);
			piles[idx].addAll(piles[idx-3]);
			piles[idx-3] = piles[idx];
			piles[idx].clear();
			dfs(count+1,idx-1);
			piles[idx] = A;
			piles[idx-3] = B;
		}
	}
}

import java.util.*;

public class B {

	private static class Card {
		char face;
		char val;

		public Card(String value) {
			val = value.charAt(0);
			face = value.charAt(1);
		}

		public boolean canPile(Card c) {
			return (c.face == this.face || c.val == this.val);
		}

	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		ArrayList<Card>[] piles = new ArrayList[n];
		for (int i = 0; i < n; i++) {
			piles[i] = new ArrayList<Card>();
			piles[i].add(new Card(sc.next()));
		}

		for (int i = n-1; i >= 1; i--) {
			if (piles[i].isEmpty())
				continue;

			boolean success = false;
			if (i - 1 > -1 && piles[i-1].size() > 0) {
				if (piles[i].get(0).canPile(piles[i - 1].get(0))) {
					piles[i].addAll(piles[i - 1]);
					piles[i - 1] = piles[i];
					piles[i].clear();
					success = true;
				}
			}

			if (!success)
				if (i - 3 > -1  && piles[i-3].size() > 0) {
					if (piles[i].get(0).canPile(piles[i - 3].get(0))) {
						piles[i].addAll(piles[i - 3]);
						piles[i - 3] = piles[i];
						piles[i].clear();
						success = true;
					}
				}

			if (!success) {
				System.out.println("NO");
				System.exit(0);
			}
		}
		System.out.println("YES");
		System.exit(0);
	}
}

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class B130 {
    static boolean [][] isok;
    static int [] index;

    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        while(cin.hasNext()){
            int n = cin.nextInt();
            String [] cards = new String [n];
            Map<String,Integer> count = new HashMap<String,Integer>();
            for( int i = 0 ; i<n;i++){
                cards[i] = cin.next();
                String key = "0"+cards[i].charAt(0);
                int cnt = 0;
                if( count.containsKey(key)){
                    cnt = count.get(key);
                }
                count.put(key, cnt + 1);
                key = "1"+cards[i].charAt(1);
                cnt = 0;
                if( count.containsKey(key)){
                    cnt = count.get(key);
                }
                count.put(key, cnt + 1);

            }
            isok = new boolean[n][n];
            for( int i= 0; i<n ; i ++){
                for( int j=i+1 ; j <n ; j ++){
                    if(cards[i].charAt(0) == cards[j].charAt(0)
                            || cards[i].charAt(1) == cards[j].charAt(1)){
                        isok[i][j] = isok[j][i] = true;
                    }
                }
                isok[i][i] = true;
            }
            boolean ok = true;
            for( int i=0;ok&&i<n;i++){
                if( count.get("0"+cards[i].charAt(0)) == 1
                    && count.get("1"+cards[i].charAt(1)) == 1){
                    ok = false;
                }
            }
            index = new int[n];
//          long beg = System.currentTimeMillis();
            System.out.println(ok?new B130().search(n-1)?"YES":"NO":"NO");
//          long t = System.currentTimeMillis() - beg;
//          System.out.println("time " + t);
        }
        cin.close();
    }

    boolean search( int depth){
        if( depth == 0){
            return true;
        }
        boolean res = false;
        if( isok[index[depth-1]][index[depth]]){
            int tmp = index[depth-1];
            index[depth-1] = index[depth];
            res = search(depth-1);
            index[depth-1] = tmp;
        }
        if( res) return res;
        if( isok[index[depth-3]][index[depth]]){
            int tmp = index[depth-3];
            index[depth-3] = index[depth];
            res = search(depth-1);
            index[depth-3] = tmp;
        }
        return res;
    }

}

/*
 * @author derrick20
 */
import java.awt.*;
import java.io.*;
import java.util.*;

public class solitaire {
    public static void main(String args[]) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        N = sc.nextInt();

        StringBuilder cards = new StringBuilder();
        for (int i = 0; i < N; i++) {
            String s = sc.next();
            cards.append(s);
        }

        memo = new HashMap<>();
        boolean ans = solve(cards, 2 * N - 1);
        out.println(ans ? "YES" : "NO");
        out.close();
    }

    static int N;
    // Shoot so hashmaps HAVE TO USE IMMUTABLES
    // SO EITHER STRINGS OR INTS OR LONGS, ETC...
    static HashMap<String, Boolean> memo;
//    static Card ZERO = new Card(0, 0);
    // Using the i indexed card, return whether we can solve it on the remaining cards
    static boolean solve(StringBuilder cards, int i) {
        if (i == 1) {
            // we finished!
            return true;
        }
        if (memo.containsKey(cards.toString())) {
            return memo.get(cards.toString());
        }
        else {
            boolean ans = false;

            StringBuilder copy = new StringBuilder(cards);
            String top = copy.substring(i - 1);
            if (copy.charAt(i) == copy.charAt(i - 2) || copy.charAt(i - 1) == copy.charAt(i - 3)) {
                // Try going placing onto the next card down
                String old = copy.substring(i - 3, i - 2 + 1);
                // delete that card and replace the one below
                copy.replace(i - 3, i - 2 + 1, top);
                ans |= solve(new StringBuilder(copy.substring(0, i - 2 + 1)), i - 2);
                // put it back, since we need to try the next case
                copy.replace(i - 3, i - 2 + 1, old);
            }
            if (i >= 7) {
                if (copy.charAt(i) == copy.charAt(i - 6) || copy.charAt(i - 1) == copy.charAt(i - 7)) {
                    // Try replacing the 3 cards down one
                    String old = copy.substring(i - 7, i - 6 + 1);
                    copy.replace(i - 7, i - 6 + 1, top);
                    ans |= solve(new StringBuilder(copy.substring(0, i - 6 + 1)), i - 6);
                    // put it back, since we need to try the next case
                    copy.replace(i - 7, i - 6 + 1, old);
                }
            }
//            System.out.println(memo);
            memo.put(cards.toString(), ans);
            return ans;
        }
    }

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        FastScanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        FastScanner(FileReader s) {
            br = new BufferedReader(s);
        }

        String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        String nextLine() throws IOException {
            return br.readLine();
        }

        double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }

        int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        long nextLong() throws IOException {
            return Long.parseLong(next());
        }
    }
}

import java.io.BufferedInputStream;
import java.io.IOException;
import java.util.InputMismatchException;

public class Main
{
	private final int[] table = new int[256];
	private int[] top;
	private int[][] dp;

	public Main()
	{
		for(char c = '2';c <= '9';++c)
		{
			table[c] = c - '0';
		}
		table['T'] = 10;
		table['J'] = 11;
		table['Q'] = 12;
		table['K'] = 0;
		table['A'] = 1;
		table['S'] = 0;
		table['D'] = 1;
		table['H'] = 2;
		table['C'] = 3;
 	}

	public boolean dfs(int x)
	{
		if(x <= 0)
		{
			return true;
		}
		if(dp[x][top[x]] != 0)
		{
			return 1 == dp[x][top[x]];
		}
		if((top[x] / 4 == top[x - 1] / 4 || top[x] % 4 == top[x - 1] % 4) && dp[x - 1][top[x]] != -1)
		{
			int tmp = top[x - 1];
			top[x - 1] = top[x];
			if(dfs(x - 1))
			{
				dp[x][top[x]] = 1;
				return true;
			}
			top[x - 1] = tmp;
		}
		if(x >= 3 && (top[x] / 4 == top[x - 3] / 4 || top[x] % 4 == top[x - 3] % 4) && dp[x - 1][top[x - 1]] != -1)
		{
			int tmp = top[x - 3];
			top[x - 3] = top[x];
			if(dfs(x - 1))
			{
				dp[x][top[x]] = 1;
				return true;
			}
			top[x - 3] = tmp;
		}
		dp[x][top[x]] = -1;
		return false;
	}

	public void foo()
	{
		MyScanner scan = new MyScanner();
		int n = scan.nextInt();
		top = new int[n];
		for(int i = 0;i < n;++i)
		{
			String s = scan.next();
			top[i] = 4 * table[s.charAt(0)] + table[s.charAt(1)];
		}
		dp = new int[n][52];
		System.out.println(dfs(n - 1) ? "YES" : "NO");
	}

	public static void main(String[] args)
	{
		new Main().foo();
	}

	class MyScanner
	{
	    private byte[] buf = new byte[1024];
	    private int curChar;
	    private int numChars;
	    BufferedInputStream bis = new BufferedInputStream(System.in);

	    public int read()
	    {
	        if (-1 == numChars)
	        {
	        	throw new InputMismatchException();
	        }
	        if (curChar >= numChars)
	        {
	            curChar = 0;
	            try
	            {
	                numChars = bis.read(buf);
	            }
	            catch (IOException e)
	            {
	                throw new InputMismatchException();
	            }
	            if (numChars <= 0)
	            {
	            	return -1;
	            }
	        }
	        return buf[curChar++];
	    }

	    public int nextInt()
	    {
	        int c = read();
	        while (isSpaceChar(c))
	        {
	        	c = read();
	        }
	        int sgn = 1;
	        if (c == '-')
	        {
	            sgn = -1;
	            c = read();
	        }
	        int res = 0;
	        do
	        {
	            if (c < '0' || c > '9')
	            {
	            	throw new InputMismatchException();
	            }
	            res *= 10;
	            res += c - '0';
	            c = read();
	        } while (!isSpaceChar(c));
	        return res * sgn;
	    }

	    public String next()
	    {
	        int c = read();
	        while (isSpaceChar(c))
	        {
	        	c = read();
	        }
	        StringBuilder res = new StringBuilder();
	        do
	        {
	            res.appendCodePoint(c);
	            c = read();
	        } while (!isSpaceChar(c));
	        return res.toString();
	    }

	    private boolean isSpaceChar(int c)
	    {
	        return ' ' == c || '\n' == c || '\r' == c || '\t' == c || -1 == c;
	    }
	}
}

    			/*
    		     * Author- Priyam Vora
    		     * BTech 2nd Year DAIICT
    		     */

    		    import java.io.*;
    		    import java.math.*;
    		    import java.util.*;
import java.util.concurrent.ConcurrentHashMap;

import javax.print.attribute.SetOfIntegerSyntax;

    		    public class Practice{
    		    	private static InputStream stream;
    		    	private static byte[] buf = new byte[1024];
    		    	private static int curChar;
    		    	private static int numChars;
    		    	private static SpaceCharFilter filter;
    		    	private static PrintWriter pw;
    		    	private static long count = 0,mod=1000000007;
    		    //	private static TreeSet<Integer> ts=new TreeSet[200000];

    		        public static void main(String[] args) {
    		        	InputReader(System.in);
    		    		pw = new PrintWriter(System.out);
    		            new Thread(null ,new Runnable(){
    		               public void run(){
    		                   try{
    		                       soln2();
    		                       pw.close();
    		                   } catch(Exception e){
    		                       e.printStackTrace();
    		                   }
    		               }
    		           },"1",1<<26).start();
    		       }

    		    	public static long gcd(long x, long y) {
    		    		if (x == 0)
    		    			return y;
    		    		else
    		    			return gcd( y % x,x);
    		    	}
    		    	public static String reverseString(String s) {
    		    		StringBuilder sb = new StringBuilder(s);
    		    		sb.reverse();
    		    		return (sb.toString());
    		    	}

    		    	public static long pow(long n, long p) {
    		    		if(p==0)
    		    			return 1;
    		    		if(p==1)
    		    			return n%10;
    		    		if(p%2==0){
    		    			long temp=pow(n, p/2);
    		    		return (temp*temp)%10;
    		    		}else{
    		    			 	long temp=pow(n,p/2);
    		    			 	temp=(temp*temp)%10;
    		    			 	return(temp*n)%10;

    		    		}
    		    	}

    		    	public static boolean isPrime(int n) {
    		    		// Corner cases
    		    		if (n <= 1)
    		    			return false;
    		    		if (n <= 3)
    		    			return true;

    		    		// This is checked so that we can skip
    		    		// middle five numbers in below loop
    		    		if (n % 2 == 0 || n % 3 == 0)
    		    			return false;

    		    		for (int i = 5; i * i <= n; i = i + 6)
    		    			if (n % i == 0 || n % (i + 2) == 0)
    		    				return false;

    		    		return true;
    		    	}

    		    	// To Get Input
    		    	// Some Buffer Methods

    		    	public static void InputReader(InputStream stream1) {
    		    		stream = stream1;
    		    	}

    		    	private static boolean isWhitespace(int c) {
    		    		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    		    	}

    		    	private static boolean isEndOfLine(int c) {
    		    		return c == '\n' || c == '\r' || c == -1;
    		    	}

    		    	private static int read() {
    		    		if (numChars == -1)
    		    			throw new InputMismatchException();
    		    		if (curChar >= numChars) {
    		    			curChar = 0;
    		    			try {
    		    				numChars = stream.read(buf);
    		    			} catch (IOException e) {
    		    				throw new InputMismatchException();
    		    			}
    		    			if (numChars <= 0)
    		    				return -1;
    		    		}
    		    		return buf[curChar++];
    		    	}

    		    	private static int nextInt() {
    		    		int c = read();
    		    		while (isSpaceChar(c))
    		    			c = read();
    		    		int sgn = 1;
    		    		if (c == '-') {
    		    			sgn = -1;
    		    			c = read();
    		    		}
    		    		int res = 0;
    		    		do {
    		    			if (c < '0' || c > '9')
    		    				throw new InputMismatchException();
    		    			res *= 10;
    		    			res += c - '0';
    		    			c = read();
    		    		} while (!isSpaceChar(c));
    		    		return res * sgn;
    		    	}

    		    	private static long nextLong() {
    		    		int c = read();
    		    		while (isSpaceChar(c))
    		    			c = read();
    		    		int sgn = 1;
    		    		if (c == '-') {
    		    			sgn = -1;
    		    			c = read();
    		    		}
    		    		long res = 0;
    		    		do {
    		    			if (c < '0' || c > '9')
    		    				throw new InputMismatchException();
    		    			res *= 10;
    		    			res += c - '0';
    		    			c = read();
    		    		} while (!isSpaceChar(c));
    		    		return res * sgn;
    		    	}

    		    	private static String nextToken() {
    		    		int c = read();
    		    		while (isSpaceChar(c))
    		    			c = read();
    		    		StringBuilder res = new StringBuilder();
    		    		do {
    		    			res.appendCodePoint(c);
    		    			c = read();
    		    		} while (!isSpaceChar(c));
    		    		return res.toString();
    		    	}

    		    	private static String nextLine() {
    		    		int c = read();
    		    		while (isSpaceChar(c))
    		    			c = read();
    		    		StringBuilder res = new StringBuilder();
    		    		do {
    		    			res.appendCodePoint(c);
    		    			c = read();
    		    		} while (!isEndOfLine(c));
    		    		return res.toString();
    		    	}

    		    	private static int[] nextIntArray(int n) {
    		    		int[] arr = new int[n];
    		    		for (int i = 0; i < n; i++) {
    		    			arr[i] = nextInt();
    		    		}
    		    		return arr;
    		    	}

    		    	private static int[][] next2dArray(int n, int m) {
    		    		int[][] arr = new int[n][m];
    		    		for (int i = 0; i < n; i++) {
    		    			for (int j = 0; j < m; j++) {
    		    				arr[i][j] = nextInt();
    		    			}
    		    		}
    		    		return arr;
    		    	}
    		    	private static char[][] nextCharArray(int n,int m){
    		    		char [][]c=new char[n][m];
    		    		for(int i=0;i<n;i++){
    		    			String s=nextLine();
    		    			for(int j=0;j<s.length();j++){
    		    				c[i][j]=s.charAt(j);
    		    			}
    		    		}
    		    		return c;
    		    	}

    		    	private static long[] nextLongArray(int n) {
    		    		long[] arr = new long[n];
    		    		for (int i = 0; i < n; i++) {
    		    			arr[i] = nextLong();
    		    		}
    		    		return arr;
    		    	}

    		    	private static void pArray(int[] arr) {
    		    		for (int i = 0; i < arr.length; i++) {
    		    			pw.print(arr[i] + " ");
    		    		}
    		    		pw.println();
    		    		return;
    		    	}

    		    	private static void pArray(long[] arr) {
    		    		for (int i = 0; i < arr.length; i++) {
    		    			pw.print(arr[i] + " ");
    		    		}
    		    		pw.println();
    		    		return;
    		    	}

    		    	private static void pArray(boolean[] arr) {
    		    		for (int i = 0; i < arr.length; i++) {
    		    			pw.print(arr[i] + " ");
    		    		}
    		    		pw.println();
    		    		return;
    		    	}

    		    	private static boolean isSpaceChar(int c) {
    		    		if (filter != null)
    		    			return filter.isSpaceChar(c);
    		    		return isWhitespace(c);
    		    	}

    		    	private interface SpaceCharFilter {
    		    		public boolean isSpaceChar(int ch);
    		    	}

     		       private static void soln2(){

     		    	   int n=nextInt();
     		    	   String s=nextLine();
     		    	   String a[]=s.split(" ");
     		    	   for(int i=n-1;i>0;i--){
     		    		   if(a[i].charAt(0)==a[i-1].charAt(0) || a[i].charAt(1)==a[i-1].charAt(1)){
     		    			   a[i-1].replace(a[i-1].charAt(0), a[i].charAt(0));
     		    			  a[i-1].replace(a[i-1].charAt(1), a[i].charAt(1));
     		    		   }else if(i-3>=0 ){
     		    			   if(a[i].charAt(0)==a[i-3].charAt(0) || a[i].charAt(1)==a[i-3].charAt(1)){
     		    				   a[i-3].replace(a[i-3].charAt(0), a[i].charAt(0));
          		    			  a[i-3].replace(a[i-3].charAt(1), a[i].charAt(1));

     		    			   }else{
     		    				   System.out.println("NO");
     		    				   System.exit(0);
     		    			   }
     		    		   }else{
     		    			   System.out.println("NO");
     		    			   System.exit(0);
     		    		   }
     		    	   }
     		    	   pw.println("YES");

     		       }

    		    }
    		    class Node{
    		    	int val;
    		    	int ind;

    		    	Node(int val,int ind){
    		    		this.val=val;
    		    		this.ind=ind;
    		    	}

    		    }

    		    class Pair implements Comparable<Pair>{

        				int ind,val;
        				Pair(int val,int ind){
        				this.ind=ind;
        				this.val=val;
        				}
    					@Override
    					public int compareTo(Pair o) {

    					return val-o.val;
    					}

    			/*	public int hashCode() {
					//	return 0;
    	    			int hu = (int) (row ^ (row >>> 32));
    	    			int hv = (int) (col ^ (col >>> 32));
    	    			return 31 * hu + hv;
    	    		}
    				public boolean equals(Object o) {
    	    			Pair other = (Pair) o;
    	    		return row == other.row && col == other.col;
    	    		}
    		*/
    		    	}
    		        class Graph{
    		        	private static int V,level[][],count=-1,lev_dfs[],degree=0,no_vert_conn_comp=0;
    		        	private Stack <Integer>st=new Stack();
    		        	private static LinkedList<Integer > adj[];
    		        	private boolean[][] Visite;
    		        	private static boolean [] Visited;
    		        	private static HashSet<Integer> Vis=new HashSet();
    		        	private static Stack<Integer> topo_sort=new Stack<>();
    		        	private static HashMap<String,Integer> hm=new HashMap<>();
    		  private static HashSet<String> hs=new HashSet();
    		private static HashSet<String > exist=new HashSet();
    		private static int a[];

    		    Graph(int V){
    		    V++;
    		    this.V=(V);
    		    adj=new LinkedList[V];
    		    Visite=new boolean[100][100];

    	 	    Visited=new boolean[V];
    		    level=new int[100][100];
    		    lev_dfs=new int[V];
    		   for(int i=0;i<V;i++)
    			   adj[i]=new LinkedList<Integer>();
    		a=new int[V+1];
    		    }

    		    void setup(int d[]){

    		    	a=Arrays.copyOf(d, d.length);

    		    }
    		    void ans(){
    		    	StringBuilder sb=new StringBuilder();
    		    	for(int i=1;i<a.length;i++){
    		    		sb.append(a[i]+" ");
    		    	}
    		    	System.out.println(sb);
    		    }
    		   void addEdge(int v,int w){

    		    	if(adj[v]==null){
    		    		adj[v]=new LinkedList();
    		    	}
    		    	adj[v].add(w);

    		    }

    		    public static int BFS2(int startVert){
    		    	Visited=new boolean[V];
    		    	for(int i=1;i<V;i++){
    		    		lev_dfs[i]=-1;
    		    	}
    		    //	System.out.println(startVert);
    		    	Queue<Integer> q=new LinkedList<Integer>();
    		    	q.add(startVert);

    		    	lev_dfs[startVert]=0;
    		    	while(!q.isEmpty()){
    		    		int top=q.poll();

    		    		Iterator<Integer> i= adj[top].listIterator();
    		    		while(i.hasNext()){
    		    			int n=i.next();
    		    	//		System.out.println(top+" "+n);
    		    			if(!Visited[n]){
    		    				q.add(n);
    		    				Visited[n]=true;
    		    				lev_dfs[n]=lev_dfs[top]+1;

    		    			}
    		    		}
    		    	}

    		    //	q.clear();
    		    	return -1;
    		    }
    		    public static int getAn(){
    		    	if(ans==Long.MAX_VALUE)
    		    		ans=-1;
    		    	return 0;
    		    }
    		    public int getEd(){
    		    	return degree/2;
    		    }
    		    public void get(int from,int to){
    		    	int h=lev_dfs[from]-lev_dfs[to];
    		    	if(h<=0){
    		    		System.out.println(-1);
    		    	}else{
    		    		System.out.println(h-1);
    		    	}
    		    }
    		    private static boolean check(int x,int y,char c[][]){

    				if((x>=0 && y>=0) && (x<c.length && y<c[0].length) && c[x][y]!='#'){

    					return true;
    				}
    				return false;
    			}
    		    public int BFS(int x,int y,int k,char[][] c)
    		    {
    		    	 LinkedList<Pair> queue = new LinkedList<Pair>();
    		        //Visited[s]=true;
    		   //     queue.add(new Pair(x,y));
    		       int count=0;
    		   level[x][y]=-1;
    		   c[x][y]='M';
    		        while (!queue.isEmpty())
    		        {
    		            Pair temp = queue.poll();

    		        }
    		        return V;
    		    }
    		    static long ans=Long.MAX_VALUE;

    		   public static void dfs2(int startVert,int endVert,long need){
    			Visited[startVert]=true;
    			//System.out.println(startVert+" "+need);
    			   for(int x:adj[startVert]){
    				if(x==endVert ){
    					String to="";
    					to+=startVert+" "+x;

    					if(hs.contains(to) && startVert!=x)
    					ans=Math.min(need+1, ans);
    					else
    						ans=Math.min(need, ans);
    				}
    				else{
    					String to="";
    					to+=startVert+" "+x;
    					boolean tmp=false;
    					if(hs.contains(to) )
    						tmp=true;
    					if(!Visited[x])
    					{
    					if(tmp)
    						dfs2(x, endVert, need+1);
    					else{
    						dfs2(x, endVert, need);
    					}
    					}
    					}
    			}

    		   }
    		     public long dfs(int startVertex){
    		    //	 getAns(startVertex);
    		    	 if(!Visited[startVertex])  {

    		   return dfsUtil(startVertex);

    		    	//return getAns();
    		    	}

    		    return 0;
    		    	}
    		 private long dfsUtil(int startVertex) {//0-Blue 1-Pink
    			 int c=1;
    		TreeSet<Integer> index=new TreeSet();
    		TreeSet<Integer> ele=new TreeSet(Collections.reverseOrder());
    			 long cout=0;
    		      degree=0;
    		    	Visited[startVertex]=true;
    		    	lev_dfs[startVertex]=0;
    		      st.push(startVertex);
    		      int temp=-1;
    		    	    while(!st.isEmpty()){

    		    	int top=st.pop();
    		    //	ts.add(top);
    		    	Iterator<Integer> i=adj[top].listIterator();

      		      index.add(top);
      		      ele.add(a[top]);
    		    while(i.hasNext()){
    		    //	System.out.println(top);
    		    	int n=i.next();
    		     if( !Visited[n]){
    		    				Visited[n]=true;
    		    				st.push(n);
    		    c++;
    		     }
    		         }
    		 }
    		    	   for(int x:index){
    		    		   a[x]=ele.first();
    		    		   ele.remove(ele.first());
    		    	  }

    		 //   System.out.println(temp);
    		    return 0;
    		    }

    		        }

    		    class Dsu{
    		    	private int rank[], parent[] ,n;
    		    	private static int[] parent1;
    		    	Dsu(int size){
    		    		this.n=size+1;
    		    		rank=new int[n];
    		    		//parent=new int[n];
    		    		parent=new int[n];
    		    	makeSet();

    		    	}

    		    	void makeSet(){
    		    		for(int i=0;i<n;i++){
    		    			parent[i]=i;
    		    		}
    		    	}

    		    	int find(int x){
    		    		if(parent[x]!=x){

    		    			parent[x]=find(parent[x]);
    		    		}
    		    		return parent[x];
    		    	}

    		    	void union(int x,int y){
    		    		int xRoot=find(x);
    		    		int yRoot=find(y);

    		    		if(xRoot==yRoot)
    		    			return;
    		    		if(rank[xRoot]<rank[yRoot]){
    		    		parent[xRoot]=yRoot;
    		    		}else if(rank[yRoot]<rank[xRoot]){
    		    			parent[yRoot]=xRoot;
    		    		}else{
    		    			parent[yRoot]=xRoot;
    		    			rank[xRoot]++;
    		    		}

    		    	}

    		    }

import java.io.*;

public class B {
	int map[];
	int dp[][][][];
	int n;
	String[] rawCards;
	int[] cards;

	int getState(String s){
		int num = map[s.charAt(0)], suit = map[s.charAt(1)];
		return num*5 + suit + 1;
	}

	void init(){
		map = new int[256];
		map['J'] = 8;
		map['Q'] = 9;
		map['K'] = 10;
		map['A'] = 11;
		map['T'] = 12;
		map['S'] = 0;
		map['D'] = 1;
		map['H'] = 2;
		map['C'] = 3;
		for(char ch = '2'; ch <='9'; ch++)
			map[ch] = ch - '2';
	}

	boolean isValid(int s1, int s2){
		if(s2 == 0) return false;
		return s1/5 == s2/5 || s1%5 == s2%5;
	}

	boolean solve(int pos, int a, int b, int c, int d){
		if(pos == 0) return true;
		if(pos<0) return false;

		if(dp[a][b][c][d] != 0)
			return dp[a][b][c][d] == 1;

		int aa = pos-4>=0? cards[pos-4]:0;
		if(isValid(d, a)){
			dp[a][b][c][d] = solve(pos-1, aa, d, b, c)? 1:2;
		}

		if(dp[a][b][c][d]!=1 && isValid(d, c)){
			dp[a][b][c][d] = solve(pos-1, aa, a, b, d)? 1:2;
		}

		return dp[a][b][c][d]==1;
	}

	void run() throws IOException{
		init();
		dp = new int[70][70][70][70];

		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		n = Integer.parseInt(bf.readLine());
		rawCards = bf.readLine().trim().split("[ ]+");

//		String[] arg1 = new String[]{"2","3","4","5","6","7","8","9","J","Q","K","A"};
//		String[] arg2 = new String[]{"S","D","H","C"};
//		n = 48;
//		int sz=0;
//		rawCards = new String[n];
//		for(int i=0; i<arg1.length; i++){
//			for(int j=0; j<4; j++){
//				rawCards[sz++] = arg1[i]+arg2[j];
//				System.out.print(rawCards[sz-1] + ", ");
//			}System.out.println();
//		}System.out.println(sz);
		cards = new int[n];
		for(int i=0; i<n; i++) cards[i] = getState(rawCards[i]);

		int a, b, c, d;
		a = n<4? 0:cards[n-4];
		b = n<3? 0:cards[n-3];
		c = n<2? 0:cards[n-2];
		d = cards[n-1];
		System.out.println(solve(n-1, a, b, c, d)? "YES" : "NO");
//		for(int i=0; i<n; i++) System.out.println(cards[i]/12 + ", " + cards[i]%12);
	}

	public static void main(String[] args) throws IOException{
		new B().run();
	}
}

import java.util.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

public class  Main  {

	//ArrayList<Integer> lis = new ArrayList<Integer>();
	//ArrayList<String> lis = new ArrayList<String>();
	//ArrayList<test> lis = new ArrayList<test>();
//	static long sum=0;
//	static boolean f=false;
	//static String s[],r="";
//	static int dx[]={1,-1,0,0,1,1,-1,-1};
  //  static int dy[]={0,0,1,-1,1,-1,1,-1},n,m,w=0;
	//static int dp[][][][],co,r=0;
	//throws IOException
	//static char c[][];
	static boolean b=false,me[][][][][];

public  static void main(String[] args)  {
   //googlein.txt C-small-attempt0.in
//	Scanner sc =new Scanner(new File("file.txt"));
	 Scanner sc =new Scanner(System.in);
	  //File file = new File("file.txt");
	//	PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter(file)));
	//	sc.useDelimiter("(\\s)+|[,]");

	  while(sc.hasNext()){
		   //long sum=0;
	//	  int n=sc.nextInt(),m=sc.nextInt(),k=sc.nextInt();
		int   n=sc.nextInt();
		b=false;
	//	db((int)sc.next().charAt(0));
      char  c[][]=new char[2][n];
	 me=new boolean [2][100][100][100][n];
		 for(int i=0;i<n;i++){
			 String s=sc.next();
			 c[0][i]=s.charAt(0);
			 c[1][i]=s.charAt(1);
		 }

		 if( n==1 ){ System.out.println("YES");return;}

		 rep(n-1,c);

	  System.out.println(b? "YES":"NO");

		 }

}
	// db("Case #"+(k)+": "+c);
	 //	pw.println("Case #"+(k)+": "+c);

	 	//pw.flush();
	 	//pw.close();

   static void rep(int a,char p[][]){

	   if( b )return;
	   if(a==0){ b=true; return; }
	  // db(p[0],p[1]);

	   if(2<a && me[0][p[0][a-2]][p[0][a-1]][p[0][a]][a] && me[1][p[1][a-2]][p[1][a-1]][p[1][a]][a] )return;

	   if(  p[0][a]==p[0][a-1]   ||  p[1][a]==p[1][a-1]   ){
	   char np[][]=new char[2][a];
	   for(int i=0;i<a;i++){np[0][i]=p[0][i]; np[1][i]=p[1][i];}  np[0][a-1]=p[0][a];np[1][a-1]=p[1][a];
	     rep(a-1,np ); }

	   if(  0<=a-3 && (  p[0][a]==p[0][a-3]  || p[1][a]==p[1][a-3] ) ){
	   char np[][]=new char[2][a];
	   for(int i=0;i<a;i++){np[0][i]=p[0][i]; np[1][i]=p[1][i];}  np[0][a-3]=p[0][a];np[1][a-3]=p[1][a];
	     rep(a-1,np ); }

	 if(2<a)  me[0][p[0][a-2]][p[0][a-1]][p[0][a]][a] = me[1][p[1][a-2]][p[1][a-1]][p[1][a]][a]=true;

   }

    static void db(Object... os){
	         System.err.println(Arrays.deepToString(os));

	}

}

/*class P implements Comparable<P>{
    int v,vv,t;
	P(int v,int vv,int t){
		this.v=v;
	    this.vv=vv;
	    this.t=t;
	}
	  public int compareTo(P x){
          return t-x.t;
	   }

}*/

import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import java.io.*;
import java.math.*;
import java.text.*;
import java.util.*;

/*
br = new BufferedReader(new FileReader("input.txt"));
pw = new PrintWriter(new BufferedWriter(new FileWriter("output.txt")));
br = new BufferedReader(new InputStreamReader(System.in));
pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
 */

public class Main {
  private static BufferedReader br;
  private static StringTokenizer st;
  private static PrintWriter pw;

  static String[] list;

  public static void main(String[] args) throws IOException {
    br = new BufferedReader(new InputStreamReader(System.in));
    pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    //int qq = 1;
    int qq = Integer.MAX_VALUE;
    //int qq = readInt();
    for(int casenum = 1; casenum <= qq; casenum++)  {
      int n = readInt();
      seen = new Set[n];
      for(int i = 0; i < n; i++) {
        seen[i] = new HashSet<Integer>();
      }
      list = new String[n];
      for(int i = 0; i < n; i++) {
        list[i] = nextToken();
      }
      pw.println(can(n-1) ? "YES" : "NO");
    }
    pw.close();
  }

  public static boolean can(int n) {
    if(n==0) {
      return true;
    }
    int hash = hash(n);
    if(!seen[n].add(hash)) return false;
    if(list[n].charAt(0) == list[n-1].charAt(0) || list[n].charAt(1) == list[n-1].charAt(1)) {
      String save = list[n-1];
      list[n-1] = list[n];
      if(can(n-1)) {
        return true;
      }
      list[n-1] = save;
    }
    if(n-3 >= 0 && (list[n].charAt(0) == list[n-3].charAt(0) || list[n].charAt(1) == list[n-3].charAt(1))) {
      String save = list[n-3];
      list[n-3] = list[n];
      if(can(n-3)) {
        return true;
      }
      list[n-3] = save;
    }
    return false;
  }

  static Set<Integer>[] seen;

  public static int hash(int n) {
    int ret = 0;
    for(int i = 0; i <= n; i++) {
      ret *= 3137;
      ret += list[i].hashCode();
    }
    return ret;
  }

  private static void exitImmediately() {
    pw.close();
    System.exit(0);
  }

  private static long readLong() throws IOException {
    return Long.parseLong(nextToken());
  }

  private static double readDouble() throws IOException {
    return Double.parseDouble(nextToken());
  }

  private static int readInt() throws IOException {
    return Integer.parseInt(nextToken());
  }

  private static String nextToken() throws IOException  {
    while(st == null || !st.hasMoreTokens())  {
      if(!br.ready()) {
        exitImmediately();
      }
      st = new StringTokenizer(br.readLine().trim());
    }
    return st.nextToken();
  }
}

import java.util.*;

public class B {

	private static class Card {
		char face;
		char val;

		public Card(String value) {
			val = value.charAt(0);
			face = value.charAt(1);
		}

		public boolean canPile(Card c) {
			return (c.face == this.face || c.val == this.val);
		}

		public String toString() {
			return val + "" + face;
		}
	}

	private static ArrayList<Card>[] piles;
	private static int n;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		piles = new ArrayList[n];
		for (int i = 0; i < n; i++) {
			piles[i] = new ArrayList<Card>();
			piles[i].add(new Card(sc.next()));
		}

		dfs(0, n - 1);
		System.out.println("NO");
		System.exit(0);
	}

	private static void dfs(int count, int idx) {
		if (idx < 0) {
			return;
		} else if (piles[idx].isEmpty()) {
			dfs(count+1,idx-1);
		}

		if (count == n - 1) {
			System.out.println("YES");
			System.exit(0);
		}

		if (idx - 1 > -1 && !piles[idx - 1].isEmpty()) {
			if (piles[idx].get(0).canPile(piles[idx - 1].get(0))) {
				ArrayList<Card> A = new ArrayList<Card>(piles[idx]);
				ArrayList<Card> B = new ArrayList<Card>(piles[idx - 1]);
				piles[idx].addAll(piles[idx - 1]);
				piles[idx - 1] = piles[idx];
				piles[idx] = new ArrayList<Card>();
				dfs(count + 1, idx - 1);
				piles[idx] = A;
				piles[idx - 1] = B;
			}
		}

		if (idx - 3 > -1 && !piles[idx - 3].isEmpty()) {
			if (piles[idx].get(0).canPile(piles[idx - 3].get(0))) {
				ArrayList<Card> A = new ArrayList<Card>(piles[idx]);
				ArrayList<Card> B = new ArrayList<Card>(piles[idx - 3]);
				piles[idx].addAll(piles[idx - 3]);
				piles[idx - 3] = piles[idx];
				piles[idx].clear();
				dfs(count + 1, idx - 1);
				piles[idx] = A;
				piles[idx - 3] = B;
			}
		}
	}
}

import java.io.*;
import java.util.*;
import java.math.*;

public class Main {
    static boolean find = false;
    static HashSet<String> set = new HashSet<>();
    public static void main(String[] args) throws Exception {
        PrintWriter out = new PrintWriter(System.out,true);
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(in.readLine());
        String[] mas = new String[n];
        StringTokenizer st = new StringTokenizer(in.readLine());
        for(int i = 0;i < n;i++) mas[i] = st.nextToken();
        func(mas,n-1);
        if(find) {
            out.println("YES");
        }else{
            out.println("NO");
        }
    }

    public static void func(String[] mas, int last) {
        String d = Arrays.toString(mas);
        if(set.contains(d)) return;
        set.add(d);
        if(last == 0 || find) find = true;
        if(last > 0 && (mas[last-1].charAt(0) == mas[last].charAt(0) || mas[last-1].charAt(1) == mas[last].charAt(1))) {
            String a = mas[last-1];
            mas[last-1] = mas[last];
            func(mas,last-1);
            mas[last-1] = a;
        }
        if(last > 2 && (mas[last-3].charAt(0) == mas[last].charAt(0) || mas[last-3].charAt(1) == mas[last].charAt(1))) {
            String a = mas[last-3];
            mas[last-3] = mas[last];
            func(mas,last-1);
            mas[last-3] = a;
        }
    }
}