并查集
#include <algorithm>
#include <cstdio>
#include <iostream>using namespace std;int pre[MAX];
void init(){
for (int i = 0; i < MAX; i++)pre[i] = i;
}
int findx(int x){
return x == pre[x] ? x : pre[x] = findx(pre[x]);
}
void join(int x, int y){
int a = findx(x);int b = findx(y);if (a != b)pre[b] = a;
}
int main(void){
int n;while (scanf("%d", &n) == 1) {
char str[51];init();for (int i = 0; i < n; i++) {
scanf("%s", str);join(str[0] - 'a', str[len - 1] - 'a');}printf("Yes\n");elseprintf("No\n");}return 0;
}