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())
a=[]
c=0
for _ in range(n):
    w=input()
    a.append(w)

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

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

Solution (Python):
from typing import List


def answer(n: int, w: List[str]) -> str:
    if len(set(w)) != len(w):
        return 'No'

    for i in range(1, len(w)):
        if not w[i].startswith(w[i - 1][-1]):
            return 'No'

    return 'Yes'


def main():
    n = int(input())
    w = [input() for _ in range(n)]
    print(answer(n, w))


if __name__ == '__main__':
    main()

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

w_list=[input()]


ans="Yes"

for i in range(n-1):
    w=input()
    if w not in w_list and w_list[-1][-1]==w[0]:
        w_list.append(w)
    else:
        ans="No"
        break

print(ans)

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

def main(n,w):
    
    words={}
    word=w[0]
    words[w[0]] = 1 
    for i in range(1,n):
        
        if w[i][0]!=word[-1]:
            return 'No'
        else:
            if w[i] not in words:
                words[w[i]] = 1
            else:
                return 'No'
        word = w[i]
    return 'Yes'

if __name__=='__main__':
    n,w=readinput()
    ans=main(n,w)
    print(ans)

Solution (Python):
n=int(input())-1
tmp=input()
wordset={tmp}

for i in range(n):
  w=input()
  if w in wordset or w[0]!=tmp[-1]:
    print('No')
    exit()
  else:
    wordset=wordset|{w}
    tmp=w
  
print('Yes')

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

Solution (Python):
import sys
s = []

for i in range(int(input())):
    W = input()
    if W in s:
        print("No")
        sys.exit()
    if len(s) != 0 and s[-1][-1] != W[0]:
        print("No")
        sys.exit()
    s.append(W)
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())
L = []
for _ in range(N):
  W = str(input())
  if W in L:
    print('No')
    exit()
  L.append(W)
for i in range(N - 1):
  if L[i][len(L[i]) - 1] != L[i+1][0]:
    print('No')
    exit()
print('Yes')

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

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


for i in range (n):
    for j in range (i+1,n):
        if w[i] == w[j]:
            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=[""]*n
a=set()
for i in range(n):
    w[i]=input()
cnt=0
for x in w:
    if x in a:
        print("No")
        exit()
    else:
        if cnt>0:
            if bef!=x[0]:
                print("No")
                exit()
        bef=x[-1]
    cnt+=1
    a.add(x)
print("Yes")

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

d = dict()
last = W[0][0]

good = True
for w in W:
    if d.get(w) != None:
        good = False
        break
    elif w[0] != last:
        good = False
        break
    else:
        d[w] = 1
        last = w[-1]

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

Solution (Python):
n=int(input())
hatsugen=[]
w=input()
hatsugen.append(w)
oshiri=w[-1]
Flag=True
for _ in range(n-1):
    w=input()
    if w[0]!=oshiri:
        Flag=False
        break
    if w in hatsugen:
        Flag=False
        break
    oshiri=w[-1]
    hatsugen.append(w)
if Flag:
    print('Yes')
else:
    print('No')

Solution (Python):
import sys
import numpy as np
import collections as cl
import itertools as it

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(100000)

n = int(readline())
w = [input().strip() for _ in range(n)]
dic = set()

for num, i in enumerate(w):
    if num == 0:
        dic.add(i)
        continue
    if i in dic or w[num-1][-1] != i[0]:
        print('No')
        sys.exit()
    dic.add(i)
print('Yes')

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

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

Solution (Python):
n = int(input())
used = []
bef = input()
used.append(bef)
for _ in range(n - 1):
  now = input()
  if now in used:
    print("No")
    exit()
  elif bef[-1] != now[0]:
    print("No")
    exit()
  else:
    used.append(now)
    bef = now
print("Yes")

Solution (Python):
n = int(input())
w = [input() for i in range(n)]
bool = True
for i in range(1,n):
    if w[i][0] != w[i-1][len(w[i-1]) - 1]:
        bool = False
    for j in range(0,i):
        if w[i] == w[j]:
            bool = False
if bool:
    print('Yes')
else:
    print('No')

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

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

print(ans)

Solution (Python):
n = int(input())
list_w = [input() for s in range(0, n)]
for i in range(0, n):
    if i == 0 or (list_w[i - 1][-1] == list_w[i][0]) and list_w[i] not in list_w[:i]:
        continue
    else:
        print("No")
        exit()
print("Yes")

Solution (Python):

import sys
input=sys.stdin.readline

def main():
    words=[]
    n = int(input())
    words=[input().rstrip() for _ in range(n)]

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

    endstring=""
    for word in words:
        if len(endstring)==0:
            endstring=word[-1]
        else:
            if endstring==word[0]:
                endstring=word[-1]
            else:
                print("No")
                exit()
    print("Yes")


if __name__=="__main__":
    main()

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

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

Solution (Python):
N = int(input())
li = []
flag = True
for i in range(N):
    word = input()
    if i != 0:
        if pre_word[len(pre_word)-1] != word[0] or word in li:
            flag = False
            break
    li.append(word)
    pre_word = word
if flag:
    print('Yes')
else:
    print('No')

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

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

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

prev = input()
m[prev] = True
flg = True

for _ in range(N - 1):
  s = input()
  flg = all([flg, s not in m, prev[len(prev) - 1] == s[0]])
  m[s] = True
  prev = s

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

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

prev = input()
m[prev] = True
flg = True

for _ in range(N - 1):
  s = input()
  flg = flg and s not in m
  flg = flg and prev[len(prev) - 1] == s[0]
  m[s] = True
  prev = s

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

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

    ok = True
    if len(set(data)) != n: ok = False
    for i in range(n-1):
        if data[i][-1] != data[i+1][0]:
            ok = False

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

main()

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

words = set()
ok = True
for i in range(n):
    if w[i] in words:
        ok = False
        break
    elif i != 0 and w[i-1][-1] != w[i][0]:
        ok = False
        break
    words.add(w[i])
print('Yes' if ok else 'No')

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

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

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N = I()
    W = []
    fail = False
    seen = set()
    for i in range(N):
        w = S()
        if i == 0:
            pass
        else:
            if w[0] != prev[-1]:
                fail = True
            if w in seen:
                fail = True
        seen.add(w)
        prev = w

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


main()

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

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

temp=li[0][-1]
for j in range(N-1):
    if temp==li[j+1][0]:
        temp=li[j+1][-1]
    else:
        print("No")
        exit()
li.sort()

for k in range(N-1):
    if li[k]==li[k+1]:
        print("No")
        exit()
print("Yes")

Solution (Python):
n = int(input())
tmp1=input()
tmp=tmp1[len(tmp1)-1]

s = set()
s.add(tmp1)

flg=True
for i in range(n-1):
    w = input()
    if w[0] != tmp:
        flg = False
        break
    tmp = w[len(w)-1]

    s.add(w)
    if(len(s) != i+2):
        flg = False
        break

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

Solution (Python):
import sys
import math


sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

ans = "Yes"
N = ini()
words = []
for _ in range(N):
    words.append(input())


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

for i in range(N-1):
    if words[i][len(words[i])-1] != words[i+1][0]:
        ans = "No"

print(ans)

Solution (Python):
n = int(input())
used = list(input() for x in range(n))
ans = "Yes"
for i in range(n-1): 
  if used.count(used[i]) == 2:
    ans = "No"
    break
  if used[i][-1] != used[i+1][0]:
    ans = "No"
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(1, N):
    if W[i][0] != W[i-1][-1]:
        print('No')
        exit()
print('Yes')

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

Solution (Python):
import os
import sys
from collections import defaultdict, Counter, deque
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt
from copy import deepcopy


def main():
    n = int(input())
    vectoer = []
    flag = True
    for i in range(n):
        s = input()
        vectoer.append(s)

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

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

if __name__ == '__main__':
	main()

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

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

for i in range(n-1):
  p=list(w[i])
  q=list(w[i+1])
  if p[-1]!=q[0]:
    print('No')
    sys.exit()
  
print('Yes')

Solution (Python):
n = int(input())
w_l = [ input() for _ in range(n) ]
memo = set()
b_w = w_l[0][0]
ans = 'Yes'
for w in w_l:
    if b_w == w[0]:
        if w not in memo:
            memo.add(w)
            b_w = w[-1]
            continue
    ans = 'No'
    break
print(ans)

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

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

for i in range(N-1):
	if W.count(W[i]) == 2:
		print("No")
		break
	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)]

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

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

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

Solution (Python):
import collections
N = int(input())
W = []
f = input()
W.append(f)
ans = "Yes"
for _ in range(N-1):
    w = input()
    if f[-1] != w[0]:
        ans = "No"
    W.append(w)
    f = w
    
cnt = collections.Counter(W)
for v in cnt.values():
    if v >= 2:
        ans = "No"
        
print(ans)

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

for i in range(1, N):
  t = input()
  if t in l:
    ans = 'No'
    break
  elif l[i-1][-1] ==  t[0]:
    l.append(t)
  else:
    ans = 'No'
    break
print(ans)

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

n = int(input())

words = []
for _ in range(n):
    w = input().strip()

    if w in words:
        print('No')
        sys.exit(0)

    if len(words) == 0:
        words.append(w)
        continue

    if words[-1][-1] != w[0]:
        print('No')
        sys.exit(0)
    else:
        words.append(w)
print('Yes')

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

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

if len(set(w)) < len(w):
    ans = 'No'

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

print(ans)

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

lst = []

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

for n in range(1, N):
    if lst[n][0] != lst[n-1][-1] or lst.count(lst[n])>=2:
        print('No')
        break
else:
    print('Yes')

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

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

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

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

W = []

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

cnt = set()
last = W[0][-1]
for i, w in enumerate(W):
    if i == 0:
        cnt.add(w)
        continue
    if w[0] != last:
        print('No')
        exit()
    last = w[-1]
    cnt.add(w)
    if i+1 != len(cnt):
        print('No')
        exit()

print('Yes')

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

siritolist = []

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

for i in range(1, len(siritolist)):
    back_word = list(siritolist[i-1])
    word = list(siritolist[i])
    if back_word[-1] == word[0] and i > 1:
        for j in range(i-1):
            if siritolist[i] == siritolist[j]:
                print('No')
                exit()
    elif back_word[-1] != word[0]:
        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 = [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 = [input() for _ in range(N)]
used = []

first = W[0]
used.append(first)

for index in range(1, len(W)):
    if W[index][0] == W[index-1][-1] and W[index] not in used:
        used.append(W[index])
    else:
        print("No")
        exit()
print("Yes")

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

unique = list(set(W))
if len(unique) != 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):
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    N = int(readline())

    def judge():
        res = True
        prev = input()
        used = set()
        used.add(prev)
        for _ in range(N - 1):
            cur = input()
            if prev[-1] != cur[0]:
                res = False
            if cur in used:
                res = False
            used.add(cur)
            prev = cur

        return res

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


if __name__ == '__main__':
    main()

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

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

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

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


if __name__ == "__main__":
    main()

Solution (Python):
import sys
n, *s = sys.stdin.read().split()
seen = set()
tmp = s[0][0]

for x in s:
    if x[0] != tmp or x in seen:
        print("No")
        sys.exit()
    else:
        seen.add(x)
        tmp = x[-1]
print("Yes")

Solution (Python):
n = int(input())
seen = set()
tmp = ""
for _ in range(n):
    x = input()
    if not tmp:
        seen.add(x)
        tmp = x[-1]
        continue
    elif x[0] != tmp or x in seen:
        print("No")
        exit(0)
    else:
        seen.add(x)
        tmp = x[-1]
print("Yes")

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

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

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

W_list = []
check = True

for i in range(N):
  W = input()
  if i == 0:
    W_list.append(W)
    continue
    
  if W in W_list:
    check = False
    break
    
  if W_list[i-1][-1] != W[0]:
    check = False
    break
    
  W_list.append(W)
    
print("Yes" if check else "No")

Solution (Python):
from collections import Counter

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

if Counter(l).most_common()[0][1] != 1:
  ans="No"
else:
  l_head = [l[i+1][0] for i in range(n-1)]
  l_tail = [l[i][-1] for i in range(n-1)]
  if l_head == l_tail:
    ans="Yes"
  else:
    ans="No"
    
print(ans)

Solution (Python):
n = int(input())
w = []
for _ in range(n):
    w.append(input())
a = ''
for i in range(n):
    for j in range(i):
        if w[i] == w[j]:
            print('No')
            exit()
for j in w:
    b = [i for i in j]
    if j != w[0] and a != b[0]:
        print('No')
        exit()
    a = b[-1]
print('Yes')

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

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

ans = 'Yes'
last = ''

for i in range(N):
    for j in range(i):
        if W[i]==W[j]:
            ans = 'No'
            
for w in W:
    W_new = [i for i in w]
    if w!=W[0] and last!=W_new[0]:
        ans = 'No'
    last = W_new[-1]

print(ans)

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

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

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

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

print('Yes')

Solution (Python):
N = int (input ())
l = []
S = 'Yes'
A = input ()
W = A[-1]
l.append (A)
for i in range (N-1):
  A = input ()
  if A[0] != W or l.count(A) != 0:
    S = 'No'
    break
  l.append (A)
  W = A[-1]
print (S)

Solution (Python):
import math
import itertools
import sys

n=int(input())
last=input()
log=[]
log.append(last)
q=[]
ans="Yes"
for i in range(n-1):
    tmp=input()
    q.append(tmp)
for i in q:
    if(i[0]!=last[-1] or i in log):
        ans="No"
        break
    else:
        last=i
        log.append(i)
print(ans)

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

print("Yes")

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

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

ok = True
t = input()
p = t[-1]
s.add(t)
for i in range(n-1):
    t = input()
    if t in s:
        ok = False
    s.add(t)
    if t[0] != p:
        ok = False
    p = t[-1]

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

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

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

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


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

Solution (Python):
N = int(input())
f = 0
A = []
for i in range(N):
  if i == 0:
    A.append(input())
  else:
    A.append(input())
    if A[-2][-1] != A[-1][0]:
      f = 1
      break
    if len(set(A)) < i + 1:
      f = 1
      break
if f == 0:
  print("Yes")
else:
  print("No")

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

Solution (Python):
n = int(input())
w = list()
f = input()
w.append(f)
cnt = 0
for i in range(1, n):
    x = input()
    a = w[i-1]
    if a[-1] == x[0]:
        if x not in w:
            cnt += 1
            w.append(x)
            if cnt == n-1:
                print("Yes")
                break
        else:
            print("No")
            break
    else:
        print("No")
        break

Solution (Python):
import sys
lines = [s.rstrip("\n") for s in sys.stdin.readlines()]
n, = [int(num) for num in lines.pop(0).split(" ")]
words = lines
prev_last_char = None
words_already_used = {}
for w in words:
    if w in words_already_used:
        print("No")
        break
    else:
        words_already_used[w] = True
    if prev_last_char is not None:
        if w[0] != prev_last_char:
            print("No")
            break
    prev_last_char = w[-1]
else:
    print("Yes")

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

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

Solution (Python):
from collections import *
n=int(input())
l=[]
for i in range(n):
    l.append(input())
f=0
c=Counter(l)
for i in c.values():
    if(i>1):
        f=1
        break
if(f==1):
    print("No")
else:
    d=0
    for i in range(1,n):
        if(l[i-1][-1]!=l[i][0]):
            d=1
            break
    if(d==1):
        print("No")
    else:
        print("Yes")

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

word = [input()]
for _ in range(n-1):
  w = input()
  if w not in word and w[0] == word[-1][-1]: word.append(w)
  else:
    print("No")
    exit()
print("Yes")

Solution (Python):
n = int(input())
m = []
for i in range(n):
    m.append(input())
    
if len(set(m)) != len(m):
    print("No")
    exit()

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

Solution (Python):
N=int(input())
correct = True
words = set({})

W = input()
words.add(W)
last_letter = W[len(W)-1]

for i in range(1,N):
    W = input()
    if  not W in words and W[0] == last_letter:
        words.add(W)
        last_letter = W[len(W)-1]
    else:
        correct = False
        break

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

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

l = len(set(ab))

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

Solution (Python):
N = int(input())
L = [str(input()) for i in range(N)]
flag = 1

for i in range(N):
    if L.count(str(L[i]))<2:
        if str(L[i-1])[-1] == str(L[i])[0]:
            pass
        elif i == 0:
            pass
        else:
            flag = 0
    else:
        flag = 0

if flag:
    print("Yes")

else:
    print("No")

Solution (Python):
import sys 

n=int(input())
w=[list(input()) for i in range(n)]
flag=True

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

Solution (Python):
n = int(input())
w = [input()]
for i in range(1,n):
  w.append(input())
if len(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")

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())
D = set()
s = input().rstrip()
D.add(s)
s0 = s[-1]
for _ in range(N-1):
    s = input().rstrip()
    if s in D:
        print("No")
        exit()
    if s[0] != s0:
        print("No")
        exit()
    D.add(s)
    s0 = s[-1]
print("Yes")

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

for w in S:
    if e!=w[0] and e!='':
        print('No')
        exit()
    e=w[-1]

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

Solution (Python):
N = int(input())
W = []
flag = 1

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

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

ok = True
for i in W:
    if W.count(i)>1:
        ok = False
        
for i in range(1,N):
    if W[i-1][-1] != W[i][0]:
        ok = False
        
if ok:
    print('Yes')
else:
    print('No')

Solution (Python):
N = int(input())
pre = input()
dict = {pre:1}
for i in range(N-1):
    now = input()
    if now[0]!=pre[-1]:
        print('No')
        exit(0)
    elif now in dict:
        print('No')
        exit(0)
    else:
        dict[now] = 1
        pre = now 
print('Yes')

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

ans = "Yes"

words.append(w)

for i in range(1,n):
    w = input()
    if w not in words:
        if words[-1][-1]==w[0]:
            words.append(w)
            continue
        else:
            ans = "No"
            break
    else:
        ans = "No"
        break
print(ans)