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):
a = int(input())
b = []
for i in range(0, a):
    b.append(input())
    if i != 0:
        if (b[i])[0] != (b[i-1])[-1]:
            print("No")
            exit()
        for j in range(len(b)-1):
            if b[j] == b[i]:
                print("No")
                exit()
print("Yes")

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



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

for i in range(1,len(ls)):
  if ls[i][0] != ls[i-1][-1]:
    print("No")
    quit()
  if ls.count(ls[i]) >= 2:
    print("No")
    quit()
    
print("Yes")

Solution (Python):
N = int(input())
words = []
l = []
for i in range(N):
    a = input()
    if i == 0:
        l.append(a)
        b = list(a)
        words.append(b[len(b)-1])
    elif i > 0:
        b = list(a)
        if i == N-1:
            words.append(b[0])
        else:
            words.append(b[0])
            words.append(b[len(b)-1])
        l.append(a)

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

for h in range(0,len(words),2):
    if words[h] != words[h+1]:
        print("No")
        exit()
print("Yes")

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

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

done = []

for i in range(n):
    if i == 0:
         before = str(w[i])
         done.append(w[i])
    else:
        target = str(w[i])
        if before[-1] != target[0]:
            print("No")
            exit()
        else:
            if w[i] in done:
                print("No")
                exit()
        before = target
        done.append(w[i])
print("Yes")

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

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

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

siritori(n, words)

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

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

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

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

Solution (Python):
N = int(input())
s=[input() for i in range(N)]
c=[]
for i in range(N-1):
    c.append([0,1][s[i][-1]==s[i+1][0]])
print(["No","Yes"][len(set(s))==len(s)and not(0 in c)])

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

from collections import Counter

dic = Counter(W)
flg = 0
for i in range(N):
    if dic[W[i]]!=1:
        flg=1
        

for j in range(N-1):
    if W[j][-1]!=W[j+1][0]:
        flg = 1

if flg!=1:
    print('Yes')
else:
    print('No')

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

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

Solution (Python):
n = int(input())
cnt = 1
w = [input() for i in range(n)]
if len(set(w)) != len(w):
    cnt *= 0
else:
    for j in range(len(w)-1):
        if w[j][len(w[j])-1] != w[j+1][0]:
            cnt *= 0

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

Solution (Python):
import sys
n=int(input())
w=[input() for i in range(n)]
w_set = set()
for i in range(n):
    w_set.add(w[i])

if len(w)!=len(w_set):
    print("No")
    sys.exit()

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 _ in range(N)]
tf = True
for i in range(N - 1):
    if W[i][-1] != W[i+1][0]:
        tf = False
print("Yes") if tf and len(set(W))==N else print("No")

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

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

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

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

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

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

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

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

Solution (Python):
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

N = n()
seen = set()
W = s()
seen.add(W)
prev_c = W[-1]
for i in range(N-1):
    W = s()
    if W in seen or W[0] != prev_c:
        print('No')
        import sys
        sys.exit()
    seen.add(W)
    prev_c = W[-1]
print('Yes')

Solution (Python):
N = int(input())
last = ""
a = set()
for i in range(N):
    if i == 0:
        last = input()
        a.add(last)
        continue
    tmp = input()
    if tmp[0] != last[-1] or tmp in a:
        print("No")
        exit(0)
    a.add(tmp)
    last = tmp
print("Yes")

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

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

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

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

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

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

l = []
for i in range(n):
    l.append(input())

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

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

print("Yes")

Solution (Python):
N=int(input())
w=[None]*N
a=1
for i in range(N):
    w[i]=input()
for i in range(1,N):
    if w[i-1][-1]==w[i][0]:
        for j in range(0,i-1):
            if w[j]==w[i]:
                a=0
                break
    else:
        a=0
    if a==0:
        break
if a==1:
    print("Yes")
else:
    print("No")

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

pre = ''
for i,w in enumerate(W_list):
    if W_list.count(w) > 1:
        print('No')
        exit(0)
    if i == 0:
        pre = w[-1:]
        
        continue
    if pre != w[0:1]:
        print('No')
        exit(0)
    pre = w[-1:]
    
    

print('Yes')

Solution (Python):
N=int(input())
L=[]
for i in range(N):
  L.append(input())
if not len(set(L))==len(L):
  print("No")
else:
  for n in range(N):
    if n==(N-1):
      print("Yes")
    elif L[n][-1] == L[n+1][0]:
      continue
    else:
      print("No")
      break

Solution (Python):
def abc():
    n = int(input())
    words = []
    for i in range(n):
        words.append(input().rstrip())
    if len(words) != len(set(words)):
        print('No')
        return
    for i in range(n-1):
        if words[i][-1] != words[i+1][0]:
            print('No')
            return
    print('Yes')


abc()

Solution (Python):

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


answer = "Yes"
already_taken = []
for idx in range(len(words)):
  
  if (idx == 0):
    already_taken.append(words[idx])
    continue

  if (words[idx] in already_taken):
    answer = "No"
    break
  if (words[idx][0] != already_taken[-1][len(already_taken[-1])-1]):
    answer = "No"
    break
  already_taken.append(words[idx])


print(answer)

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

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


for i in range(1, n):
    if lst[i-1][-1] == lst[i][0]:
        pass
    else:
        print("No")
        exit()

print("Yes")

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

judge0 = 1
judge1 = 1

if len(set(W)) < len(W):
    judge0 = 0
    
W = list(map(list, W))
    
for n in range(N-1):
    if W[n][-1] != W[n+1][0]:
        judge1 = 0
        break

if judge0 == 1 and judge1 == 1:
    print('Yes')
else:
    print('No')

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())

s = set()
last = ""
ans = "Yes"

for i in range(N):

    w = input()

    if i == 0:
        last = w
        s.add(w)

    elif (w[0] == last[-1]) and (w not in s):

        last = w
        s.add(w)

    else:
        ans = "No"
        break

print (ans)

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

W = [None] * N

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

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

last = W[0][-1]

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

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

Solution (Python):
n = int(input())
word = [input() for i in range(n)]
used = set()
end = word[0][0]


for w in word:
    if w in used or end != w[0]:
        print("No")
        exit()
    else:
        used.add(w)
        end = w[-1]
print("Yes")

Solution (Python):
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")

N = int(sys.stdin.readline())
W = [sys.stdin.readline().rstrip() for _ in range(N)]
i = 0
ok = True
while i < N - 1:
    j = i + 1
    ok &= W[i][-1] == W[j][0]
    i+=1
if ok and len(set(W)) == N:
    print('Yes')
else:
    print('No')

Solution (Python):
n=int(input())
shiritori=[]
for i in range(n):
  shiritori.append(input())
check=set(shiritori)
if len(check)!=n:
  print("No")
else:
  flag=0
  for i in range(n-1):
    if shiritori[i][-1]!=shiritori[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)]

solver = [W[0]]
for i in range(1,N):
  if W[i] not in solver and W[i][0] == solver[-1][-1]:
    solver.append(W[i])
  else:
    print('No')
    exit()
else:
  print('Yes')

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

tmp = []
tmp.append(W[0])
for i in range(N-1):
    if W[i][-1] == W[i+1][0] and W[i+1] not in tmp:
        tmp.append(W[i+1])
        if i == N-2:
            print('Yes')
    else:
        print('No')
        break

Solution (Python):



N = int(input())
word = [input() for i in range(N)]




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

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

Solution (Python):
words = []
N = int(input())
flag = True

words.append(input())

for _ in range(N-1):
    w = input()
    if w not in words and words[-1][-1] == w[0]:
        words.append(w)
    else:
        flag = False
        break

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

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

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



def solve(n,ls):
    if n == 0:
        return "Yes"
    else:
        if ls[n-1][-1] == ls[n][0]:
            return solve(n-1,ls)
        else:
            return "No"


flg = solve(n-1,w)
if flg == "No":
    pass
else:
    if not len(w) == len(list(set(w))):
        flg ="No"

print(flg)

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

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

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


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


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

print("Yes")

Solution (Python):

s = int(input())
last = str(input())
wordlist = [last]
ans = "Yes"

for i in range(s-1):
    word = str(input())

    if last[-1] != word[0]:
        ans = "No"
        break
    
    elif word in wordlist:
        ans = "No"
        break

    last = word
    wordlist.append(word)

print(ans)

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

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

if len(list_w) != len(set(list_w)):
    print("No")

else:
    for i in range(1, n):
        if list_w[i - 1][-1] == list_w[i][0]:
            list_ok.append(list_w[i])
            i += 1
    if len(list_ok) == len(list_w):
        print("Yes")
    else:
        print("No")

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

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

print("Yes")

Solution (Python):
N=int(input())
d={}
flag=True
before=None
for z in range(N):
  s=input()
  if before==None:
    before=s[-1]
  else:
    if before==s[0]:
      before=s[-1]
    else:
      flag=False
  if not(s in d):
    d[s]=True
  else:
    flag=False

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

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

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

Solution (Python):


N = int(input())
list = [input() for i in range(N)]
def has_duplicates(seq):
    return len(seq) != len(set(seq))    
if has_duplicates(list):
    print("No")
else:
    i = 1
    while i < N:
        if list[i-1][-1] != list[i][0]:
            print("No")
            break
        else:
            i += 1
    else:
        print("Yes")

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

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

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

        for j in range(i-1):
            if w[i] == w[j]:
                print('No')
                exit()

print('Yes')

Solution (Python):
n = int(input())
wList = [input()]
flag = True
for _ in range(1, n) :
        w = input()
        if w in wList or w[0] != wList[-1][-1] :
                flag = False
        wList.append(w)
if flag :
        print('Yes')
else:
        print('No')

Solution (Python):
N = int(input())
W = [input()]
flag = True
for _ in range(1, N):
    w = input()
    if w in W or w[0] != W[-1][-1]:
        flag = False
    W.append(w)
if flag:
    print('Yes')
else:
    print('No')

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

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

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

Solution (Python):

n=int(input())

l=[]
for i in range(n):
  l.append(input())


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

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


print('Yes')

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

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

print(res)

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

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

for i  in w:
    if w.count(i) > 1:
        answer = 'No'
        break

if answer == 'No':
    print(answer)
else:
    for i in range(N-1):
        if w[i][-1] != w[i+1][0]:
            answer = 'No'
            break
    print(answer)

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

Solution (Python):
import collections

number = int(input())
word = [input() for i in range(number)]

for i in range(number-1):
    if word[i][-1] == word[i+1][0]:
        continue
    else:
        print("No")
        exit()

word = collections.Counter(word)

if word.most_common()[0][1] != 1:
    print("No")
else:
    print("Yes")

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

Solution (Python):
N = int(input())
W = []
for i in range(N):
    W.append(input())
letter = W[0][0]
for s in W:
    if W.count(s) > 1 or s[0] != letter:
        print("No")
        break
    letter = s[-1]
else:
    print("Yes")

Solution (Python):
n=int(input())
f=0
l=[]
a=list(input())
l.append(a)
for i in range(n-1):
    b=list(input())
    if b in l:
        f+=1
    l.append(b)
    if a[len(a)-1]!=b[0]:
        f+=1
    a=b
    
if f>0:
    print('No')
else:
    print('Yes')

Solution (Python):
def f(W):
    if len(W) != len(set(W)):
        return False
    for i in range(len(W) - 1):
        if W[i][-1] != W[i + 1][0]:
            return False
    return True


N = int(input())
W = [input() for _ in range(N)]
print('Yes' if f(W) else 'No')

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

Solution (Python):
n = int(input())
l = []
i = 1
while i <= n:
  if i == 1:
    s = input()
    l.append(s)
    i += 1
  else:
    s = input()
    if s in l or s[0] != l[-1][-1]:
      print('No')
      quit()
    else:
      l.append(s)
      i += 1
print('Yes')

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

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):
n = int(input())
dic = [input() for _ in range(n)]
ans = "Yes"
for i in range(1,n):
    if dic[i] in dic[:i] or dic[i][0] != dic[i-1][-1]:
        ans = "No"
        break
print(ans)

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

Solution (Python):
N = int(input())
S = []
S.append(input())
ans = 'Yes'

for i in range(N - 1):
	s = input()
	S.append(s)

	
	if S.count(s) != 1:
		ans = 'No'
		break

	
	if S[i][-1] != S[i + 1][0]:
		ans = 'No'
		break

print(ans)

Solution (Python):
N = int(input())
S = []
S.append(input())
ans = 'Yes'

for i in range(N - 1):
	s = input()
	S.append(s)

	
	if S.count(s) != 1:
		ans = 'No'
		break

	
	S1 = S[i]
	S2 = S[i + 1]
	if S1[-1] != S2[0]:
		ans = 'No'
		break

print(ans)

Solution (Python):
N = int(input())
W = [[] for _ in range(N)]
seen = []
for i in range(N):
    W[i] = input()
judge = 0
for tango in W:
    if tango not in seen:
        seen.append(tango)
    else:
        judge = 1
for i in range(N-1):
    if W[i][-1] != W[i+1][0]:
        judge = 1
if judge == 0:
    print('Yes')
else:
    print('No')

Solution (Python):

N = int(input())

lst_W = []
for i in range(N):
    lst_W.extend(input().split())

ans = "Yes"

for i in range(N - 1):
    if (lst_W[i])[-1:] != (lst_W[i+1])[:1]:
        ans = "No"
        break

if len(lst_W) != len(set(lst_W)):
    ans = "No"

print(ans)

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

used = set()
flag = True
old_w = words[0]
used.add(old_w)
for word in words[1:] :
	if word in used :
		flag = False
		break
	else :
		used.add(word)
	
	if old_w[-1] != word[0] :
		flag = False
		break
	old_w = word
print("Yes" if flag else "No")

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

dic = True

for i in range(N-1):
    ss = input()
    if ss in S:
        dic = False
        break
    elif S[i][-1] != ss[0]:
        dic = False
        break
    else:
        S.append(ss)

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

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

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

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

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

print(ans)

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

Solution (Python):
n = int(input())
s = [str(input()) for i in range(n)]
t = [s[0]]
alpha = s[0][-1]
a = True
for i in range(n-1):
    if s[i+1] not in t and alpha == s[i+1][0]:
        t.append(s[i+1])
        alpha = s[i+1][-1]
    else:
        a = False
        break
 
if a:
    print("Yes")
else:
    print("No")

Solution (Python):
n = int(input())
s = [str(input()) for i in range(n)]
t = [s[0]]
alpha = s[0][-1]
a = True
for i in range(n-1):
    if s[i+1] not in t and alpha == s[i+1][0]:
        t.append(s[i+1])
        alpha = s[i+1][-1]
    else:
        a = False
        break

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

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

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

def solve(words):
  s = {words[0]}
  for p, w in zip(words, words[1:]):
    if p[-1] != w[0]:
      return "No"
    if w in s:
      return "No"
    s.add(w)
  return "Yes"

print(solve(words))

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

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

if len(list(set(word_list))) == n and ng == 0:
  print("Yes")
else:
  print("No")

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

if len(s)!=n:
  print("No")
else:
  for j in range(n-1):
    if w[j][-1]!=w[j+1][0]:
      print("No")
      break
  else:
    print("Yes")

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

li = []
flag = True

for i in range(n):
  word = input()
  li.append(word)
  if i != 0:
    if li[i-1][-1] != li[i][0]:
      flag = False

for i in li:
  if li.count(i) >= 2:
    flag = False

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

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

answered = set([words[0]])
ans = "Yes"

for i in range(1, n):
    if words[i] in answered:
        ans = "No"
        break

    if words[i][0] != words[i-1][-1]:
        ans = "No"
        break

    answered.update([words[i]])

print(ans)

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

Solution (Python):
N = int(input())
first = input()
told = set((first,)) 
win = True
for _ in range(N-1):
    second = input()
    if (not second in told) and (first[-1] == second[0]):
        told.add(second)
        first = second
    else:
        win = False
print('Yes' if win else 'No')

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

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

print("Yes")

Solution (Python):
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n = f()[0]
    w = [ input() for i in range(n)]

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

    

solve()

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

list = []

for _ in range(N):
  list.append(input())

if len(set(list)) != len(list):
  print('No')
  exit()
  
w_old = list[0]

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

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

Solution (Python):
N = int(raw_input())
word = [raw_input()]
for i in range(1, N):
	newword = raw_input()
	if newword in word or newword[0] != word[-1][-1]:
		print 'No'
		break
	if i == N-1: print 'Yes'
	else: word.append(newword)

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]:
    print("No")
    exit()
else:
  if len(W) != len(list(set(W))):
    print("No")
    exit()
  else:
    print("Yes")

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

N = int(input())
L = [input().strip() for _ in range(N)]

target = list(L[0])
s = set()
s.add(L[0])

for i in range(1, N):
    v = L[i]
    if v not in s:
        s.add(v)
        
        vv = list(v)
        if target[-1] != vv[0]:
            print("No")
            exit()
        else:
            target = vv
    else:
        print("No")
        exit()
        
print("Yes")

Solution (Python):
N=int(input())
W=[]
for i in range(N):
    w=input()
    W.append(w)
last=W[0][-1]
S=set()
S.add(W[0])
for i in range(1,N):
    if W[i][0]==last and not W[i] in S:
        pass
    else:
        print("No")
        exit()
    S.add(W[i])
    last=W[i][-1]
print("Yes")