func_code_string: #include <bits/stdc++.h>   using namespace std;   int n;   int f[55][55][55][55];   string s[100];   bool dfs(int n, int a, int b, int c) {     if (n == 1) return 1;     if (f[n][a][b][c]) return 0;     if (s[c][0] == s[b][0] || s[c][1] == s[b][1])       if (dfs(n - 1, n - 3, a, c)) return 1;     if (n > 3 && (s[c][0] == s[n - 3][0] || s[c][1] == s[n - 3][1]))       if (dfs(n - 1, c, a, b)) return 1;     f[n][a][b][c] = 1;     return 0;   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) cin >> s[i];     bool ans = dfs(n, n - 2, n - 1, n);     if (ans == 0)       cout <<  NO  << endl;     else       cout <<  YES  << endl;     return 0;   }   