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):
print("No" if (lambda w:(sum([w.count(s)-1 for s in w])) or sum([w[i][0] != w[i-1][-1] for i in range(1,len(w))]))([input() for i in range(int(input()))]) else "Yes")

Solution (Python):
print("No" if (lambda w:(sum([w.count(s)-1 for s in w])) or sum([1-(w[i][0] == w[i-1][-1]) for i in range(1,len(w))]))([input() for i in range(int(input()))]) else "Yes")

Solution (Python):
n=int(input())
w=[input() for i in range(n)]
flag=True
for s in w:
    if w.count(s) > 1:
        flag = False
for i in range(1,n):
    if w[i][0] != w[i-1][-1]:
        flag = False
print("Yes" if flag else "No")

Solution (Python):
N = int(input())
s = set()
p = input()
s.add(p)
valid = True
for i in range(1, N):
    t = input()
    if(t in s or p[-1] != t[0]):
        valid = False
    p = t
    s.add(p)
print("Yes" if valid else "No")

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

Solution (Python):
n=int(input())
a=[input() for i in range(n)]
b=set(a)
c=0
if len(a)!=len(b):print("No")
else:
  for x in range(n-1):
     if a[x][len(a[x])-1]!=a[x+1][0]:c+=1
  if c>0:print("No")
  else:print("Yes")

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

count=0

for i in range(n-1):
    if word[i][-1] != word[i+1][0]:
        count += 1

if len(set(word)) != len(word):
    count += 1

if count==0:
    print('Yes')
else:
    print('No')

Solution (Python):
n=int(input())
s=[input()for _ in[0]*n]
f=0
for i in range(1,n):
    f+=s[i-1][-1]!=s[i][0]
print("No"if f or len(set(s))<n else"Yes")

Solution (Python):


n = int(input())
words = [0]*n
for i in range(n):
    words[i] = str(input())

state = 1

for i in range(n-1):
    
    if list(words[i])[-1] == list(words[i+1])[0]:
        state = 1
    else:
        state = 0
        break

if len(list(set(words))) < n:
    state = 0

if state == 1:
    print("Yes")
else:
    print("No")

Solution (Python):
falsify = "Yes"
c = int(input())
w = []
for i in range(c):
  w.append(input())
if len(set(w)) != len(w):
  falsify = "No"
for i in range(len(w) - 1):
  if w[i][-1] != w[i+1][0]:
    falsify = "No"
print(falsify)

Solution (Python):
n = int(input())
word_list = [input() for _ in range(n)]
flag_count = 0
for word in word_list:
    count = 0
    count = word_list.count(word)
    if count == 1:
        if word_list.index(word) != 0:
            if word[0] == last_string:
                flag_count += 1
    last_string = word[-1]
if flag_count == n-1:
    print('Yes')
else:
    print('No')

Solution (Python):
n=int(input())
flg=True
se=set()
for i in range(n):
  s=input()
  if s in se:
    flg=False
  se.add(s)
  if not i:
    f,b=s[0],s[-1]
  else:
    if s[0]!=b:
      flg=False
    f,b=s[0],s[-1]
if flg:
  print("Yes")
else:
  print("No")

Solution (Python):
N = int(input())
l = []
ans = 'Yes'
for i in range(N):
    w = input()
    if w in l:
        ans = 'No'
        break
    l.append(w)
    if i == 0:
        continue
    if l[i-1][-1] != l[i][0]:
        ans = 'No'
        break
print(ans)

Solution (Python):
cnt = int(input())
ans = 'Yes'
pw = input()
already = set()
already.add(pw)
for i in range(1, cnt):
    nw = input()
    if pw[-1] != nw[0] or nw in already:
        ans = 'No'
        break
    else:
        pw = nw
        already.add(pw)
print(ans)

Solution (Python):
N = int(input())
W = str(input())
gobi = W[-1]
List = []
List.append(W)
a = True
for i in range(N-1):
  W = str(input())
  if gobi == W[0] and not(W in List):
    List.append(W)
    gobi = W[-1]
    continue
  else:
    a = False
    break
if a == True:
  print("Yes")
else:
  print("No")

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

WL = []
for _ in range(N):
    WL.append(input())

WS = set(WL)

R = 'Yes'
if len(WL) == len(WS):
    for w1, w2 in zip(WL[:-1], WL[1:]):
        if w1[-1] != w2[0]:
            R = 'No'
            break
else:
    R = 'No'

print(R)

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

flg = True
for i in range(n - 1):       
    if w[i][-1] != w[i + 1][0]:
        flg = False
        break
for i in range(n):
    for j in range(i):
        if w[i] == w[j]:
            flg = False
            break
    if not flg:
        break
    
print('Yes' if flg else 'No')

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

def func(N, words):
    if (len(words) != len(set(words))):
        return "No"
    
    for n in range(N-1):
        if words[n][-1] != words[n+1][0]:
            return "No"
    else:
        return "Yes"

print(func(N, words))

Solution (Python):
L=[input()for x in' '*int(input())];print('YNeos'[any(i[-1]!=j[0]*L.count(i)for i,j in zip(L,L[1:]))::2])

Solution (Python):
N=int(input())
W=[]
count=0
for i in range(N):
	w=str(input())
	W.append(w)
for i in range(N):
	c=0
	for j in range(N):
		if W[i]==W[j]:
			c=c+1
		if c>=2 and count==0:
			print("No")
			count=1
for i in range(N-1):
	s=0
	for j in W[i+1]:
		s=s+1
		if s==1:
			t=j
		for k in W[i]:
			r=k
	if t!=r and count==0:
		print("No")
		count=2
if count==0:
	print("Yes")

Solution (Python):
N = int(input())
word = []
for i in range(N):
    word.append(str(input()))
flag = True


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

for i in range(N):
    searchWord = word[i]
    for k in range(N):
        if i != k and searchWord == word[k]:
            flag = False

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

Solution (Python):
L=[input()for x in' '*int(input())];print('YNeos'[any(i[-1]!=j[0]*(L.count(i))for i,j in zip(L,L[1:]))::2])

Solution (Python):
N=int(input())
S=[input() for i in range(N)]
ans='Yes'
if N!=len(set(S)):
    ans='No'
for i in range(0,N-1):
    if S[i][len(S[i])-1]!=S[i+1][0]:
        ans='No'
print(ans)

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

Solution (Python):
import sys
def is_unique(seq):
    return len(seq) == len(set(seq))

N = int(input())
W = []
for i in range(N):
    W.append((input()))
if is_unique(W):
    for i in range(N-1):
        if W[i][-1] != W[i+1][0]:
            print("No")
            sys.exit()
    print("Yes")

else:
    print("No")

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

Solution (Python):
if __name__ == '__main__':
  
  flag = 1
  
  wordNum = int(input())
  wordAll = []

  for i in range(wordNum) :

    word = input()
    wordAll.append(word)
    wordLen = len(word)
    
    if i > 0 and wordLast != word[0]:
      flag = 0
      break
    
    
    for j in range(len(wordAll)-1):
      if wordAll[j] == word:
        flag = 0
        break
    
    
    wordLast = word[wordLen - 1]

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

Solution (Python):
N=int(input())
def x(N):
    lis= []
    for i in range(N):
        lis.append([])
    return lis
W=x(N)
W[0]=input()
flag=1
a=list(W[0])
start=a.pop()
def panduan():
    for i in range(1,N):
        W[i]=input()
        global flag
        for each in range(i):
            if W[i]==W[each]:
                flag=0
        a=list(W[i])
        start=a.pop(0)
        if flag!=0 and W[i-1].endswith(start):
            flag=1
        else:
            flag=0
panduan()
if flag==1:
    print('Yes')
else:
    print('No')

Solution (Python):
N = int(input())
W = []
flg = False

for i in range(N):
    Wi = input()
    if i != 0 and (Wi in W or W[-1][-1] != Wi[0]):
        flg = True
    W.append(Wi)

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

Solution (Python):

def has_duplicated_elem(word_list):
    if len(list(set(word_list))) == len(word_list):
        return False
    else:
        return True


def break_shiritori_rule(word_list):
    for i,word in enumerate(word_list):
        
        if i+1 == len(word_list):
            return False
        if word[-1] == word_list[i+1][0]:
            continue
        else:
            return True
    else:
        return False

num = int(input())
word_list = []
for i in range(num):
    word_list.append(input())

if has_duplicated_elem(word_list) or break_shiritori_rule(word_list):
    print('No')
else:
    print('Yes')

Solution (Python):
n = int(input())
a = []
flag = 1
before = ""
def is_unique(seq):
    return len(seq) == len(set(seq))
for i in range(n):
    a1 = input()
    a.append(a1)
    if i == 0:
        before = a1[len(a1)-1]
        continue
    if before != a1[0]:
        flag = 0
    before = a1[len(a1)-1]
if is_unique(a) == False:
    flag = 0
if flag==0:
    print("No")
else:
    print("Yes")

Solution (Python):
import sys
 
n = int(input())
l = []
p = None
 
for i in range(n):
  s = input()
  if s not in l and (p == None or p[-1:] == s[:1]):
    l.append(s)
    p = s
  else:
    print("No")
    sys.exit()
print("Yes")

Solution (Python):
n=int(input())
words=[input() for _ in range(n)]
distinct_words=set(words)
if(len(words)==len(distinct_words) and
   all(pword[-1]==nword[0] for pword,nword in zip(words[:-1],words[1:]))):
   print('Yes')
else:
   print('No')

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

old = None
w = []

for i in range(n):
    word = input()
    if old:
        if word[0] != old[-1]:
            print("No")
            exit()
        elif word in w:
            print("No")
            exit()
    w.append(word)
    old = word

print("Yes")

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

old = None
w = []

for i in range(n):
    word = input()
    if old:
        if word[0] != old[-1]:
            print("No")
            exit()
        elif word in w:
            print("No")
            exit()
    w.append(word)
    old = word
    print()

print("Yes")

Solution (Python):

import sys
N = int(input())
words = [input() for w in range(N)]

i = 0
if len(set(words)) != len(words):
    print("No")
    sys.exit()
else:
    while i < N-1:
        if words[i][-1] != words[i+1][0]:
            print("No")
            sys.exit()
        i += 1
    print("Yes")

Solution (Python):
N = int(input())
a = [input() for i in range(N)]
 
for num in range(N):
  if num > 0:
    if a[num] in a[:num-1]:
    	print('No')
    	break
  if num < N-1:
    if a[num][-1] != a[num+1][0]:
    	print('No')
    	break
  if num == N-1:
    print('Yes')

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

for i in range(N-1):
    if W[i+1][0]!=W[i][-1]:
        r = r+1
for i in range(N):
    for p in range(N):
        if W[i]==W[p]:
            r = r+1
if r == N:
    print('Yes')
else:
    print('No')

Solution (Python):
N=int(input())
W=[input() for i in range(N)]
res = (len(set(W))==N)
for i in range(N-1):
    res &= W[i][-1] == W[i+1][0]
if res:
    print("Yes")
else:
    print("No")

Solution (Python):
L=[input()for x in' '*int(input())];b=0;p=L[0]
for i in L[1:]:b|=p[-1]!=i[0];p=i
print('YNeos'[len(set(L))<len(L)or b::2])

Solution (Python):

N = int(input())
W = []
for i in range(N):
    W.append(str(input()))


if len(W) != 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 i in range(N)]
S = set(W)
p = 0
if (len(W) != len(S)):
  print('No')
else:
  for k in range(N-1):
    a = W[k]
    b = W[k+1]
    if (a[len(a)-1] == b[0]):
      p += 1
    else:
      p += 0
  if (p == N-1):
    print('Yes')
  else:
    print('No')

Solution (Python):
def spaceinput():
    return list(map(int,input().split(" ")))



N=int(input())
words=[]
done=[]
for i in range(N):
    words.append(input())

done.append(words[0])
for i in range(1,N):
    if words[i-1][-1]!=words[i][0]:
        print("No")
        break

    if words[i] in done:
        print("No")
        break

    done.append(words[i])
    if i==N-1:
        print("Yes")

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

word = input()
known_words = [word]
for i in range(n-1):
    word = input()
    if word in known_words:
        print('No')
        exit()
    if word[0] != known_words[-1][-1]:
        print('No')
        exit()
    known_words.append(word)
print('Yes')

Solution (Python):
import collections
n=int(input())
a=[]
for i in range(0,n):
    a.append(input())
d=collections.Counter(a)
flag=0
for i in a:
    if d[i]>1:
        flag=1
        break
if flag==1:
    print("No")
else:
    l=len(a[0])
    s=a[0]
    t=s[l-1]
    flag=0
    for i in range(1,n):
        s=a[i]
        m=s[0]
        if m!=t:
            flag=1
            break
        s=a[i]
        l=len(s)
        t=s[l-1]
    if flag==1:
        print("No")
    else:
        print("Yes")

Solution (Python):
input_lines = int(input())
tango=[]
lastchar = ''
for i in range(input_lines):
    s = input().rstrip()
    if len(lastchar) > 0 and not s[0] in lastchar or s in tango:
        print('No')
        break
    tango.append(s)
    lastchar = s[-1]
else:
    print('Yes')

Solution (Python):
strings = []
stringed = " "
flag = 0

num = int(input())

for i in range(num):
    string = input()
    if string[0] != stringed[-1] and i != 0:
        flag = 1
    for st in strings:
        if st == string:
            flag = 1
    if flag == 1:
        break
    stringed = string
    strings.append(string)

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

Solution (Python):
N = int(input())
A = []
for i in range(N):
   A.append(input())
S = 0
for i in range(N-1):
    if A[i][-1] == A[i+1][0]:
        S += 1
B = 0
for i in range(N):
    for j in range(N):
        if A[i] == A[j]:
            B += 1
        else:
            B += 0

if S == N-1 and B == N:
    print('Yes')
else:
    print('No')

Solution (Python):
x = 0
listen = []
first = []
last = []
n = int(input())
for i in range(n):
 listen.append(input())
 first.append(listen[i][:1])
 last.append(listen[i][-1:])
 if i > 0:
  if first[i] != last[i-1]:
   x = 1
 for k in range(i):
  if listen[k] == listen[i]:
   x = 1
if x == 0:
 print ('Yes')
else:
 print ('No')

Solution (Python):


num = int(input())
x = [str(input())]

for i in range(num-1):
    
    saigo = x[-1]
    saigoMoji = saigo[-1]

    verStr = str(input())
    tugiMoji = verStr[0]

    if saigoMoji != tugiMoji:
        print("No")
        exit()

    
    if verStr in x:
        print("No")
        exit()
    else:
        x.append(verStr)
print("Yes")

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

A = set()


for i, s in enumerate(S):
    if s in A or (i - 1 >= 0 and S[i-1][-1] != s[0]):
        print('No')
        exit()
    A.add(s)

print('Yes')

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

Solution (Python):
n = int(input())
words = ['' for i in range(n)]
flag = True
for i in range(n):
    word = input()
    if i == 0:
        words[i] = word
    elif word not in words and words[i-1][-1] == word[0]:
        words[i] = word
    else:
        flag = False
        break
if flag:
    print('Yes')
else:
    print('No')

Solution (Python):
N = int(input())
L = []

Ans = True

for i in range(N):
    a =input()
    L.append(a)

for j in range(N-1):
    if list(L[j])[-1] != list(L[j+1])[0]:
        Ans = False

for k in range(N):
    if L[k] in L[:k]:
        Ans = False
        
if Ans == True:
    print('Yes')
else:
    print('No')

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

Solution (Python):
import sys

A = int(input())

wordlist = []
tmplist = []
lastword = ""

for b in range(A):
    wordlist.append(input())
    tmpstr = wordlist[-1]

    if(lastword != ""):
        if(tmpstr[0] != lastword):
            print("No")
            sys.exit()
    lastword = tmpstr[-1]

if(len(wordlist) == len(set(wordlist))):
    print("Yes")
else:
    print("No")

Solution (Python):
n=int(input())
a=input()
s={a}
r="Yes"
for i in range(1,n):
  b=input()
  if a[-1] != b[0] or b in s:
    r="No"
    break
  a=b
  s.add(b)
print(r)

Solution (Python):
words = []
result = 0
N = int(input())
words.append(input())
for i in range(1, N):
	temp = input()
	if temp in words:
		result +=1
	words.append(temp)
	if words[i][0] != words[i - 1][-1]:
		result +=1
if result == 0:
	print("Yes")
else:
	print("No")

Solution (Python):
from sys import stderr
from functools import reduce
from operator import add
def f(): return [int(i) for i in input().split()]
def yes(n): print("Yes" if n else "No")
def debug(*x, sep=" ", end="\n"):
    for item in x:
        stderr.write(str(item))
        stderr.write(sep)
    stderr.write(end)

n = int(input())
words = [input()]
for _ in range(n-1):
    word = input()
    if word in words or word[0] != words[-1][-1]:
        print("No")
        break
    else:
        words.append(word)
else:
    print("Yes")

Solution (Python):
N = int(input())
W = [input() for i in range(N)]
sum = 0
for i in range(N):
  for j in range(N):
    if W[i] == W[j]:
      sum = sum+1
if sum != N:
  print("No")
  exit()
for i in range(N-1):
  if W[i][-1] != W[i+1][0]:
    print("No")
    exit()
print("Yes")

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

	for i, word in enumerate(W):
		if i != 0:
			if word[:1] != W[i-1][-1:]:
				return False
	if len(W) != len(set(W)):
		return False

	return True


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

Solution (Python):
n=int(input())
flag='OK'
maeWord=''
nowWord=''
wordList=[]

for i in range (1,n+1):
  if(i==1):
      maeWord=input()
      wordList.append(maeWord)
  else:
    nowWord=input()
    if(nowWord in wordList):
      flag='NG'
    
    if(list(maeWord)[-1] != list(nowWord)[0]):
      flag='NG'
      
    maeWord=nowWord
    wordList.append(maeWord)
    
if(flag=='NG'):
  print('No')
else:
  print('Yes')

Solution (Python):
n,w,temp = int(input()),[],[]
for i in range(n):
    w.append(input())
    if w[-1] in temp:
        print("No")
        exit()
    else:
        temp.append(w[-1])
    if i>0 and w[i-1][-1] != w[i][0]:
        print("No")
        exit()
print("Yes")

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

atama=[]
oshiri=[]

def is_unique(seq):
    return len(seq) == len(set(seq))



for i in s:
    atama.append(i[0])
    oshiri.append(i[-1])



oshiri=oshiri[-1:]+oshiri[:-1]

atama.pop(0)
oshiri.pop(0)

if oshiri==atama and is_unique(s)==True:
    print("Yes")
else:
    print("No")

Solution (Python):
n = int(input())
 
shiritori = []
tmp = 0
for i in range(n):
    shiritori.append(input())
    if i > 0:
        if not shiritori[i-1][-1] == shiritori[i][0]:
            tmp += 1
        if not tmp > 0:
            for j in range(i):
                if shiritori[i] == shiritori[j]:
                    tmp += 1
                    break;
if(tmp > 0):
    print('No')
else:
    print('Yes')

Solution (Python):

def is_unique(seq):
    return len(seq) == len(set(seq))
N = int(input())
a = []
for i in range(N):
    a.append(input())

flag = True

if is_unique(a) == False:
  flag = False
  
for i in range(1,N):
    s1 = a[i-1]
    s2 = a[i]
    s3 = s1[len(s1)-1]
    s4 = s2[0]
    if s3 != s4:
      flag = False
      
if flag == False:
  print("No")
else:
  print("Yes")

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

words = []

flag = 0

for i in range(N):
    w = input()

    words.append(w)
    if i == 0:
        continue
    if words[i-1][-1] != w[0]:
        flag = 1

sets = set(words)

if len(sets) != len(words):
    flag = 1

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

Solution (Python):
def fun():
    N = int(input())
    W = []
    for n in range(N):
        W.append(input())
    for i, w in enumerate(W):
        if i==0:
            prev_w = w
            continue
        for wn in W[:i]:
            if w == wn:
                print('No')
                return 
        if prev_w[-1] != w[0]:
            print('No')
            return
        prev_w = w
    print('Yes')
    return

fun()

Solution (Python):
import sys

N=int(input())

lst=[]
for i in range(N):
    lst.append(input())



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



nbr=0
flag=0
before_word=""
now_word=""

for i in lst:
    
    if (before_word != ""):
        
        
        if(before_word[-1] != i[0]):
            print("No")
            sys.exit()

    
    before_word = i

print("Yes")

Solution (Python):
import sys
def is_unique(seq):
    return len(seq) == len(set(seq))


N = int(input())
a = []
for i in range(N):
    a.append(input()) 


if not(is_unique(a)):
	print("No")
	sys.exit()

last_char=""
counter=0
for item in a:
	if counter == 0:
		last_char = item[-1]
		counter = 1
	else:
		if(len(item) > 11):
			print("No")
			sys.exit()
		if not (item[0] == last_char):
			print("No")
			sys.exit()
		else:
			last_char = item[-1]
			
print("Yes")

Solution (Python):
n = int(input())
a = []
for i in range(n):
  b = input()
  if b in a:
    print("No")
    exit()
  a.append(b)
mae = a[0][-1]
for i in range(1,n):
  if mae != a[i][0]:
    print("No")
    exit()
  mae = a[i][-1]
print("Yes")

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


ans = 1

if len(a) != len(set(a)):
    ans = 0

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

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

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

ans = 'Yes'
s = []
s.append(w[0])
for i in range(1,n):
    if w[i-1][-1] != w[i][0]:
        ans = 'No'
    if w[i] in s:
        ans = 'No'
    s.append(w[i])

print(ans)

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

w = []
count = 0

for i in range(n):
    w.append(input())
    if i >= 1:
        m = w[i - 1]
        l = m[-1]
        hantei = w[i].startswith(l)
        if hantei == False:
            count = 1
    a = 0
    for j in w:
        if w[i] == j:
            a += 1
        if a > 1:
            count = 1

if count == 1:
    print('No')
else:
    print('Yes')

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

Solution (Python):

 
n = int(input())
w=[]
for i in range(n):
    w.append(str(input()))

i=int(0)
z=str(w[0][:1])
x=int(0)
k=int(0)

while i < n:
    a=str(w[i][:1])
    if z != a:
        x=1
    z=str(w[i][-1:])
    k=int(0)
    while k < i:
        if w[i]==w[k]:
            x=1
        k +=1
    if x==1:
        break
    i+=1
    

if x==1:
    print('No')
else:
    print('Yes')

Solution (Python):
def check_word(w,n):
    count = 0
    for i in range(n):
        for j in range(n):
            if i < j:
                if w[i] == w[j]:
                    count += 1
            else:
                continue
    if count == 0:
        return True
    else:
        return False
    
def shiritori(w1,w2):
    if w1[len(w1)-1:len(w1)] == w2[0]:
        return True
    else:
        return False
    
n = int(input())
w = [input() for i in range(n)]
count = 0
if check_word(w,n):
    for i in range(n-1):
        if not shiritori(w[i],w[i+1]):
            print('No')
            break
        else:
            count += 1
else:
    print('No')

if count == (n-1):
    print('Yes')

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

ha=0
for i in range(n-1):
    if W[i][len(W[i])-1]!=W[i+1][0] :
        ha=1
for i in range(n):
    for j in range(i+1,n):
        if W[i]==W[j] :
            ha=1

if ha==0 :
    print("Yes")
else:
    print("No")

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

if len(words) == len(set(words)) and all([words[i][-1] == words[i+1][0] for i in range(len(words) - 1)]):
    print('Yes')
else:
    print('No')

Solution (Python):
N = int(input())
a = []
flg = 1
for i in range(N):
    a.append(input())
for i in range(N-1):
    if(a[i][-1] != a[i+1][0]):
        flg = 0
a.sort()
for i in range(N-1):
    if(a[i] == a[i+1]):
        flg = 0
if(flg == 0):
    print("No")
else:
    print("Yes")

Solution (Python):
def solve():
    n = int(input())
    prev = input()
    already = {prev}
    for _ in range(n - 1):
        word = input()
        if word in already:
            return False
        if prev[-1] != word[0]:
            return False
        already.add(word)
        prev = word
    return True


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

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

judge = len(w) == len(set(w))

for pre, post in zip(w[:-1], w[1:]):
    judge &= pre[-1] == post[0]

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

Solution (Python):
N = int(input())
w = list([input() for i in range(N)])
cnt=0
for i in range(N-1):
	for j in range(i+1,N,1):
		if w[i]==w[j]:
			print('No')
			exit()
	if w[i][len(w[i])-1]==w[i+1][0]:
		cnt +=1
if cnt==N-1:
	print('Yes')
else:
	print('No')

Solution (Python):
def is_unique(seq):
    return len(seq) == len(set(seq))

word_num = int(input())

word_list=[]
for i in range(word_num):
  word_list.append(str(input()))
  if(is_unique(word_list) == False):
      print("No")
      exit()




temp = 0
for item in word_list:
  initial_word = item[0]
  last_word = item[-1]
  if(temp != initial_word and temp != 0):
      print("No")
      exit()
  temp = last_word
  
print("Yes")

Solution (Python):
import collections

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


def is_unique2(seq):
    seen = []
    unique_list = [x for x in seq if x not in seen and not seen.append(x)]
    return len(seq) == len(unique_list)
c=0

if is_unique2(W)==True:
    for i in range(N-1):
        a = W[i]
        b = W[i+1]


        if a[len(a)-1] == b[0]:
            c+=1
    if c == N-1:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Solution (Python):

N = int(input())

strList = [""] * N
strList[0] =input()
ans = "Yes"

for count in range(1,N):
    string = input()
    for s in strList:
        if s == string :
            ans = "No"
            break
        else:
            before = strList[count -1]
            car = before[len(before) -1: len(before)] 
            if car != string[:1]:
                ans = "No"
                break
    if ans == "No":
        break
    strList[count] = string

print(ans)

Solution (Python):




"""








"""
from operator import and_
from functools import reduce
def get_nlines():
    N = int(input())
    return [input() for i in range(N)]


def tsunagari_check(first, second):
    if first[-1] == second[0]:
        return True
    else:
        return False

def judge(data):
    """
    >>> judge(["hoge","english", "hoge"])
    False
    >>> judge(["basic","cpp","python"])
    True
    >>> judge(["agg","abc", "cba"])
    False
    """
    
    if len(set(data)) == len(data):
        pass
    else:
        return False

    
    checked = [tsunagari_check(data[i], data[i+1]) for i in range(len(data)-1)]
    
    return reduce(and_, checked)

if __name__ == '__main__':
    
    
    RES = judge(get_nlines())
    if RES:
        print("Yes")
    else:
        print("No")

Solution (Python):
N = int(input())
ans = "Yes"
arr = []
for i in range(N):
    arr.append(input())
    if not i == 0:
        if arr[i-1][-1] == arr[i][0] and not arr[i] in arr[:-2]:
            pass
        else:
            ans = "No"
            break

print(ans)

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

start=list()
end=list()

for i in range(N):
    W.append(input())
    w=W[i]
    w=list(w)
    
    if i!=0:
        start.append( w[0] )

    if i!=(N-1):
        end.append( w.pop() )
        
    w.clear()

Ws=set(W)

if len(W)!=len(Ws) or start!=end:
    print("No")

else :
    print("Yes")

Solution (Python):


N = int(input())
W = []

for i in range(N):
    W.append(input())

h = []
for i in range(1,N):
    h.append(W[i][0])
t = []
for i in range(N-1):
    t.append(W[i][-1])    

flg = 1
for i in range(N-1):
    if h[i] != t[i]: flg = 0
W.sort()
for i in range(N-1):
    if W[i] == W[i+1]: flg = 0

if flg==1: print("Yes")
else: print("No")

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

def is_unique(seq):
    return len(seq) == len(set(seq))
flag = 'B'
if is_unique(t) == False:
  flag = 'A'

count = 0       
while count < N-1:
  if t[count][-1] != t[count+1][0]:
      flag = 'A'
      count += 1
  else:
    count += 1

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

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

memo = []
flag = 1
for i in range(n):
    w = input()
    start = w[0]
    if i==0: end = w[len(w)-1]; memo.append(w); continue
    if start == end and not w in memo: end = w[len(w)-1]; memo.append(w)
    else: flag = 0; break

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

Solution (Python):
a=int(input())
l=[]
for i in range(a):
    s=input()
    if i!=0:
        if s[0]!=last or l.count(s):
            print('No')
            exit()
    l.append(s)
    last=s[-1]
print('Yes')

Solution (Python):
n = int(input())
index=0
lists =[]
listForWords=[]
flag =0
while index<n:
    word = input()
    list1 = list(word)
    if index!=0:
        length = len(lists[index-1])
        if list1[0] == lists[index-1][length-1]:
            for li in listForWords:
                if word == li:
                    flag =1
        else:
            flag =1
    lists.append(list1)
    listForWords.append(word)
    index+=1

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

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

words=[input() for _ in range(N)]

tmp=set(words)

c=1
if len(words)!=len(tmp):
    c=0
else:
    for i in range(N):

        if i==0:
            continue
        elif words[i][0]!=words[i-1][-1]:
            c=0
            break



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