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

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

isShiritori = 'Yes'

for i in range(len(w) - 1):
    if w.count(w[i]) > 1 or w[i][-1] != w[i + 1][0]:
        isShiritori = 'No'
        break

print(isShiritori)

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

flag = True
mem = [x[0]]
for i in range(1, n):
  if x[i-1][-1] != x[i][0] or x[i] in mem:
    flag = False
    break
    
  mem.append(x[i])
      
print("Yes" if flag else "No")

Solution (Python):
def main():
    N = int(input())
    words = list()
    rule = True
    for _ in range(N):
        word = input()
        if len(words) > 0:
            if words[-1][-1] != word[0]:
                rule = False
        if word not in words:
            words.append(word)
        else:
            rule = False
    if rule == True:
        print("Yes")
    else:
        print("No")
main()

Solution (Python):

import io

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

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

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

S = set([W[0]])

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

print(ans)

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

Solution (Python):
N = int(input())
S = set()
prev = None
flag = 1
for _ in range(N):
    W = input()
    if W in S or (prev is not None and prev[-1] != W[0]):
        flag = 0
    prev = W
    S.add(W)
if flag:
    print("Yes")
else:
    print("No")

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

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

ok = 1
tmp_list = []
for i in range(n):
    w = str(input())

    if i == 0:
        tmp = w
        tmp_list.append(w)
        continue

    else:
        if w[0] != tmp[-1] or w in tmp_list:
            ok = 0

        else:
            tmp_list.append(w)
            tmp = w

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

Solution (Python):
N = int(input())
S = set()
prev = None
flag = 1
for _ in range(N):
    W = input()
    if W in S or (prev is not None and prev[-1] != W[0]):
        flag = 0
    prev = W
    S.add(W)
if flag:
    print("Yes")
else:
    print("No")

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

Solution (Python):
def myAnswer(N:int,W:list) -> str:
   lis =[W[0]]
   pre = W.pop(0)[-1]
   for word in W:
      if(pre == word[0] and (word in lis)==False):
         lis.append(word)
         pre = word[-1]
      else:
         return "No"
   return "Yes"

def modelAnswer():
   tmp=1
def main():
   N = int(input())
   W=[]
   for _ in range(N):
      W.append(input())
   print(myAnswer(N,W[:]))

if __name__ == '__main__':
   main()

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

Solution (Python):
N = int(input())
W = [input() for _ in range(N)]
flag = True
if len(set(W)) != N:
    flag = False
for i in range(N-1):
    if W[i][-1] != W[i+1][0]:
        flag = False
print('Yes' if flag else '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]) >= 2:
    print("No")
    exit()

print("Yes")

Solution (Python):
N,*W=open(0)

ans='Yes'
i=0
while i+1<int(N):
    if W[i][-2]!=W[i+1][0]:
        ans='No'
    i+=1
print([ans,'No'][int(N)>len(set(W))])

Solution (Python):


def solve():

    N = int(input())

    wlist = [input() for i in range(N)]
    s = set(wlist)

    if len(wlist) != len(s):
        print("No")
        exit()
    else:
        last = wlist[0][-1]
        for i in range(1, N):
            ini = wlist[i][0]
            if last != ini:
                print("No")
                exit()
            last = wlist[i][-1]

    print("Yes")


if __name__ == "__main__":
    solve()

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

for i in range(n-1):
    if w.count(w[i]) == 1 and w[i][-1] == w[i+1][0]: 
        continue
    else: 
        x = 1
        print("No")
        break

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

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

W = input()
words = {W}

ans = True
for _ in range(N - 1):
    num = len(words)
    w = input()
    words.add(w)
    if (W[-1] != w[0] or num == len(words)):
        ans = False
        break
    W = w

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

Solution (Python):
n ,*L = map(str,open(0).read().split())
li = [L[0]]
for i in range(1,int(n)):
    if (L[i] in li) or L[i-1][-1] != L[i][0]:
        print("No")
        exit()
    li.append(L[i])
print("Yes")

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

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

print(ans)

Solution (Python):
n =int(input())
w =[]
for i in range(n):
    w.append(input())
import sys
for i in range(n):
    for j in range(n):
        if i != j:
            if w[i] ==w[j]:
                print("No")
                sys.exit()

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

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

ans = 'Yes'
used_w = []
for i, word in enumerate(w):
    if i == 0:
        used_w.append(word)
        prev = word[-1]
        continue
    if word[0] == prev and word not in used_w:
        prev = word[-1]
        used_w.append(word)
    else:
        ans = 'No'
        break

print(ans)

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

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

print('Yes')

Solution (Python):
n = int(input())
ans = True
already = set()
memory = 0
for i in range(n):
    w = input()
    if (memory == 0 or memory == w[0]) and not w in already:
        memory = w[len(w)-1]
        already.add(w)
    else:
        ans = False
if ans:
    print("Yes")
else:
    print("No")

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

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

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

Solution (Python):
n=int(input())
wl=[input() for i in range(n)]
f=0
if len(wl)==len(set(wl)):
  for i in range(n):
    if i==0:
      pass
    else:
      if wl[i][0]==wl[i-1][-1]:
        pass
      else:
        f=1
else:
  f=1
print("Yes" if f==0 else "No")

Solution (Python):
import sys

input = sys.stdin.readline

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

check = set([W[0]])
flag = True
before = W[0][-1]
for i in range(1, N):
    if before != W[i][0] or W[i] in check:
        flag = False
        break
    else:
        before = W[i][-1]
        check.add(W[i])

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

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

Solution (Python):
n=int(input())
ans="Yes"
dic={}
w=input()
last=w[-1]
dic[w]=dic.get(w,0)+1
for i in range(n-1):
    w=input()
    if dic.get(w,0)==1 or w[0]!=last:
        ans="No"
        break
    dic[w]=dic.get(w,0)+1
    last=w[-1]

print(ans)

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

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

for i in range(n-1):
    flag=True
    for j in range(i+1,n):
        if w[i]==w[j]:
            flag=False
            print("No")
            exit()
if flag:
    print("Yes")

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

Solution (Python):
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n = ii()
wl = [input()]
rule = True
for i in range(1,n):
    s = input()
    if s in wl or s[0] != wl[-1][-1]:
        rule = False
    wl.append(s)

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

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):
  b = W[i-1]
  a = W[i]
  if b[len(b)-1] != a[0]:
    print('No')
    exit()

print('Yes')

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

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

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

Solution (Python):
n=int(input())
words=[]
def siritori(word):
    global words
    if words==[]:
        words.append(word)
        return True
    if (word not in words) and words[-1][-1]==word[0]:
        words.append(word)
        return True
    return False

ans=0
for i in range(n):
    if not siritori(input()):
        ans+=1
if ans==0:
    print("Yes")
else:
    print("No")

Solution (Python):
n = int(input())
check = set()
p = ''
for i in range(n):
  now = input()
  if i == 0:
    p = now
    check.add(now)
    continue
  if p[-1] != now[0] or now in check:
    print('No')
    exit()
  check.add(now)
  p = now
print('Yes')

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

Solution (Python):
a = int(input())
b_list =[]
for i in range(a):
    b = input()
    b_list.append(b)
def again(p,q):
    
    
    count = 0
    for i in range(p):
        if  q.count(q[i]) == 2:
            return False
            break
        else:
            count += 1
    if count == p:
        return True

def tail_head(p,q):
    count = 0
    for i in range(p-1):
        if q[i][len(q[i])-1]== q[i+1][0]:
            count += 1
        else:
            return False
            break
        if count == p-1:
                return True
                
if again(a,b_list) and tail_head(a,b_list):
    print('Yes')
else:
    print('No')

Solution (Python):
N = int(input())
first = input()
shiritori = [first]
t = 0
for i in range(N-1):
  lastword = shiritori[-1]
  nextword = input()
  lastchara = list(lastword)[-1]
  nextchara = list(nextword)[0]
  if lastchara == nextchara:
    shiritori.append(nextword)
    if shiritori.count(nextword) > 1:
      t += 1
  else:
    t += 1
if t == 0:
  print("Yes")
else:
  print("No")

Solution (Python):
from sys import exit
N = int(input())
w = [input()]
for i in range(N - 1):
  last = w[i] 
  word = input()
  if word in w or word[0] != last[len(last) - 1]: 
    print("No")
    exit()
  w.append(word)  
print("Yes")

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

def checkDuplication(wordList):
    if len(set(wordList)) == n:
        return True
    else :
        return False

def checkMatch(wordList):
    checkCount = 0
    for i in range(n-1):
        if wordList[i][-1] == wordList[i+1][0]:
            pass
        else:
            checkCount += 1
    
    if checkCount:
        return False
    else: 
        return True

if checkMatch(w) and checkDuplication(w):
    print('Yes')
else:
    print('No')

Solution (Python):

def Shiritori(n , wli):

    ans = "Yes"

    if len(set(wli)) != len(wli):
        ans = "No"
    else:
        last = (wli[0])[0]
        for i in wli:
            if last != i[0]:
                ans = "No"
                break
            last = i[-1]

    return ans

def main():
    n = int(input())
    wli = [str(input()) for i in range(n)]
    print(Shiritori(n , wli))

if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
w = [input() for i in range(n)]
count = 0
if len(set(sorted(w))) != n:
     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):
n = int(input())
w = [input() for i in range(n)]
count = 0
for i in range(n):
     if len(set(sorted(w))) != n:
          count += 2
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):
n = int(input())
check = True
ss = ''
str_set = set()

for i in range(n):
  s = input()
  str_set.add(s)
  if ss != '':
    if ss[-1] != s[0]:
      check = False
      break  
  ss = s  
  
if len(str_set)!=n: check = False
  
if check:
  print('Yes')
else:
  print('No')

Solution (Python):
N = int(input())
W = [input() for _ in range(N)]
history = set()
prev = W[0][::-1]
for w in W:
    
    if w in history or w[0] != prev[-1]:
        print('No')
        break

    history.add(w)
    prev = w
else:
    print('Yes')

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

Solution (Python):
n, *l = open(0).read().split()
print("Yes" if len(set(l)) == len(l) and all(l[i][-1] == l[i+1][0] for i in range(int(n)-1)) else "No")

Solution (Python):
n=int(input())
B=[]
S = 0
for i in range(0,n):
    B.append((input()))
C = set(B)
if len(B) != len(C):
    print("No")
else:
    for m in range(n-1):
        if B[m][-1] == B[m+1][0]:
            S += 1
    if S == n-1:
        print("Yes")
    else: 
        print("No")

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

Solution (Python):

N = int(input())
ans = "Yes"
memo = {}
word = input()
memo[word] = None
last_char = word[-1]

for _ in range(N-1):
    word = input()
    if word in memo:
        ans = "No"
        break
    if word[0] != last_char:
        ans = "No"
        break
    memo[word] = None
    last_char = word[-1]

print(ans)

Solution (Python):
N = int(input())
Dict = {}
flag = 0 

first_f = input()
Dict[first_f]=1
last_f = first_f[-1]

for _ in range(N-1):
  f = input()
  if f[0]!=last_f:
    flag=1
    break
  else:
    if f in Dict:
      Dict[f]+=1
    else:
      Dict[f]=1
  last_f = f[-1]
      
l = [i for i in list(Dict.values()) if i>=2]
if len(l)>=1:
  flag=1
if flag==1:
  print("No")
else:
  print("Yes")

Solution (Python):
n = int(input())
w_list = [input() for _ in range(n)]
for i in range(1, n):
    if w_list[i - 1][-1] != w_list[i][0] or w_list[i] in w_list[:i]:
        print("No")
        exit()
print("Yes")

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

Solution (Python):


import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
d = defaultdict(lambda : False)
flag = True
for i in range(n):
    w = input()
    if i == 0:
        tmp = w
        d[w] = True
        continue
    if tmp[-1] != w[0]:
        flag = False
    if d[w]:
        flag = False
    d[w] = True
    tmp = w
if flag:
    print('Yes')
else:
    print('No')

Solution (Python):
n = int(input())
W = [input() for _ in range(n)]
L = [""] * n
ans = "Yes"

for i in range(n - 1):
    if W[i][-1] == W[i + 1][0] and W[i] not in L:
        L[i] = W[i]
    else:
        ans = "No"
        break

if W[n - 1] in L:
    ans = "No"

print(ans)

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

Solution (Python):
n = int(input())
w=[]
w.append(input())
a = False
for i in range(n-1):
    w.append(input())
    if not(w[i][-1]==w[i+1][0] and sorted(w)==sorted(set(w))):
        print('No')
        a = True
        break
if a==False:
    print('Yes')

Solution (Python):
import itertools
import math
import sys
import heapq
from collections import Counter
from collections import deque
from fractions import gcd
from functools import reduce
INF = 1 << 60
sys.setrecursionlimit(10 ** 6)


n = int(input())
a = []
yes = True
for i in range(n):
    w = input()
    if i != 0 and a[i - 1][-1] != w[0]:
        yes = False
    a.append(w)

a_set = set(a)
if len(a_set) != n:
    yes = False
if yes:
    print("Yes")
else:
    print("No")

Solution (Python):
a=int(input())
b=[]
c=""
for i in range(a):
    b.append(str(input()))
for j in range(a-1):
    if b[j][-1]==b[j+1][0]:
        if len(set(b))==a:
            c="Yes"
        else:
            c="No"
            break
    else:
        c="No"
        break
print(c)

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

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

w=set(W)
answer="Yes"

if len(w)==len(W):
    for i in range(1,N):
        if W[i-1][len(W[i-1])-1]==W[i][0]:
            pass
        else:
            answer="No"
            break
    print(answer)
else:
    print("No")

Solution (Python):
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

n = ni()
w = nsn(n)

flag = True
dic = dict()
last = w[0][0]
for i in range(n):
    if dic.get(w[i], False):
        flag = False
    if last != w[i][0]:
        flag = False
    last = w[i][-1]
    dic[w[i]] = True

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

Solution (Python):
N = int(input())
W = [input() for _ in range(N)]
S = set()
ans = 'Yes'
for i in range(N-1):
    if W[i] in S:
        ans = 'No'
        break
    else:
        S.add(W[i])
    
    if W[i][-1] != W[i+1][0]:
        ans = 'No'
        break 

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

print(ans)

Solution (Python):
n=int(input())
S=[]
for i in range(n):
  s=input()
  S.append(s)
flg=True
for i in range(1,n):
  if S[i][0]!=S[i-1][-1]:
    print('No')
    exit()

if len(set(S))!=n:
  print('No')
else: print('Yes')

Solution (Python):
N = int(input())
word = []
flag = 0
for i in range(N):
    S = input()
    if i == 0:
        word.append(S)
    else:
        if S in word:
            print("No")
            flag += 1
            break
        else:
            if word[i-1][len(word[i-1])-1] == S[0]:
                word.append(S)
            else:
                print("No")
                flag += 1
                break
if flag == 0:
    print("Yes")

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

Solution (Python):
st = set()
cant = False
prev = "-"
for i in range(int(input())):
        s = input()
        if (prev!="-" and prev!=s[0]) or s in st: cant = True
        prev = s[-1]
        st.add(s)
print("YNeos"[cant::2])

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

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

Solution (Python):
N = int(input())
word = []
flag = 1
for i in range(N):
  st = input()
  if i > 0 :
    if final != st[0]:
      flag = 0
    elif st in word:
      flag = 0
    else:
      final = st[-1]
      word += [st]
  else:
    final = st[-1]
    word += [st]
if flag:
  print("Yes")
else :
  print("No")

Solution (Python):

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

tmp = []
ans = "Yes"
for i in range(n-1):
    if w[i] in tmp:
        ans = "No"
        break
    if not w[i] in tmp:
        tmp.append(w[i])
    if w[i][-1] != w[i + 1][0]:
        ans = 'No'
        

if w[-1] in tmp:
    ans = "No"
print(ans)

Solution (Python):
N = int(input())
wlst = [input() for i in range(N)]
wset = set(wlst)
if len(wset) != N:
    print('No')
    exit()

tmp = wlst[0][-1]
for i in range(1, N):
    if tmp != wlst[i][0]:
        print('No')
        exit()
    tmp = wlst[i][-1]

print('Yes')

Solution (Python):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
a = [input() for _ in range(n)]
ok = True
if len(a) != len(set(a)):
    ok = False
for i in range(n-1):
    if a[i][-1] != a[i+1][0]:
        ok = False
print('Yes' if ok else 'No')

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

flag = True
for i in range(N):
    S = input()
    if S in s:
        flag = False
    if i > 0 and S[0] != prev:
        flag = False
    s.add(S)
    prev = S[-1]
if flag:
    print("Yes")
else:
    print("No")

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

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

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

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

Solution (Python):
n=int(input())
s=set()
w=input()
s.add(w)
for _ in range(n-1):
  x=input()
  if x in s:
    print('No')
    exit()
  if w[-1]!=x[0]:
    print('No')
    exit()
  s.add(x)
  w=x
print('Yes')

Solution (Python):

from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    w = [input() for i in range(n)]
    d = defaultdict(lambda : 1)
    p = w[0][0]
    for i in w:
        if not d[i]:
            print("No")
            return
        d[i] = 0
        if p != i[0]:
            print("No")
            return
        p = i[-1]
    print("Yes")
    return


if __name__ == "__main__":
    solve()

Solution (Python):
def main():
    N = int(input())
    A = [input() for i in range(N)]
    if len(A) != len(set(A)):
        return print("No")
    pre = A[0][-1]
    for a in A[1:]:
        if pre != a[0]:
            return print("No")
        pre = a[-1]
    print("Yes")


if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
word = [input() for _ in range(n)]
count=0
for i in range (0,n):
    for j in range (i+1,n):
        if (word[i] == word[j]):
            count += 1
for k in range (0,n-1):
    if (word[k][len(word[k])-1] != word[k+1][0]):
        count += 1
if (count == 0):
    print("Yes")
else:
    print("No")

Solution (Python):
if __name__ == "__main__":
    n = int(input())
    w = list()
    for i in range(n):
        w.append(input())

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

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

    print('Yes')

Solution (Python):
n = int(input())
l = []
ans = 'Yes'
ps = 'a'
for i in range(n):
  s = input()
  if s in l:
    ans = 'No'
  l.append(s)
  if i != 0 and ps[-1] != s[0]:
    ans = 'No'
  ps = s

print(ans)

Solution (Python):
n = int(input())
l = []
ans = 'Yes'
ps = 'a'
for i in range(n):
  s = input()
  if s in l:
    ans = 'No'
  l.append(s)
  if i != 0 and ps[-1] != s[0]:
    ans = 'No'
  ps = s

print(ans)

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

if len(set(W)) != 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):
n=int(input())
w=[]
w.append(input())
for i in range(n-1):
    s=input()
    if  s[0]!=w[-1][-1]:
        pass
    else:
        w.append(s)

l=len(list(set(w)))

if l!=n:
    print('No')
else:
    print('Yes')

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

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

Solution (Python):



N = int(input())


last = input()
word_list = []
word_list.append(last)
is_ok = True


for i in range(N-1):
    tmp = input()
    if tmp in word_list or not last[-1]==tmp[0]:
        is_ok = False
        break
    else:
        last = tmp
        word_list.append(tmp)


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

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

Solution (Python):
def has_duplicates(words):
    return len(words) != len(set(words))

def words(n):
    words = []
    for i in range(n):
        w = input()
        words.append(w)
    return words

def shiritori(shiritori_words):
    ans = []
    word = shiritori_words[0]
    end_word = word[len(word) -1]
    for j in range(1, len(shiritori_words)):
        word = shiritori_words[j]
        first_word = word[0]
        if has_duplicates(shiritori_words) or end_word != first_word:
            ans.append("No")
        else:
            ans.append("Yes")
        end_word = word[len(word) - 1]
    return ans
            
        

n = int(input())
shiritori_words = words(n)
ans = shiritori(shiritori_words)
if "No" in ans:
    print("No")
else:
    print("Yes")

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

Solution (Python):
n = int(input())
w = [input() for _ in range(n)]
w_l = [w[0]]
w_ = w[0][-1]
for wi in w[1:]:
    if w_ != wi[0] or wi in w_l:
        print("No")
        exit()
    w_ = wi[-1]
    w_l.append(wi)
print("Yes")

Solution (Python):
import sys

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

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

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

print("Yes")

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


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

Solution (Python):
N = int(input())
s = set()
word = input()
s.add(word)
last = word[-1]
for i in range(N-1):
  word = input()
  if word in s or word[0] != last:
    print('No')
    quit()
  else:
    s.add(word)
    last = word[-1]

print('Yes')