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):
import sys
n = int(input())
w = input()
words=[]

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:
            print("No")
            sys.exit()
    else:
        print("No")
        sys.exit()
print("Yes")

Solution (Python):
N=int(input())
W=[]
for i in range(N):
    W.append(input())
A=[]
for i in range(1,N):
    for j in range(0,i):
        if W[i]!=W[j] and W[i][0]==W[i-1][len(W[i-1])-1]:
            A.append('Yes')
        else:
            A.append('No')
if 'No' in A:
    print('No')
else:
    print('Yes')

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

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

Solution (Python):
n = int(input())
s = []
fl = [[] for _ in range(n)]
ans = "Yes"
for i in range(n):
    w = input()
    if w in s:
        s.append(w)
        fl[i] = [w[0], w[-1]]
        ans = "No"
    else:
        s.append(w)
        fl[i] = [w[0], w[-1]]

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

Solution (Python):
n = int(input())
w = [str(input()) for i in range(n)]
z = 'Yes'
l = [w[0]]
for h in range(n-1):
    if w[h][-1] == w[h+1][0] and w[h+1] not in l:
        l.append(w[h+1])
    else:
        z = 'No'
        break
print(z)

Solution (Python):
n = int(input())
tmp = []
isOK = True
for i in range(n):
    s = str(input())
    if len(tmp)!=0:
        if s in tmp:
            
            isOK = False
            break
        if end!=s[0]:
            
            isOK = False
            break
    end = s[-1]
    tmp.append(s)

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

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

flag = True

for i in range(n-1):
    s = input()
    if s not in l and s[0] == l[-1][-1]:
        l.append(s)
    else:
        flag = False
        break

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

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

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

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

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

Solution (Python):
N = int(input())
w = []
w1 = ""
flag = 0
for i in range(N):
  s = input()
  if i == 0:
    w1 = s
    w.append(w1)
  else:
    if s[0] == w[i-1][-1] and s not in w:
      w1 = s
      w.append(w1)
    else:
      flag += 1
      break
print("No") if flag == 1 else print("Yes")

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

Solution (Python):
n =int(input())
W=[]
w=''
for i in range(n):
    s=str(input())
    if i !=0 and w[-1] != s[0]:
        print('No')
        exit()
    else:
        w=s
        W.append(w)
if len(W) != len(list(set(W))):
    print('No')
    exit()
print('Yes')

Solution (Python):
for i,w in enumerate(l:=[input() for _ in range(int(input()))]):
  if i and (l[i][0]!=l[i-1][-1] or w in l[:i]): exit(print('No'))
print('Yes')

Solution (Python):
l=[input() for _ in range(int(input()))]
for i,w in enumerate(l):
  if i and (l[i][0]!=l[i-1][-1] or w in l[:i]): exit(print('No'))
print('Yes')

Solution (Python):
l=[input() for _ in range(int(input()))]
for i,w in enumerate(l):
  if i:
    if l[i][0]!=l[i-1][-1] or w in l[:i]:
      exit(print('No'))
print('Yes')

Solution (Python):
l=[input() for _ in range(int(input()))]
for i,w in enumerate(l):
  if i:
    if l[i][0]==l[i-1][-1] and w not in l[:i]:
      continue
    exit(print('No'))
print('Yes')

Solution (Python):
n = int(input())
w = list(input() for _ in range(n))
flag = False

if n == len(set(w)):
    if all([w[i - 1][-1] == w[i][0] for i in range(1, n)]):
        flag = True

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

Solution (Python):
n = int(input())
a = input()
s = {a}
a = a[-1]
c = 1
for _ in range(n-1):
    b = input()
    if a == b[0]:
        a = b[-1]
        c += 1
        s.add(b)
    else:
        print('No')
        break
else:
    print('Yes' if len(s) == c else 'No')

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

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

Solution (Python):
n = int(input())
w = [input() for i in range(n)]
cnt = 0
for j in range(n-1):
    if (w[j][-1] == w[j+1][0])&(w.count(w[j])==1):
        pass
    else:
        cnt += 1
print("No") if cnt else print("Yes")

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(n-1):
        if w[i][len(w[i])-1]!=w[i+1][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")
else:
    for i in range(n-1):
        if w[i][len(w[i])-1]!=w[i+1][0]:
            print("No")
            break
    else:
        print("Yes")

Solution (Python):
n = int(input())
w = input()
double_set = set()
double_set.add(w)
finish_str = w[-1]

for i in range(1, n):
    w = input()
    if w not in double_set and w[0] == finish_str:
        double_set.add(w) 
        finish_str = w[-1]
    else:
        print("No")
        break
else:
    print("Yes")

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N = int(readline())
    W = [readline().strip() for _ in range(N)]

    for w in W:
        if W.count(w) > 1:
            print('No')
            return

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

    print('Yes')
    return


if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
w = [input() for i in range(n)]
for i in range(n):
    flag = True
    for j in range(i):
        if w[i] == w[j]:
            flag = False
    if not flag:
        break
    elif i >= 1 and w[i-1][-1] != w[i][0]:
        flag = False
        break
if flag:
    print("Yes")
else:
    print("No")

Solution (Python):









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

if (len(w) != len(set(w))):
    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 = ""
S = []
f = True
for i in range(N):
    W = input()
    if i != 0:
        if W[0] != w[(len(w) - 1)] or W in S:
            f = False
            break
    w = W
    S.append(w)
if f == True:
    print("Yes")
else:
    print("No")

Solution (Python):
n=int(input())
ng=['!']
for i in range(n):
  w=input()
  ng[0]+=w[0]
  if w in ng or w[0] != ng[-1][-1]:
    
    print('No')
    break
  ng.append(w)
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(1, N):
    if W[i][0] != W[i-1][-1]:
        print('No')
        exit()
print('Yes')

Solution (Python):
import sys


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    n = ni()
    words = []
    flag = True
    for i in range(n):
        w = ns()
        if w in words:
            flag = False
        elif i != 0 and w[0] != words[-1][-1]:
            flag = False
        else:
            words.append(w)
    print('Yes' if flag else 'No')


if __name__ == '__main__':
    main()

Solution (Python):

import collections
N = int(input())
Word_List = []
SP = ""
for i in range(N):
    CW = str(input())
    if i == 0:
        Word_List.append(CW)
        SP = CW[-1]
    elif SP != CW[0]:
        print("No")
        break
    else:
        Word_List.append(CW)
        SP = CW[-1]
else:
    Word_List = collections.Counter(Word_List)
    if len(Word_List) != N:
        print("No")
    else:
        print("Yes")

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

for i in W:
    if W.count(i) > 1:
        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 i in range (n)]
if len(set(w)) == n and all (w[i][-1] == w[i + 1][0] for i in range (n - 1) ):
  print("Yes")
else:
  print("No")

Solution (Python):
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()
    W = [SS() for _ in range(N)]

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

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

    print(ans)

if __name__ == '__main__':
    resolve()

Solution (Python):
import collections
N=int(input())
W=[""]*N
for i in range(N):
  W[i]=input()
c=collections.Counter(W)
if len(c)!=N :
  print("No")
  exit()
for i in range(N-1):
  if W[i][-1] != W[i+1][0] :
    print("No")
    exit()
print("Yes")

Solution (Python):
def main():
    N = int(input())
    W_before = input()
    word_set = set()
    word_set.add(W_before)
    for i in range(N-1):
        W_after = input()
        if W_before[-1] != W_after[0]:
            print('No')
            return
        if W_after in word_set:
            print('No')
            return
        word_set.add(W_after)
        W_before = W_after
    print('Yes')

if __name__ == "__main__":
    main()

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


if len(set(w)) == N: 
    if all(w[i][-1] == w[i+1][0] for i in range(N-1)):
        print("Yes")
        exit() 

print("No")

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

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

print('No')

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

w = input().strip()
d = set([w])
l = w[-1]
f = True
for _ in range(N-1):
    w = input().strip()
    if w.startswith(l) and not w in d:
        d.add(w)
        l = w[-1]
    else:
        f = False
print("Yes" if f else "No")

Solution (Python):
import sys

N = int(input())
W = list(input() for _ in range(N))

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

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

words = []
ans = "Yes"
for count in range(N):
    word = input()
    if count == 0:
        words.append(word)
        next = word[-1]
        continue
    if next != word[0]:
        ans = "No"
    if words.count(word) == 1:
        ans = "No"
    words.append(word)
    next = word[-1]


print(ans)

Solution (Python):
def main():
    N = int(input())
    W_before = input()
    W_list = set()
    W_list.add(W_before)
    for i in range(N-1):
        W_after = input()
        if W_before[-1] != W_after[0]:
            print('No')
            return
        if W_after in W_list:
            print('No')
            return
        W_list.add(W_after)
        W_before = W_after
    print('Yes')

if __name__ == "__main__":
    main()

Solution (Python):
n = int(input())
f = True
w = input()
used = set([w])
last = w[-1]
for i in range(n-1):
    w = input()
    if w in used or w[0]!=last:
        f = False
        break
    else:
        used.add(w)
        last = w[-1]
if f:
    print('Yes')
else:
    print('No')

Solution (Python):
import sys
input = sys.stdin.readline
import math
from functools import reduce


def read():
    N = int(input().strip())
    W = []
    for i in range(N):
        w = input().strip()
        W.append(w)
    return N, W


def solve(N, W):
    used = dict()
    for w in W:
        if w in used.keys():
            return "No"
        used[w] = True
    for i in range(N-1):
        if W[i][-1] != W[i+1][0]:
            return "No"
    return "Yes"


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))

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

dict = defaultdict(bool)  
dict[W[0]] = True
for i in range(1, N):
    if (W[i][0] is not W[i - 1][-1]) or dict[W[i]]:
        print("No")
        sys.exit()
    dict[W[i]] = True

print("Yes")

Solution (Python):
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n = inint()
word = []

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

print("Yes")

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

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

v = True
z = list(set(w))
if len(z) != len(w):
  print("No")
else:
  for j in range(N - 1):
    if w[j][-1] != w[j+1][0]:
      v = False
  print("Yes") if v else print("No")

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

v = True
z = list(set(w))
if len(z) != len(w):
  print("No")
else:
  for j in range(N - 1):
    if w[j][-1] != w[j+1][0]:
      v = False
  print("Yes") if v else print("No")

Solution (Python):
N = int(input())
s = [input() for i in range(N)]
pre = ''
shirori = {}
for i in range(N):
    S = s[i]
    if i == 0:
        pre = S[len(S) - 1]
        shirori[S] = 1
        continue
    else:
        if shirori.get(S) is None:
            now = S[0]
            if now == pre:
                pre = S[len(S) - 1]
                shirori[S] = 1
            else:
                print('No')
                exit(0)
        else:
            print('No')
            exit(0)
print('Yes')

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

for i in range(n):
  x_=input()
  if x_ not in l:
    l.append(x_)
    
  else:
    print('No')
    exit()
    
alpha_list=[chr(i) for i in range(97,123)]

for i in range(len(l)-1):
  if l[i][-1]==l[i+1][0]:
    continue
    
  else:
    print('No')
    exit()
    
print('Yes')

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

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

L = set(l)

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

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

Solution (Python):
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

N = int(input())

w = input()
last = w[-1]
past = [w]
for _ in range(N-1):
    w = input()
    if w[0] != last or w in past:
        print('No')
        quit()
    last = w[-1]
    past.append(w)
print('Yes')

Solution (Python):
seen = set()

N = int(input())

prev = ""
for i in range(N):
    w = input()
    if w in seen:
        print("No")
        exit()
    seen.add(w)
    if i == 0:
        prev = w[-1]
        continue
    if prev != w[0]:
        print("No")
        exit()
    prev = w[-1]
print("Yes")

Solution (Python):
import sys
import heapq
import math


def input():
    return sys.stdin.readline().rstrip()


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

    l = "A"
    s = set()

    for i in range(N):

        w = input()
        if w[0] != l and i!=0:
            print("No")
            exit()
        if w in s:
            print("No")
            exit()
        l = w[-1]
        s.add(w)

    print("Yes")


if __name__ == "__main__":
    main()

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

res = True

dic = {}

last = ""

for w in W:
    if last != "":
        if w in dic:
            res = False
        if not w[0] == last:
            res = False

    dic[w] = 1
    last = w[-1]


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

Solution (Python):
n=int(input())
w=[]
f=0
for i in range(n):
    w.append(input())
for i in range(n-1):
    if w[i][len(w[i])-1]==w[i+1][0]:
        f+=1
for i in range(n):
    if w.count(w[i])==1:
        
        f+=1
print("Yes" if f==2*n-1 else "No")

Solution (Python):
n=[input() for _ in range(int(input()))]
if len(set(n))!=len(n): print('No');exit()
print('NYoe s'[all([1 if n[i-1][-1]==n[i][0] else 0 for i in range(1,len(n))])::2])

Solution (Python):
N=int(input())
a=input()
d=[a]
for x in range(N-1):
  b=input()
  if b not in d:
    d.append(b)
    if a[len(a)-1]==b[0]:
      a=b
      if x==N-2:
        print("Yes")
    else:
      print("No")
      break
  else:
    print("No")
    break

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

check = True

arrays = []

for i in range(n):
    v = input()
    x = list(v)
    if i > 0:
        if not y == x[0]:
            check = False
            break
    for j in range(len(arrays)):
        if arrays[j] == v:
            check = False
            break
    arrays.append(v)
    y = x.pop()

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

Solution (Python):
n=int(input())
a=[]
x=str(input())
a.append(x)
d=bool(True)

for i in range(1, n):
  y=str(input())
  if x[len(x)-1]!=y[0]:
    d=False
    
  for j in range(len(a)):
    if y==a[j]:
      d=False
  a.append(y)
  x=y

if  d==True:
  print("Yes")
else:
  print("No")

Solution (Python):
def main():
    N = int(input())
    words = []
    record = []
    previous = ''
    for i in range(N):
        words.append(str(input()))
    for i in range(N):
        if i == 0:
            record.append(words[i])
            previous = words[i]
        elif not words[i] in record and previous[-1] == words[i][0] and i != 0:
            record.append(words[i])
            previous = words[i]
        else:
            print('No')
            return
    print('Yes')
main()

Solution (Python):
n = int(input())
lists = [list(input()) for _ in range(n)]
lists_2 = [lists[0]]
for i in range(1,n):
  if lists[i-1][-1] == lists[i][0]:
    if lists[i] in lists_2:
      print("No")
      exit()
    else:
      lists_2.append(lists[i])
    if i == n-1:
      print("Yes")
    else:
      continue
  else:
    print("No")
    exit()

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

Solution (Python):
N=int(input())
history=[]
for i in range(N):
  s = input()
  if i == 0:
    history.append(s)
    continue
  if s not in history and history[-1][-1]==s[0]:
    history.append(s)
  else:
    print('No')
    exit()
print('Yes')

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

s = []
for i in range(n):
  s.append(input())
  
no = False

s_1 = s[1::]

for i, c in enumerate(s):
  if s.count(c) > 1:
    no = True
    
  if i < len(s)-1:
    c_1 = s_1[i]
    if c[-1] != c_1[0]:
      no = True
      
if no == True:
  print('No')
else:
  print('Yes')

Solution (Python):
import sys
N=int(input())
S=input()
L=list()
m=S[-1]
L.append(S)
for i in range(N-1):
  S=input()
  if S[0]!=m:
    print("No")
    sys.exit()
  else:
    L.append(S)
    m=S[-1]
if len(set(L))==N:
  print("Yes")
else:
  print("No")

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



word0 = wl[0][-1]

for i in range(1,n):
    if wl[i][0] == word0 and wl[i] not in wl[:i]:
        word0 = wl[i][-1]
    else:
        print('No')
        exit()
print('Yes')

Solution (Python):
n = int(input())
che = [input()]
for i in range(1,n):
  a = input()
  if a in che:
    print('No')
    exit()
  else:
    che.append(a)
    if che[i-1][-1] == che[i][0]:
      continue
    else:
      print('No')
      exit()
print('Yes')

Solution (Python):
if __name__ == '__main__':

	n = int(input())
	s = input()
	A = []
	A.append(s)

	flg = True
	for _ in range(n-1):
		cmd = input()
		if s[-1] == cmd[0] and cmd not in A:
			A.append(cmd)
			s = cmd
		else:
			flg = False

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

Solution (Python):
n = int(input())
w = []
flag = 0
tmp = ''

for i in range(n):
    w.append(input())
    if i == 0:
        continue
    elif w[i][0] != w[i-1][len(w[i-1])-1]:
        flag = 1

w = sorted(w)

for i in range(1,n):
    if w[i-1] == w[i]:
        flag = 1
        break

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

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

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

Solution (Python):
N = int(input())
list1 = []
count = 0
for i in range(N):
  a = input()
  list1.append(a)
for i in range(N-1):
  if list1[i][-1] == list1[i+1][0]:
    pass
  else:
    count +=1
aaa = set(list1)
if len(aaa) == len(list1):
  pass
else:
  count+=1
if count == 0:
  print('Yes')
else:
  print('No')

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

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

Solution (Python):
n = int(input())
t = 0
s = set()
ans = 1
for i in range(n):
    w = input()
    if w[0] != t and i >= 1:
        ans = 0
        break
    t = w[-1]
    s.add(w)
if len(s) != n:
    ans = 0
print(["No","Yes"][ans])

Solution (Python):




















































































def calculation(lines):
    N = int(lines[0])
    
    last_letter = lines[1][0]
    values = list()
    for i in range(1, N+1):
        line = lines[i]
        if line[0] != last_letter:
            return ['No']
        last_letter = line[-1:]
        if line in values:
            return ['No']
        values.append(line)
    return ['Yes']



def get_input_lines():
    line = input()
    N = int(line)
    lines = list()
    lines.append(line)
    for _ in range(N):
        lines.append(input())
    return lines



def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['4', 'hoge', 'english', 'hoge', 'enigma']
        lines_export = ['No']
    if pattern == 2:
        lines_input = ['9', 'basic', 'c', 'cpp', 'php', 'python', 'nadesico', 'ocaml', 'lua', 'assembly']
        lines_export = ['Yes']
    if pattern == 3:
        lines_input = ['8', 'a', 'aa', 'aaa', 'aaaa', 'aaaaa', 'aaaaaa', 'aaa', 'aaaaaaa']
        lines_export = ['No']
    if pattern == 4:
        lines_input = ['3', 'abc', 'arc', 'agc']
        lines_export = ['No']
    return lines_input, lines_export



def get_mode():
    import sys
    args = sys.argv
    if len(args) == 1:
        mode = 0
    else:
        mode = int(args[1])
    return mode



def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines()
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    
    
    
    
    
    
    
    
    
    
    



if __name__ == '__main__':
    main()

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] or W.count(W[i]) != 1:
        ans = "No"

print(ans)

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

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

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

Solution (Python):
n = int(input())
x = [input() for i in range(n)]
l = []
foot = x[0][0]
ans = 0
for i in range(len(x)):
  if foot != x[i][0]:
    ans = 1
  foot = x[i][-1]
  if x[i] in l:
    ans = 1
  l.append(x[i])
if ans == 1:
  print('No')
else:
  print('Yes')

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

last_letter = w[0][0]
for word in w:
    if word in words_hist:
        print('No')
        exit()
    if not word.startswith(last_letter):
        print('No')
        exit()
    
    words_hist.add(word)
    last_letter = word[-1]

print('Yes')

Solution (Python):

import sys

N = int(input())
w =[]
for i in range(N):
    x =input().strip()
    w.append(x)


from collections import Counter
c =Counter(w)
c_k =list(c.values())
ans =""
if max(c_k) >=2:
    print("No")
    sys.exit()
    
ans ="Yes"
for i in range(N-1):
    if w[i][-1] != w[i+1][0]:
        ans ="No"
        break
print(ans)

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

Solution (Python):
n = int(input())
l = [input() for _ in range(n)]
flg1 = len(l) == len(set(l))
flg2 = all(l[i][-1] == l[i + 1][0] for i in range(n - 1))
print(["No", "Yes"][flg1 and flg2])

Solution (Python):

import sys
N = int(input())
word = [] 

w = input()
word.append(w)

for i in range(N-1):
    w = input()
    if word[-1][-1] != w[0]:
        print("No")
        sys.exit()
    for j in word:
        if j == w:
            print("No")
            sys.exit()
    word.append(w)
    
print("Yes")

Solution (Python):
import sys

n = int(input())
l = [input() for i in range(n)]
for i in range(n):
  if i > 0:
    if l[i-1][-1] != l[i][0]:
      print("No")
      sys.exit()
  if l.count(l[i]) > 1:
    print("No")
    sys.exit()
print("Yes")

Solution (Python):
N = int(input())
W = [input()]
ans = 1
for i in range(N-1):
    new_word = input()
    if new_word in W:
        ans = 0
        break
    W.append(new_word)
    if W[i][-1]!=W[i+1][0]:
        ans = 0
        break

for j in range(N-i-2):
    input()

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

Solution (Python):


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

flag = 1

if len(w) != len(set(w)):
    flag = 0


moji = w[0][-1]
for i in w[1:]:
    
    if moji != i[0]:
        flag = 0
    moji = i[-1]

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

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

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

    print('Yes')


if __name__ == '__main__':
    main()

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

Solution (Python):
N = int(input())
a_word = input()
words = [a_word]
judge = 'Yes'
for i in range(N-1):
  b_word = input()
  if not a_word[-1] == b_word[0]:
    judge = 'No'   
  elif b_word in words:
    judge = 'No'
  words.append(b_word)
  a_word = b_word

print(judge)

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

words_list = [input()]
c = 1

for i in range(1,N):
    new_word = input()
    words_list.append(new_word)
    
    if new_word in words_list[:i-1]:
        c += 0
        
    elif new_word[0] != words_list[i-1][len(words_list[i-1])-1]:
        c += 0
        
    else:
        c += 1

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