Problem:
 Score : 200 points    Problem Statement Takahashi is practicing shiritori alone again today.  Shiritori is a game as follows:   In the first turn, a player announces any one word.  In the subsequent turns, a player announces a word that satisfies the following conditions:  That word is not announced before.  The first character of that word is the same as the last character of the last word announced.     In this game, he is practicing to announce as many words as possible in ten seconds.  You are given the number of words Takahashi announced, N , and the i -th word he announced, W_i , for each i . Determine if the rules of shiritori was observed, that is, every word announced by him satisfied the conditions.      Constraints  N is an integer satisfying 2 \leq N \leq 100 .  W_i is a string of length between 1 and 10 (inclusive) consisting of lowercase English letters.         Input Input is given from Standard Input in the following format:  N  W_1  W_2  :  W_N       Output If every word announced by Takahashi satisfied the conditions, print Yes ; otherwise, print No .        Sample Input 1 4
hoge
english
hoge
enigma      Sample Output 1 No  As hoge is announced multiple times, the rules of shiritori was not observed.       Sample Input 2 9
basic
c
cpp
php
python
nadesico
ocaml
lua
assembly      Sample Output 2 Yes       Sample Input 3 8
a
aa
aaa
aaaa
aaaaa
aaaaaa
aaa
aaaaaaa      Sample Output 3 No       Sample Input 4 3
abc
arc
agc      Sample Output 4 No

Solution (Python):

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

n = int(input())
words = set()
lastWord = ''
for i in range(n):
    word = input()[:-1]
    if (i != 0 and word[0] != lastWord[-1] or word in words):
        print('No')
        exit()
    lastWord = word
    words.add(word)
print('Yes')

Solution (Python):

def main():
    N, *W = open(0).read().split()
    cur, used = W[0], {W[0]}
    for i in W[1:]:
        if cur[-1] == i[0] and i not in used:
            cur = i
            used.add(i)
        else:
            print("No")
            return
    print("Yes")


if __name__ == "__main__":
    main()

Solution (Python):
N = int(input()); W = [input() for _ in range(N)]; t = W[0][0]
for i in range(N):
  if W.count(W[i]) > 1:
    print("No")
    exit(0)
  if W[i][0] != t:
    print("No")
    exit(0)
  t = W[i][-1]
print("Yes")

Solution (Python):
import sys
n = int(input())
src = [input() for _ in range(n)]
tmp = ''
for i,s in enumerate(src):
    if i == 0:
        tmp = s[-1]
    else:
        if s[0] != tmp:
            print('No')
            sys.exit()
        tmp = s[-1]
if len(src) != len(set(src)):
    print('No')
    sys.exit()
print('Yes')

Solution (Python):

from math import sin, cos, radians

def main():
    N  = int(input())
    s = [input() for i in range(N)]
    if len(set(s)) == N -1: 
        print("No")
        exit()
    for i in range(N-1):
        if s[i][-1] != s[i+1][0]:
            print("No")
            exit()
    print("Yes")
                

    

if __name__ == '__main__':
    main()

Solution (Python):
N=int(input())

a=[]
ans=0
for i in range(N):
  s=input()
  
  if i>=1:
    if s[0]!=a[-1][-1]:
      ans=1
      break
   
  if a.count(s)>0:
    ans = 1
    break
  
  a.append(s)

print("No" if ans==1 else "Yes")

Solution (Python):
n = int(input())
w = [input()]
ans = 'Yes'
for _ in range(n-1):
  s = input()
  if s in w:
    ans = 'No'
    break
  if w[-1][-1] != s[0]:
    ans = 'No'
    break
  w.append(s)

print(ans)

Solution (Python):
n=int(input())
w=[input() for _ in range(n)]

if len(set(w))!=len(w):
  print("No")
else:
  for i in range(1,n):
    if w[i][0]!=w[i-1][-1]:
      print("No")
      exit()
      
  print("Yes")

Solution (Python):
n = int(input())
w = [input() for i in range(n)]
swi = "Yes"
for i in range(n - 1):
    if w.count(w[i]) > 1 or w[i][-1] != w[i + 1][0]:
        swi = "No"
print(swi)

Solution (Python):
n = int(input())
w = [input() for _ in range(n)]

if len(set(w)) is not n:
    print('No')
    exit()

for i in range(len(w) - 1):
    if not w[i][-1] == w[i + 1][0]:
        print('No')
        exit()
print('Yes')

Solution (Python):
n=int(input())

bk=input()
word=[bk]
for _ in range(1,n):
  s=input()
  if s[0]!=bk[-1] or s in word:
    print("No")
    exit()
  else:
    word.append(s)
    bk=s

print("Yes")

Solution (Python):
import sys
input = sys.stdin.readline

import copy

N=int(input())
W = [input().split() for _ in range(N)]

for i in range(N):
    for j in range(i+1,N):
        if W[i] == W[j]:
            print("No")
            sys.exit()



for i in range(N):
    W[i] = list(W[i][0])

for i in range(1,N):
    if W[i-1][-1] != W[i][0]:
        print("No") 
        sys.exit()


print("Yes")

Solution (Python):
n = int(input())
w = []
for i in range(n):
  w.append(input())
k = 0
for i in range(n-1):
  if w[i][-1] == w[i+1][0]:
    k += 1

print('Yes' if k == n-1 and len(set(w)) == n else 'No')

Solution (Python):
N = int(input())
WList = []
wrongflag = False
lastword = ''

for _ in range(N):
    word = input()
    if word in WList:
        wrongflag = True
    if lastword != '' and lastword != word[0]:
        wrongflag = True

    WList.append(word)
    lastword = word[-1]

if wrongflag:
    print('No')
else:
    print('Yes')

Solution (Python):
N=int(input())
W=[]
for i in range(N):
    W.append(input())
for i in range(1,N):
    if W[i-1][-1]!=W[i][0] or W[i-1] in W[i:]:
        print("No")
        exit(0)
print("Yes")

Solution (Python):
n = int(input())
w = [input() for i in range(n)]
count = 0
for i in range(1, n):
    if w[i - 1][len(w[i - 1]) - 1] != w[i][0]:
        count += 1
if count == 0 and len(list(set(w))) == n:
    print('Yes')
else:
    print('No')

Solution (Python):
n=int(input())
w=[input() for i in range(n)]
ans=0
for i in range(n-1):
  if w[i][-1]!=w[i+1][0]:
    ans+=1
if ans==0 and len(set(w))==n:
  print("Yes")
else:
  print("No")

Solution (Python):
N=int(input())
W=[input() for i in range(N)]
Ws=sorted(W)
for i in range(1,N):
  if Ws[i-1]==Ws[i] or W[i-1][-1]!=W[i][0]:
    print('No')
    exit()
print('Yes')

Solution (Python):
import collections

n = int(input())
ws = [input().strip() for _ in range(n)]

counter = collections.Counter()
ok = True
prev = ws[0][0]
for w in ws:
    counter[w] += 1
    if counter[w] > 1 or w[0] != prev:
        ok = False
        break
    prev = w[-1]
if ok:
    print('Yes')
else:
    print('No')

Solution (Python):
n = int(input())
W = [input() for i in range(n)]
for i in range(n-1):
    if W[i][-1] != W[i+1][0]:
        print('No')
        exit()
    elif W[i] in W[i+1:]:
        print('No')
        exit()
print('Yes')

Solution (Python):
N = int(input())

flag = True
tmp = []
for i in range(N):
    W = str(input())
    if i == 0:
        tmp.append(W)
    else:
        if W in tmp:
            flag = False
        else:
            if tmp[-1][-1] != W[0]:
                flag = False
            tmp.append(W)

if flag:
    print ('Yes')
else:
    print ('No')

Solution (Python):
import sys

N=int(input())

flag=0

word=[]

for i in range(N):
    buf=input()
    if word.count(buf)==0:
        word.append(buf)
    else:
        flag=1

if flag!=1:
    for i in range(N-1):
        
        
        if word[i][-1]!=word[i+1][0]:
            print('No')
            sys.exit()
    print('Yes')
else:
    print('No')
    sys.exit()

Solution (Python):
N=int(input())
ls=[input() for i in range(N)]
flag="Yes"
for i in range(1,N):
  if ls[i][0]!=ls[i-1][-1]:
    flag="No"
    break
x=len(set(ls))
if x<N:
  flag="No"
print(flag)

Solution (Python):
N = int(input())
word_list = []
word_old = input()
word_list.append(word_old)
flag = 0
for i in range(1, N):
    word = input()
    if word[0] != word_old[-1] or word in word_list:
        print("No")
        flag = 1
        break
    word_old = word
    word_list.append(word_old)

if flag == 0:
    print("Yes")

Solution (Python):
N = int(input())
W = [input() for _ in range(N)]
if len(set(W)) == len(W):
    flag = True
    for i in range(len(W) - 1):
        if W[i][-1] != W[i+1][0]:
            flag = False
            break
    print('Yes' if flag == True else 'No')
else:
    print('No')

Solution (Python):
n=int(input())
w=[]
ans='Yes'
for i in range(n):
    w.append(input())
for i in range(1,n):
    if w[i][0]==w[i-1][-1] and w.count(w[i])==1:
        continue
    else:
        ans='No'
print(ans)

Solution (Python):
N = int(input())

w = list(input() for i in range(N))
a = {}
a[w[0]] = 1
flag = 0
for i in range(1,N):
    if w[i-1][-1] != w[i][0]:
        flag = 1
        break
    if w[i] in a:
        flag = 1
        break
    a[w[i]] = 1
if flag == 0:
    print("Yes")
else:
    print("No")

Solution (Python):
import collections
N=int(input())
siritori=collections.defaultdict(int)
prev=" "
for i in range(N):
  word = input()
  if word in siritori:
    print("No")
    exit(0)
  elif prev[-1]!=word[0] and i != 0:
    print("No")
    exit(0)
  siritori[word]+=1
  prev=word
print("Yes")

Solution (Python):
N = int(input())
Ws = []
for i in range(N):
  W = input()
  Ws.append(W)
if len(set(Ws)) != N:
  print("No")
  exit()
for i in range(1, N):
  if Ws[i-1][-1] != Ws[i][0]:
    print("No")
    exit()
print("Yes")

Solution (Python):
N = int(input())
w =[input() for i in range(N)]

ans = "Yes"
if len(set(w))!=len(w):
    ans = "No"
for i in range(N-1):
    if w[i+1][0] !=w[i][-1]:
        ans = "No"
        break
print(ans)

Solution (Python):
N = int(raw_input())
W = []
ans = True
for i in range(N):
    W.append(raw_input())
    
for i in range(0,len(W)):
    if W.count(W[i]) != 1:
        ans = False
        break

for i in range(0,len(W)-1):
    A = W[i]
    B = W[i+1]
    if A[-1] != B[0]:
        ans = False
        break

if ans:
    print "Yes"
else:
    print "No"

Solution (Python):

n = int(input())
w = [0]*n
for i in range(n):
    w[i] = input() 
    
flag = False
for i in range(n-1):
    if w[i][len(w[i])-1] != w[i+1][0]:
        flag = True

s = set()
for i in range(n):
    if w[i] in s:
        flag = True
    else:
        s.add(w[i])

print('No' if flag else 'Yes')

Solution (Python):
N = int(input())

used_word_list = []
for n in range(N):
  if n == 0:
    pre_word = input()
    used_word_list.append(pre_word)
    pre_word = pre_word[-1]
    continue
  else:
    word = input()
    word_first = word[0]
    
    if (pre_word != word_first) or (word in used_word_list):
      print('No')
      exit()
    
    pre_word = word[-1]
    used_word_list.append(word)

print('Yes')

Solution (Python):
n = int(input())
w = [input() for _ in range(n)]

for i in range(1, n):
    if w[i][0] != w[i-1][-1] or w[i] in w[:i-1]:
        print("No")
        break
else:
    print("Yes")

Solution (Python):
from sys import stdin

n = int(stdin.readline().rstrip())

w = stdin.readline().rstrip()
w_lst = [w]
prev = w[-1]
f = True

for _ in range(n-1):
  w = stdin.readline().rstrip()
  if(w[0] != prev or w in w_lst):
    f = False
    break
  else:
    w_lst.append(w)
    prev = w[-1]
    
if f: print('Yes')
else: print('No')

Solution (Python):
"""
【ABC109】
B_Shiritori



import sys


def ILI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def ISI(): return map(int, sys.stdin.readline().rstrip().split())
def II(): return int(sys.stdin.readline().rstrip())
def ISS(): return sys.stdin.readline().rstrip().split()
def IS(): return sys.stdin.readline().rstrip()

N = II()
txt = []
good = True
txt = [IS() for i in range(N)]
for s in txt:
    if txt.count(s) > 1:
        good = False
for i in range(N-1):
    if txt[i][-1] != txt[i+1][0]:
        good = False
if good == True:
    print("Yes")
else:
    print("No")

Solution (Python):
n = int(input())
w = [input() for _ in range(n)]
if len(set(w)) != len(w):
  print('No')
else:
  for i in range(n-1):
    if w[i][-1] != w[i+1][0]:
      print('No')
      exit()
  print('Yes')

Solution (Python):
n = int(input())
w = []
for i in range(n):
    item = str(input())
    if i == 0:
        w.append(item)
    elif i!=0:
        if w[i-1][-1]==item[0]:
            w.append(item)
        elif w[i-1][-1]!=item[0]:
            print("No")
            exit()
l = set(w)
if len(l)==len(w):
    print("Yes")
else:
    print("No")

Solution (Python):
"""
【ABC109】
B_Shiritori



import sys


def ILI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def ISI(): return map(int, sys.stdin.readline().rstrip().split())
def II(): return int(sys.stdin.readline().rstrip())
def ISS(): return sys.stdin.readline().rstrip().split()
def IS(): return sys.stdin.readline().rstrip()

N = II()
txt = []
good = True
for i in range(N):
    txt += [IS()]
for s in txt:
    if txt.count(s) > 1:
        good = False
for i in range(N-1):
    if txt[i][-1] != txt[i+1][0]:
        good = False
if good == True:
    print("Yes")
else:
    print("No")

Solution (Python):
import sys
n = int(input())
yetlist = []
for i in range(n):
    word = input()
    if word in yetlist:
        print("No")
        sys.exit()
    if yetlist:
        if word[0] != yetlist[-1][-1]:
            print("No")
            sys.exit()
    yetlist.append(word)
print("Yes")

Solution (Python):
n=int(input())
l=[str(input()) for i in range(n)]
ans = 'Yes'
for i in range(1,n):
    if l[i][0] != l[i-1][-1]:
        ans = 'No'
        break
if len(set(l)) != n:
  ans = 'No'
print(ans)

Solution (Python):
N = int(input())

W0 = input()
W = []
W.append(W0)
for i in range(N - 1):
    W1 = input()
    if W0[-1] != W1[0] or W1 in W:
        print("No")
        exit()
    W.append(W1)
    W0 = W1
print("Yes")

Solution (Python):
import sys
n = int(input())
w =[input() for i in range(n)]
if len(w) > len(set(w)):
    print('No')
    sys.exit()
else:
    for i in range(n-1):
        if w[i][-1] != w[i+1][0]:
            print('No')
            sys.exit()
    print('Yes')

Solution (Python):
N = int(input())
W = [input() for i in range(N)]

if len(W) != len(set(W)):
    print('No')
    exit()

ini = W[0][0]
for i in W:
    if i[0] == ini:
        ini = i[-1]
    else:
        print('No')
        exit()
print('Yes')

Solution (Python):
N = int(input())
L = [input() for _ in range(N)]

before = L[0]
words = set([before])
for i in range(1, N):
    if before[-1] is not L[i][0] or L[i] in words:
        print("No")
        exit()
    before = L[i]
    words.add(before)

print('Yes')

Solution (Python):
n=int(input())
S=[input() for _ in range(n)]

if len(S)!=len(set(S)):
  print('No')
  exit()
for i in range(1,n):
  if S[i-1][-1]!=S[i][0]:
    print('No')
    exit()
print('Yes')

Solution (Python):
n=int(input())
A=[input()]
for i in range(1,n):
    a=input()
    if a[0]==A[i-1][-1] and a not in A:
        A.append(a)
    else:
        print('No')
        exit()
print('Yes')

Solution (Python):
n = int(input())
w = input()
words = set([w])
e = w[-1]
for _ in range(n - 1):
	w = input()
	if w in words or e != w[0]:
		print('No')
		break
	e = w[-1]
	words.add(w)
else:
	print('Yes')

Solution (Python):
N=int(input())
W=[input() for i in range(N)]
result='Yes'
for i in range(N-1):
    if W[i][-1] != W[i+1][0]:
        result='No'
        break
W_unique=list(set(W))
if len(W) != len(W_unique):
    result='No'
print(result)

Solution (Python):
def main():
    N = int(input())

    ok = True
    said = set()
    pre = input()
    said.add(pre)
    for i in range(1, N):
        w = input()
        if w in said:
            ok = False
            
        elif pre[-1] != w[0]:
            ok = False
            
        else:
            pre = w
            said.add(w)
    
    if ok:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()

Solution (Python):
N = int(input())
W = []
f = True
for i in range(N):
  W.append(input())
for i in range(N-1):
  if W[i][-1] != W[i+1][0]:
    f = False
W = sorted(W)
for i in range(N-1):
  if W[i] == W[i+1]:
    f = False
if f:
  print("Yes")
else:
  print("No")

Solution (Python):

n = int(input())
L = [input() for i in range(n)]
ans = "Yes"
if len(L) != len(set(L)):
    ans = "No"
for i in range(n-1):
    if L[i][-1] !=L[i+1][0]:
        ans ="No"
print(ans)

Solution (Python):
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  

n = ni()
word = input()
li = [word]
end = word[-1]
ans = 'Yes'
for i in range(n-1):
    word = input()
    if word[0] != end or word in li:
        ans = 'No'
        break
    end = word[-1]
    li.append(word)
print(ans)

Solution (Python):
N = int(input())
li = [input() for _ in range(N)]
se = set(li)

Flag = True
for i in range(N-1):
    if li[i][-1] != li[i+1][0]:
        Flag = False

if len(li) != len(se):
    Flag = False
        
if Flag:
    print("Yes")
else:
    print("No")

Solution (Python):
w=[]
n = int(input())
for _ in range(n):
    w.append(input())

if n != len(set(w)):
    print("No")
    exit()

for i in range(n-1):
    if w[i][-1] != w[i+1][0]:
        print("No")
        exit()
print("Yes")

Solution (Python):
N = int(input())
W = [input() for _ in range(N)]

if len(W) != len(set(W)):
    print("No")
    exit()
    
for i in range(N-1):
    if W[i][len(W[i])-1] != W[i+1][0]:
        print("No")
        exit()

print("Yes")

Solution (Python):
n = int(input())
s = [input() for _ in range(n)]
valid = True
if len(set(s)) != n:
    valid = False
else:
    for i in range(n - 1):
        if s[i][-1] != s[i + 1][0]:
            valid = False
            break
if valid is False:
    print("No")
else:
    print("Yes")

Solution (Python):
ss = []
for i in range(int(input())):
  s = input()
  if len(ss) == 0:
    ss.append(s)
  elif not s in ss and s[0] == ss[-1][-1]:
    ss.append(s)
  else:
    print('No')
    break
else:
  print('Yes')

Solution (Python):
from collections import defaultdict
dd = defaultdict(bool)
n = int(input())
w = [input() for _ in range(n)]
pre = w[0][0]
for s in w:
    if dd[s] or (pre[len(pre) - 1] != s[0]):
        print("No")
        exit()
    dd[s] = True
    pre = s
print("Yes")

Solution (Python):
n=int(input())
w=[]
ws=[]
count=1
for i in range(n):
    w.append(input())
    ws.append(list(w[i]))
for i in range(n):
    if (w.count(w[i]))>1:
        count-=1
for j in range(n-1):
    if (ws[j][len(w[j])-1])==(ws[j+1][0]):
        count+=1
if count==int(n):
    print('Yes')
else:
    print('No')

Solution (Python):
import collections
N= int(input())
n=[]
for i in range(N):
	n.append(input())
c = collections.Counter(n)
if len(c) !=len(n):
	print("No")
	exit()
for i in range(N-1):
	if n[i+1][0] != n[i][len(n[i]) -1]:
		print("No")
		exit()

print("Yes")

Solution (Python):
n = int(input())
w = [input() for i in range(n)]
c = 0

if len(set(w)) != n:
  c = 101
else:
  for i in range(n-1):
    if w[i][-1] == w[i+1][0]:
      c += 1

print("Yes" if c == n-1 else "No")

Solution (Python):
n = int(input())
w = [input() for i in range(n)]
c = 0

if len(set(w)) != n:
  print("No")
  exit()
  
for i in range(n-1):
  if w[i][-1] == w[i+1][0]:
    c += 1

print("Yes" if c == n-1 else "No")

Solution (Python):
n=int(input())
cur=input()
past=[cur]
ans=True
for i in range(n-1):
  s=input()
  if cur[-1:]==s[0] and s not in past:
    past.append(s)
    cur=s
  else:
    ans=False
    break

print(("No","Yes")[ans])

Solution (Python):

N=int(input())
s=True
w1=input()
W=[w1]
for i in range(N-1):
    w2=input()
    W.append(w2)
    if len(set(W))==len(W) and w1[-1]==w2[0]:
        w1=w2
    else:
        s= False
if s:
    print("Yes")
else:
    print("No")

Solution (Python):

N=int(input())
W=[]
s=True
for i in range(N):
    W.append(input())
if len(set(W))==N:
    for i in range(N-1):
        if W[i][-1]!=W[i+1][0]:
            print("No")
            s=False
            break   
else:
    print("No")
    s=False
if s:
    print("Yes")

Solution (Python):
n = int(input())
w0 = input()
word_set = set([w0])
ans = True

for i in range(1, n):
    w = input()
    if ans and w not in word_set and w[0] == w0[-1]:
        word_set.add(w)
        w0 = w
    else:
        ans = False

if ans:
    print("Yes")
else:
    print("No")

Solution (Python):
n = int(input())
L = [input() for i in range(n)]
ans = "Yes"
if len(L) != len(set(L)):
    ans = "No"
for i in range(n-1):
    if L[i][-1] !=L[i+1][0]:
        ans ="No"
print(ans)

Solution (Python):
def takahashi():
    N = int(input())
    L = [input() for _ in range(N)]
    if len(L) != len(set(L)):
        print("No")
        return
    for i in range(N - 1):
        if L[i][-1] != L[i + 1][0]:
            print("No")
            return
    print("Yes")


takahashi()

Solution (Python):
N = int(input())
se = set()
ans = 'Yes'
s = input()
se.add(s)
c = s[-1]
for i in range(N-1):
    s = input()
    if s in se or s[0] != c:
        ans = 'No'
        break
    c = s[-1]
    se.add(s)
print(ans)

Solution (Python):
n = int(input())
lst = []
for i in range(n):
    s = input()
    if i==0:
        text = s
        lst.append(s)
        continue
    else:
        if s in lst or text[-1] != s[0]:
            print('No')
            exit()
        else:
            text = s
            lst.append(s)
print('Yes')

Solution (Python):
N = int(input())
L = [input() for _ in range(N)]

flg = False
if len(L) != len(set(L)): flg = True
for i in range(1, N):
  if flg: break
  if i != 0:
    if L[i][0] != L[i-1][-1]:
      flg = True
print ("No" if flg else "Yes")

Solution (Python):
n = int(input())
w = [input() for _ in range(n)]

prev = w[0][0]
for x in w:
  if not(w.count(x) == 1 and x[0] == prev):
    print('No')
    exit(0)
  prev = x[-1]

print('Yes')

Solution (Python):
n,*w=open(0);n=int(n);print("No"if len(set(w))<n else" YNeos"[all(w[i][-2]==w[i+1][0]for i in range(n-1))::2])

Solution (Python):
n = int(input())
li = [input() for i in range(n)]

for i in range(n-1):
    if li[i][-1] == li[i+1][0]:
        flag = True
    elif li[i][-1] != li[i+1][0]:
        flag = False
        break
if flag == True and len(li) == len(set(li)):
    print("Yes")
else:
    print("No")

Solution (Python):
n = int(input())
words = [input() for x in range(n)]

A = 'Yes'

last_word = words[0][-1:]


if len(words) != len(list(set(words))):
    A = 'No'

for i in range(1, n):
    if last_word == words[i][:1]:
        last_word = words[i][-1:]
        continue

    else:
        A = 'No'
        break

print(A)

Solution (Python):
N = int(input())
W = []
for _ in range(N):
    W.append(input())

ans = True
for i in range(N):
    for j in range(N):
        if i != j and W[i] == W[j]:
            ans = False

for i in range(N - 1):
    if W[i][-1] != W[i + 1][0]:
        ans = False

if ans == True:
    print("Yes")
else:
    print("No")

Solution (Python):
w=[input() for _ in range(int(input()))]

used=[w[0]]
last_chr=w[0][-1]

for word in w[1:]:
    if (word[0]==last_chr) and (word not in used):
        used.append(word)
        last_chr=word[-1]
    else:
        print("No")
        exit()
print('Yes')

Solution (Python):
def main():
    N = int(input())
    used = set()
    prev = input()
    used.add(prev)
    for i in range(1, N):
        w = input()
        if w in used or w[0] != prev[-1]:
            return "No"
        used.add(w)
        prev = w
    return "Yes"

if __name__ == '__main__':
    print(main())

Solution (Python):
N = int(input())

W, OK = ["-"], True
for i in range(N):
    W.append(input())
    if W[-1] in W[:-1] or (W[-2][-1] != W[-1][0] and W[-2] != "-"):
        OK = False

print("Yes" if OK else "No")

Solution (Python):
n=int(input())

word=[input() for _ in range(n)]
if len(word)!=len(set(word)):
    print("No")
else:
    isOK=True
    for i,j in zip(word[:-1], word[1:]):
        if i[-1]!=j[0]:
            isOK=False
    print("Yes") if isOK else print("No")

Solution (Python):
def main():
    N = int(input())

    W = [""] * N

    for i in range(N):
        W[i] = input()

    set_W = set(W)

    if len(set_W) != N:
        print('No')
        exit()

    for i in range(N-1):
        if W[i][len(W[i]) - 1] != W[i+1][0]:
            print('No')
            exit()

    print('Yes')


main()

Solution (Python):
N = int(input())
W = []
for i in range(N):
  W.append(str(input()))
  
ans="Yes"
for i in range(1,N):
  if W.count(W[i]) > 1 or W[i][0:1] != W[i-1][len(W[i-1])-1:len(W[i-1])]:
    ans = "No"
print(ans)

Solution (Python):
n = int(input())

last = input()
s = set()
s.add(last)

for i in range(1, n):
    word = input()
    if last[len(last) - 1] != word[0] or word in s:
        print("No")
        exit(0)
    else:
        last = word
        s.add(word)
print("Yes")

Solution (Python):
n = int(input())
wl = [input() for i in range(n)]
saidl = [wl[0]]

for i in range(1,n):
	if wl[i-1][-1] == wl[i][0]:
		if wl[i] in saidl:
			print("No")
			quit()
		else:
			saidl.append(wl[i])
	else:
		print("No")
		quit()
print("Yes")

Solution (Python):
n = int(input())
ald = set()
start = input()
ald.add(start)
flag = True
for i in range(1,n):
    nword = input()
    if nword not in ald and start[-1] == nword[0]:
        ald.add(nword)
        start = nword
    else:
        flag = False

if flag:
    print("Yes")
else:
    print("No")

Solution (Python):
n=int(input())
l=[input() for i in range(n)]
if len(set(l))!=n:
  print("No")
else:
  f=True
  for i in range(1,n):
    if (l[i-1])[-1]!=(l[i])[0]:
      f=False
      break
  print("Yes" if f else "No")

Solution (Python):
N = int(input())
W = [input() for _ in range(N)]

Ws = set([W[0]])
for i in range(1, N):
    if not W[i - 1][-1] == W[i][0] or W[i] in Ws:
        print("No")
        exit()
    else:
        Ws.add(W[i])

print("Yes")

Solution (Python):
n = int(input())
w = [input() for _ in range(n)]
w_used = set()
pre_word = ""
for i in range(n):
    if i == 0:
        pre_word = w[i]
        w_used.add(w[i])
        continue
    if pre_word[-1] != w[i][0] or w[i] in w_used:
        print("No")
        break
    w_used.add(w[i])
    pre_word = w[i]
else:
    print("Yes")

Solution (Python):
n = int(input())
w = [input() for _ in range(n)]
w_used = set()
pre_word = ""
for i in range(n):
    if i == 0:
        pre_word = w[i]
        w_used.add(w[i])
        continue
    if pre_word[-1] != w[i][0] or w[i] in w_used:
        print("No")
        break
    w_used.add(w[i])
    pre_word = w[i]
else:
    print("Yes")

Solution (Python):
import math
import sys
import queue
from collections import Counter
from itertools import accumulate
from fractions import gcd
from functools import reduce


def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

sys.setrecursionlimit(10000)

mod = 1000000007

"""

a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654


char_list = list("abcd") 



    = sys.stdin.readline().rstrip()
    = list(sys.stdin.readline().rstrip())


    = int(sys.stdin.readline())
    = map(int, sys.stdin.readline().split())
    = list(map(int, sys.stdin.readline().split()))
    = [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""

if __name__ == "__main__":
    N = int(sys.stdin.readline())
    L = []
    e = ""
    for i in range(N):
        S = sys.stdin.readline().rstrip()
        if S in L:
            print("No")
            exit()
        L.append(S)
        if i > 0:
            if e != S[0]:
                print("No")
                exit()
        e = S[::-1][0]

    print("Yes")

Solution (Python):
N = int(input())
w = []
ans = "Yes"
for i in range(N):
  s = str(input())
  if(i>0):
    if(s[0]==w[-1][-1]):
      None
    else:
      ans = "No"
      break
  w.append(s)
j = set(w)
l = len(list(j))
if(N==l):
  None
else:
  ans="No"
print(ans)

Solution (Python):
n = int(input())
s = []
check = True
s .append(input())
for i in range(1,n):
    s.append(input())
    if s[i-1][-1] != s[i][0] or s[i] in s[:i]:
        check = False
        break
if check:
    print("Yes")
else:
    print("No")

Solution (Python):
n = int(input())
words = []
for i in range(n):
    words.append(input())

flag = True

for i in range(n-1):
    if words[i][-1] != words[i+1][0]:
        flag = False
        break

if len(set(words)) != n:
    flag = False

if flag:
    print('Yes')
else:
    print('No')

Solution (Python):
n = int(input())
w = []

for i in range(n):
    w.append(input())

ans = True

for i in range(1, n):
    if w.count(w[i]) > 1 or w[i-1][-1] != w[i][0]:
        ans = False
        break

if ans:
    print('Yes')
else:
    print('No')

Solution (Python):

N = int(input())
W = [0] * N
for i in range(N):
    W[i] = input()

flag = True
if N != len(set(W)):
    flag = False
if flag:
    for i in range(N-1):
        if W[i][-1] != W[i+1][0]:
            flag  = False
            break
if flag:
    print("Yes")
else:
    print("No")

Solution (Python):
N = int(input())
hist = [input()]
res = 'No'
s = hist[0][-1]
for _ in range(N-1):
  w = input()
  if w in hist or w[0] != s:
    break
  s = w[-1]
  hist.append(w)
else:
  res = 'Yes'
print(res)

Solution (Python):
n=int(input())
w=[]
for _ in range(n):
    w.append(str(input()))
if len(set(w))!=n:
    print('No')
else:
    for i in range(n-1):
        if w[i][-1]!=w[i+1][0]:
            print('No')
            break
    else:
        print('Yes')

Solution (Python):
N=input()
a=[]
Z=[]
for i in range(int(N)):
    A=input()
    Z.append(A)
    a.append(A[0])
    a.append(A[-1])

del a[-1],a[0]

if len(Z) != len(set(Z)):
    print("No")
elif a[0::2] != a[1::2]:
    print("No")
elif a[0::2] == a[1::2]:
    print("Yes")

Solution (Python):
import collections
n = int(input())
w = list(str(input()) for _ in range(n))
w2 = list(collections.Counter(w).values())
if max(w2) != 1:
    print('No')
else:
    for i in range(n-1):
        if w[i][-1] != w[i+1][0]:
            print('No')
            break
    else:
        print('Yes')

Solution (Python):
def solve():
    n = int(input())
    w = list(input() for _ in range(n))
    if len(set(w)) != n:
        return "No"
    for i in range(n - 1):
        if w[i][-1] != w[i + 1][0]:
            return "No"
    return "Yes"


if __name__ == "__main__":
    print(solve())

Solution (Python):
n = int(input())
w = [input() for _ in range(n)]
e = []
for i in range(n):
    if i == 0:
        e.append(w[i])
    else:
        cw = w[i]
        lw = w[i-1]
        if cw[0] != lw[-1] or cw in e:
            print("No")
            exit()
        else:
            e.append(cw)
print("Yes")

Solution (Python):
N,*S = open(0).read().split()

F = True if len(S) == len(set(S)) else False
for i in range(int(N)-1):
  if S[i][-1] != S[i+1][0]:
    F = False
print("Yes" if F else "No")

Solution (Python):
n = int(input())
nlist = [input() for i in range(n)]
if len(nlist) != len(set(nlist)):
    print('No')
    exit()
for i, j in enumerate(nlist):
    if i + 1 < len(nlist):
        if nlist[i][-1] != nlist[i + 1][0]:
            print('No')
            exit()
print('Yes')

Solution (Python):

from collections import defaultdict

n = int(input())
W = [input() for _ in range(n)]

dd = defaultdict(int)
before = ''
for c in W:
    if dd[c] == 0 and (before == '' or before[-1] == c[0]):
        dd[c] += 1
        before = c
    else:
        print('No')
        exit()

print('Yes')

Solution (Python):
n,*words=list(open(0).read().split())

ans='Yes'
if len(set(words)) != int(n):
  ans='No'
else:
  for a,b in zip(words, words[1:]):
    if not a[-1] == b[0]:
      ans='No'
      break
print(ans)

Solution (Python):
n=int(input())
x=[]
s="Yes"
for i in range(n):
    w=input()
    if i!=0 and (w in x or x[i-1][-1]!=w[0]):
        s="No"
    x.append(w)
print(s)