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):
def main():
    n = int(input())
    W = [input() for _ in range(n)]

    if n != len(set(W)):
        print("No")
        return

    for i in range(n-1):
        if W[i][-1] != W[i+1][0]:
            print('No')
            return
    print('Yes')


if __name__ == '__main__':
    main()

Solution (Python):
from sys import exit

N = int(input())

prev = input()
used = set([prev])
for _ in range(N - 1):
    s = input()
    if s in used or prev[-1] != s[0]:
        print('No')
        exit()
    prev = s
    used.add(s)
print('Yes')

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

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

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

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

Solution (Python):
def q11(W):
    s = W.pop(0)
    deplicate = []
    deplicate.append(s)
    for w in W:
        if not w.startswith(s[-1]):
            return 'No'
    
        if w in deplicate:
            return 'No'
    
        deplicate.append(w)
        s = w
    return 'Yes'

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

print(q11(W))

Solution (Python):
def q11(W):
    s = W.pop(0)
    deplicate.append(s)
    for w in W:
        if not w.startswith(s[-1]):
            return 'No'
    
        if w in deplicate:
            return 'No'
    
        deplicate.append(w)
        s = w
    return 'Yes'

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

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

print(q11(W))

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

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

Solution (Python):
def main():
    N = int(input())
    W = [input() for j in range(N)]

    D = []
    ans = 'Yes'
    for i in range(N - 1):
        if W[i] in D:
            ans = 'No'
            break
        elif W[i][-1] != W[i + 1][0]:
            ans = 'No'
            break
        else:
            D.append(W[i])

    if W[-1] in D:
        ans = 'No'

    print(ans)


main()

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

before = str(input())
use = [str(before)]
check = 0
for i in range(n-1):
    w = str(input()) 
    if w in use or before[-1] != w[0]:
        check = 1
        break
    use.append(w)

    before = w

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

Solution (Python):
n=int(input())
w=list(list(input()) for i in range(n))
f=True
c=0
for i in range(n):
    for j in range(n):
        if w[i]==w[j]:
            c+=1
    if (i!=n-1 and w[i+1][0]!=w[i][-1]) or c>n:
        f=False
if f:
    print("Yes")
else:
    print("No")

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

Solution (Python):
n=int(input())
li=[str(input())]
for i in range(n-1):
    x=str(input())
    y=li[-1]
    if x in li or y[-1]!=x[0]:
        print("No")
        exit()
    else:
        li.append(x)
print("Yes")

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

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

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

Solution (Python):
a=int(input())
c=0
z=[]
y=[]
b=[]
for i in range(a):
    x=str(input())
    z.append(x[0])
    y.append(x[-1])
    if i==0:
        b.append(x)
    if x not in b and z[i]==y[i-1]:
        b.append(x)
        c+=1
if c==a-1:
    print("Yes")
else:
    print("No")

Solution (Python):
def main():
  import collections
  N, *W = open(0).read().split()
  N = int(N)

  if max(collections.Counter(W).values()) != 1:
    print("No")
    exit()
  else:
    for i in range(len(W)-1):
      if W[i][-1] != W[i+1][0]:
        print("No")
        exit()
    print("Yes")
  
if __name__ == "__main__":
    main()

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

X  =[list(W[i]) for i in range(N)]
Y  = set(W)

ans = 0

if len(W) != len(Y):
    print('No')
else:
    for i in range(1,N):
        if X[i-1][-1] == X[i][0] :
            ans += 1
            
    if ans == N-1:  
        print('Yes')
    else:
        print('No')

Solution (Python):
N=int(input())
W=[0]*N
for i in range(N):
    W[i] = input()
cnt = 0
for i in range(N-1):
    moji=len(W[i])
    if W[i][moji-1] == W[i+1][0]:
        cnt +=1
    else:
        print('No')
        break
if cnt == N-1:
    if len(set(W)) == len(W):
        print('Yes')
    else:
        print('No')

Solution (Python):

N = int(input())
words = []
for i in range(N):
    w = input()
    if i == 0:
        words.append(w)
    else:
        if w[0] == l and w not in words:
            words.append(w)
        else:
            print("No")
            exit()
    l = w[-1]
print("Yes")

Solution (Python):

import sys
if sys.platform =='ios':
    sys.stdin=open('input_file.txt')

n = int(input())

l = []

l = [str(input()) for i in range(n)]

ans = 0

for i in range(n):
	if i == n-1:
		pass
	else:
		if l[i][len(l[i])-1] == l[i+1][0]:
			ans = ans + 1

print('Yes' if ans==n-1 and len(l)==len(set(l)) else 'No')

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

for i in range(n-1):
    if (ls_w[i][-1:] != ls_w[i+1][:1]) or (ls_w[i] in ls_w[i+1:]):
        print("No")
        break
    elif i == n - 2:
        print("Yes")

Solution (Python):
N = int(input())
W = [input() for i in range(N)]
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())
wa=[] 
wp="" 
NGflag=False 


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

    if wp!="": 
        if wp[-1]!=w[0] or (w in wa): 
            NGflag=True
            break

    wa.append(w) 
    wp=w 

if NGflag==False: 
    print("Yes")
else: 
    print("No")

Solution (Python):
N=int(input())
W=[input() for i in range(N)]
flag=True
def has_duplicates(seq):
    return len(seq) == len(set(seq))

for i in range(N-1):
    if W[i][-1]!=W[i+1][0]:
        flag=False
if has_duplicates(W) and flag:
    print('Yes')
else:
    print('No')

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

cnt_A=0
cnt_B=0

for i in range(N-1):
    if not list_aaa[i][-1:] ==list_aaa[i+1][:1]:
        cnt_A +=1
    if list_aaa.count(list_aaa[i]) >=2 or list_aaa.count(list_aaa[i]) >=2 :
        cnt_B +=1


if cnt_A >=1 or cnt_B>=1:
    print("No")
else:
    print("Yes")

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

for i in range(N-1):
    if W[i][-1] != W[i+1][0] or W[i+1] in ary:
        print('No')
        exit()
    ary.append(W[i])
print('Yes')

Solution (Python):
A=int(input())
B = [input() for _ in range(A)]
count = 0
if len(set(B)) != len(B):
  print('No')
else:
  for b in B:
    if count == 0:
      k = b[-1]
      count += 1
    else:
      if k == b[0]:
        k = b[-1]
      else:
        print('No')
        exit()
  print('Yes')

Solution (Python):
N = int(input())
now = list(input())
already = [now]
Flag = False
for _ in range(N - 1):
    next_word = list(input())
    if next_word in already or now[-1] != next_word[0]:
        Flag = True
    already.append(next_word)
    now = next_word

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

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

ans = 'Yes'
tmp = ws.pop(0)
a = [tmp]

for w in ws:
    if w in a:
        ans = 'No'
        break
        
    if tmp[len(tmp)-1] != w[0]:
        ans = 'No'
        break
        
    a.append(w)
    tmp = w
        
print(ans)

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


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

Solution (Python):
N = int(input())
W = [input() for _ in range(N)]
V = set()
prev = -1
for S in W:
    if S in V:
        print('No')
        exit()
    V.add(S)
    if prev == -1 or S[0] == prev:
        prev = S[-1]
    else:
        print('No')
        exit()
print('Yes')

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

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

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

end = None
for w in w_list:
  if end == None:
    end = w[-1]
    continue
  if w_list.count(w) > 1:
    print('No')
    break
  if w[0] != end:
    print('No')
    break
  end = w[-1]
else:
  print('Yes')

Solution (Python):
N = int(input())
w = [input()]
flg = 0
pre = list(w[0])[-1]
for i in range(N-1):
    s = input()
    if s in w or pre != list(s)[0]:
        flg = 1
    pre = list(s)[-1]
    w.append(s)
if flg:
    print('No')
else:
    print('Yes')

Solution (Python):
import sys

N = int(input())
word = list()
for i in range(N):
	word.append(input())

word_set = set(word)
if len(word) != len(word_set): 
	print('No')
	sys.exit()

for i in range(N):
	alphabet = list(word[i])
	if i != 0 and last != alphabet[0]:
		print('No')
		sys.exit()	
	last = alphabet[-1]
print('Yes')

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

words = set()

for n in range(N):
  w = input()
  if n > 0 and (w[0] != pre or w in words):
    print('No')
    exit()
  else:
    words.add(w)
    pre = w[-1]

print('Yes')

Solution (Python):
n = int(input())
check = {}
word = input()
check[word] = 1
last = word[-1]

for i in range(n-1):
    word = input()
    if word in check:
        print('No')
        exit()

    check[word] = 1
    if word[0] == last:
        last = word[-1]
    else:
        print('No')
        exit()

print('Yes')

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

word_L = []
for val in range(n):
    new_word = input()
    word_L.append(new_word)

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

for val in range(1,n):

    if word_L[val-1][-1] != word_L[val][0]:
        print("No")
        exit()
    

print("Yes")

Solution (Python):
N=int(input())
Ws=[]
W1=input()
Ws.append(W1)
kotae="Yes"
for i in range(1, N):
    W=input()
    if W not in Ws and W[0]==W1[-1]:
        Ws.append(W)
        W1=W
    else:
        kotae="No"
print(kotae)

Solution (Python):
N = int(input())
words = set()
for n in range(N):
  w = input()
  if n > 0 and (w[0] != prev or w in words):
    print('No')
    exit()
  else:
    words.add(w)
    prev = w[-1]

print('Yes')

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

def is_shiritori():
  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'

print(is_shiritori())

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

Solution (Python):
N=int(input())
W=[]
ans ='Yes'

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

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

if len(set(W)) != N:
    ans = 'No'

print(ans)

Solution (Python):

import sys

YES = "Yes"  
NO = "No"  


def solve(N: int, W: "List[str]"):
    ans = YES
    for i in range(N-1):
        if W[i][-1] != W[i+1][0]:
            ans = NO
            break
    for i in range(N):
        if W[i] in W[:i]:
            ans = NO
            break
    print(ans)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    W = [next(tokens) for _ in range(N)]  
    solve(N, W)

if __name__ == '__main__':
    main()

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


wl = []
end = ""
for _ in range(n):
    w = input()
    wl.append(w)
    if end == "" or w[0] == end:
        end = w[-1]
    else:
        print("No")
        sys.exit()
    
if len(wl) != len(set(wl)):
    print("No")
    sys.exit()

print("Yes")

Solution (Python):
N = int(input())
W = [input() for _ in range(N)]
l = [W[0]]
for i in range(N - 1):
  if W[i][-1] == W[i + 1][0] and not W[i + 1] in l:
    l.append(W[i + 1])
  else:
    break
print("Yes" if len(l) == N else "No")

Solution (Python):
def main(n: int, w: list) -> None:
    if len(set(w)) != n:
        print("No")
        return

    last_letter = ""

    for w_n in w:
        if last_letter == "":
            last_letter = w_n[-1]
            continue

        if last_letter != w_n[0]:
            print("No")
            return

        last_letter = w_n[-1]

    print("Yes")


if __name__ == "__main__":
    n = int(input())
    w = [input() for _ in range(n)]

    main(n, w)

Solution (Python):
n = int(input())
w1 = input()
used = [w1]

for _ in range(n-1):
    w2 = input()
    if w2 in used:
        print("No")
        quit()
    if w1[-1] != w2[0]:
        print("No")
        quit()
    used.append(w2)
    w1 = w2
print("Yes")

Solution (Python):
N = int(input())
A=[]
hantei = True
for i in range(N):
  A+=[str(input())]
L=[A[0]]
for i in range(1,N):
  if A[i] in L:
    hantei = False
    break
  if A[i-1][-1]!=A[i][0]:
    hantei= False
    break
  L +=[A[i]]
print('Yes' if hantei else'No')

Solution (Python):
n = int(input())
s = ['']*n
ans='Yes'

for i in range(n):
    instr = str(input())
    if i!=0:
        if s[i-1][len(s[i-1])-1]!=instr[0]:
            ans = 'No'
        if instr in s:
            ans = 'No'
    s[i]=instr
print(ans)

Solution (Python):

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

is_satisfied = 'Yes'

if len(w) != len(set(w)):
    is_satisfied = 'No'
else:
    for i in range(1, len(w)):
        if w[i][0] != w[i - 1][-1]:
            is_satisfied = 'No'
            break

print(is_satisfied)

Solution (Python):
N = int(input())
used = set()
for i in range(N):
    s = input()
    if (i!=0 and s[0]!=p[-1]) or s in used:
        print("No")
        exit()
    used.add(s)
    p = s
print("Yes")

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

Solution (Python):
N = int(input())
words = []
s = input()
words.append(s)
ans = True
for i in range(N-1):
    t = input()
    if(t[0] == s[-1] and (t in words) == False):
        words.append(t)
        s = t
    else:
        ans = False
if(ans):
    print("Yes")
else:
    print("No")

Solution (Python):
n=int(input())
w=[input() for i in range(n)]
last=""
wl=[]
ans="Yes"
for x,i in enumerate(w):
    if x==0:
        last=i[-1]
        wl.append(i)
        continue
    if i in wl:
        ans="No"
    if i[0]!=last:
        ans="No"
    last=i[-1]
    wl.append(i)
print(ans)

Solution (Python):
N = int(input())
W = []
dic = dict()
yes = 1

for _ in range(N):
	char = str(input())
	W.append(char)
	if not char in dic:
		dic[char] = 1
	else:
		yes = 0

tale = W[0][0]
		
for i in range(N):
	if tale != W[i][0]:
		yes = 0
		break
	else:
		tale = W[i][-1]
		
if yes:
	print("Yes")
else:
	print("No")

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

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

for i in range(N):
  if W.count(W[i]) != 1:
    f = 0
    break
    
if f == 1:
  print('Yes')
else:
  print('No')

Solution (Python):


import sys










def main():
    n, *w = sys.stdin.read().split()
    n = int(n)
    for i in range(1, n):
        if w[i][0] == w[i-1][-1] and not w[i] in w[:i]:
            continue
        else:
            print('No')
            exit()
    
    print('Yes')


if __name__ == "__main__":
    
    main()

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

words = [input() for _ in range(N)]
prev = words[0]
se = set([words[0]])

bl = True
for w in words[1:]:
    if w in se:
        bl = False
    if prev[-1] != w[0]:
        bl = False
    se.add(w)
    prev = w

answer = 'Yes' if bl else 'No'
print(answer)

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

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

spoken = {words[0]}

for x, y in zip(words, words[1:]):
    if y[0] != x[-1]:
        print("No")
        exit()
    if y in spoken:
        print("No")
        exit()
    spoken.add(y)
else:
    print("Yes")

Solution (Python):
import sys

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

t = len(list(set(word)))

if n != t:
    print("No")
else:
    for i in range(n-1):
        if word[i][-1] == word[i+1][0]:
            continue
        else:
            print("No")
            sys.exit()
    else:
        print("Yes")

Solution (Python):
from sys import stdin
import fractions

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

li = [stdin.readline().rstrip() for _ in range(n)]
k = len(li)
lin = list(set(li))

if len(lin) != k:
    print("No")
    exit()

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

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

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

count = 0

for n in range(1,N):
    if W[n-1][-1] != W[n][0] or W[n] in W[:n]:
        break
    else:
        count += 1

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

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

Solution (Python):
N = int(input())
words = []
ans = True
for i in range(N):

    word = input()
    if i >= 1:
        if words[-1][-1] != word[0]:
            ans = False
        if word in words:
            ans = False
    words.append(word)
print("Yes" if ans else "No")

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

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

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

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

prev = W[0]
for w in W[1:]:
    if prev[-1] != w[0]:
        print('No')
        exit(0)
    prev = w
print('Yes')

Solution (Python):
n = int(input())
list = []
list.append(input())
c = 0

for i in range(n - 1):
    old = list[-1]
    new = input()
    if old[-1] != new[0]:
        c += 1
    for j in list:
        if j == new:
            c += 1
    list.append(new)

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

Solution (Python):
import sys
n=int(input())
string_list=[input() for i in range(n)]
for i in range(n):
	for k in range(n):
		if i!=k:
			if string_list[i]==string_list[k]:
				print('No')
				sys.exit()

for i in range(n-1):
	if string_list[i][-1]!=string_list[i+1][0]:
		print('No')
		sys.exit()

print('Yes')

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

flag = len(W) == len(list(set(W)))

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

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

Solution (Python):
noOfWords= int(input())
words = []
satisfactor = True
for i in range(noOfWords):
    word = input()
    words.append(word)

if len(set(words)) < len(words):
    print("No")    
    satisfactor = False 
else:
    for i in range(len(words)-1):
        if words[i][len(words[i])-1] ==  words[i+1][0]:
            continue
        else:
            satisfactor = False
            print("No")
            break
if satisfactor :
    print("Yes")

Solution (Python):
n = int(input())
W = [ input() for _ in range(n) ]
if sorted(W) != sorted(list(set(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):
  w.append(input())

flag = 0
ss = set(w)
if(len(ss) != N):
  flag = 1
for i in range(N-1):
  if(w[i][-1] != w[i+1][0]):
    flag = 1
    break

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

Solution (Python):
n = int(input())
W = [ input() for _ in range(n) ]
if sorted(W) != sorted(list(set(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 = [input() for _ in range(n)]
ans = 'Yes'
if len(list(set(w))) != n:
    ans = 'No'
for i in range(1, n):
    if w[i - 1][-1] != w[i][0]:
        ans = 'No'
print(ans)

Solution (Python):
def taka():
    n = int(input())
    listofwords =[]
    for i in range(n):
        strTEMP = input()

        if i == 0:
            listofwords.append(strTEMP)
            continue
        else:
            if strTEMP in listofwords:
                return "No"
            else:
                cmp = listofwords[-1]
                if strTEMP[0] != cmp[-1]:
                    return "No"
                else:
                    listofwords.append(strTEMP)
    return "Yes"

print(taka())

Solution (Python):
def game():
    n = int(input())
    listofwords =[]
    for i in range(n):
        strTEMP = input()

        if i == 0:
            listofwords.append(strTEMP)
            continue
        else:
            if strTEMP in listofwords:
                return "No"
            else:
                cmp = listofwords[-1]
                if strTEMP[0] != cmp[-1]:
                    return "No"
                else:
                    listofwords.append(strTEMP)
    return "Yes"

print(game())

Solution (Python):
n = int(input())
prev = None
s = set()
flag = True
for i in range(n):
    w = input()
    if prev is None:
        prev = w[0]
    if w in s or w[0] != prev:
        flag = False
    s.add(w)
    prev = w[-1]
if flag:
    print("Yes")
else:
    print("No")

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

for i in range(n-1):
    if W[i][-1] != W[i+1][0] or W.count(W[i]) > 1:
        print('No')
        exit()

print('Yes')

Solution (Python):
N = int(input())
s = [input() for _ in range(N)]
last = s[0][-1]

for i in range(1, N):
    if s[i][0] != last:
        print("No")
        break
    last = s[i][-1]
    if s.count(s[i]) > 1:
        print("No")
        break
else:
    print("Yes")

Solution (Python):


n = int(input())
w = ["" for i in range(n)]

for i in range(n):
    w[i] = input()


hasNoDuplicate = True
if len(set(w)) == len(w):
    pass
else:
    hasNoDuplicate = False


isShiritori = True
for i in range(n):
    if i == 0:
        last = list(w[i])[-1]
    else:
        
        if last == list(w[i])[0]:
            pass
            
            last = list(w[i])[-1]
        else:
            isShiritori = False
            break

if (isShiritori) and (hasNoDuplicate):
    print("Yes")
else:
    print("No")

Solution (Python):
N = int(input())
words = [input() for i in range(N)]
preword =words[0]
se = set([words[0]])
hantei = True
for w in words[1:]:
  if w in se:
    hantei = False
  if preword[-1] != w[0]:
    hantei = False
  se.add(w)
  preword = w
print('Yes' if hantei else 'No')

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

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

def main():
    N = int(input())
    W = [input().rstrip() for _ in range(N)]
    if len(W) != len(set(W)):
        print('No')
        exit()
    for i in range(len(W)-1):
        if W[i][-1] != W[i+1][0]:
            print('No')
            exit()

    print("Yes")

if __name__ == '__main__':
    main()

Solution (Python):
import sys
import collections


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    n = int(input().rstrip('\n'))
    s = [str(input().rstrip('\n')) for _ in range(n)]
    d = collections.defaultdict(int)
    d[s[0]]
    b = True
    for i in range(1, n):
        if s[i] not in d:
            d[s[i]]
            if s[i][0] != s[i-1][-1]:
                b = False
                break
        else:
            b = False
            break
    print("Yes" if b else "No")


if __name__ == '__main__':
    solve()

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

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

now = W[0][-1]
flag = True
for i in range(1, N):
    if now == W[i][0]:
        now = W[i][-1]
    else:
        flag = False
        break

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

Solution (Python):
n = int(input())
words = []
flag = True
for i in range(n):
    words.append(input())
for i in range(1,n):
    if words[i][0] != words[i-1][-1]:
        flag = False
        break
if len(set(words)) != n:
    flag = False
print('Yes' if flag else 'No')

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

W = [input() for w in range(N)]

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

Solution (Python):
import sys
def input():
    return sys.stdin.readline()[:-1]
n=int(input())
w=[input() for i in range(n)]
li=[]
for i in range(n):
    if w[i] in li:
        print("No")
        quit()
    elif i>0 and w[i][0]!=w[i-1][-1]:
        print("No")
        quit()
    else:
        li.append(w[i])
print("Yes")

Solution (Python):
N = int(input())
W = [input() for i in range(N)]
ans = "Yes"
if sorted(set(W)) != sorted(W):
    ans = "No"
else:
    for i in range(N-1):
        if W[i][-1] != W[i+1][0]:
            ans = "No"
            break
print(ans)

Solution (Python):
def has_duplicates(words):
  if len(words) == len(set(words)):
    return False
  return True

a = int(input())
words = []
for i in range(a):
  words.append(input())
if has_duplicates(words) == True:
  print('No')
  exit()
for i in range(a-1):
  if words[i][len(words[i])-1] != words[i+1][0]:
    print('No')
    exit()
print('Yes')

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

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

a=[input() for i in range(n)]

ans=True
if all(a.count(w) <2  for w in a):
    for i in range(n-1):
        if a[i][-1]!=a[i+1][0]:
            ans=False
else:
    ans=False
    
if ans:    
    print('Yes')
else:
    print('No')

Solution (Python):


N = int(input().split()[0])
w_list = []
is_ok = True
for i in range(N):
    w = input()

    if w in w_list:
        is_ok = False
        break

    w_list.append(w)
    if i == 0:
        tail = w[-1]
        continue

    if w[0] != tail:
        is_ok = False
        break
    tail = w[-1]


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

Solution (Python):
n = int(input())
s = []
for i in range(n):
  s.append(input())
  
ans = "Yes"

for i in range(n-1):
  if s[i] in s[i+1:n]:
    ans = "No"
  elif s[i][len(s[i])-1] != s[i+1][0]:
    ans = "No"
    
print(ans)

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

print("Yes")

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

    for word in words:
        count = 0
        for w in words:
            if w == word:
                count += 1
        if count > 1:
            print('No')
            exit()
    
    for i in range(n):
        if i + 1 <= n - 1:
            x = words[i+1][0]
            y = words[i][-1]
            if x == y:
                continue
            else:
                print('No')
                exit()
    
    print('Yes')


if __name__ == '__main__':
    shiritori()

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

W = []
for i in range(N):
    if i == 0:
        x = input()
        W.append(x)
    else:
        x = input()
        if x in W:
            print("No")
            exit()
        elif W[i-1][-1] != x[0]:
            print("No")
            exit()
        else:
            W.append(x)

print("Yes")

Solution (Python):
n = int(input())
shiritori = []
ans = 1
for i in range(n):
    if i == 0:
        shiritori.append(input())
    else:
        shiritori.append(input())
        if shiritori.count(shiritori[i]) >= 2 or shiritori[i-1][-1] != shiritori[i][0]:
            ans = 0
if ans == 1: print("Yes")
else: print("No")