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() for _ in range(N)]
li = [W[0]]
for i in range(1,N):
  if W[i][0] != W[i-1][-1]:
    print("No")
    sys.exit()
  if W[i] in li:
    print("No")
    sys.exit()
  li.append(W[i])
print("Yes")

Solution (Python):
import sys
_,*W = open(0).read().split()

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

s = W[0][0]
for w in W:
    if s != w[0]:
        print('No')
        sys.exit()
    s = w[-1]

print('Yes')

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

Solution (Python):
def main():
    has_said = set()
    n = int(input())
    last = ""
    for i in range(n):
        w = input()
        if i > 0 and (w[0] != last or w in has_said):
            print("No")
            break
        last = w[-1]
        has_said.add(w)
    else:
        print("Yes")


if __name__ == '__main__':
    main()

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

Solution (Python):
N = int(input())
C = {}
flag = 0
for i in range(N):
    W = input().strip()
    if W not in C:
        C[W] = 0
    C[W] += 1
    if i==0:
        a = W
    else:
        if W[0]!=a[-1]:
            flag = 1
        a = W
if len(C)<N or flag==1:
    print("No")
else:
    print("Yes")

Solution (Python):
import sys

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

n = ini()
w = [ins() for _ in range(n)]


def solve():
    p = set()
    p.add(w[0])
    for i in range(1, n):
        if w[i] in p:
            return False
        if w[i - 1][-1] != w[i][0]:
            return False
        p.add(w[i])
    return True


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

Solution (Python):

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


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

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(readline())
w = read().decode().rstrip().split()

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

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

prev = s_list[0][-1]
ans = "Yes"
tmp = [s_list[0]]
for s in s_list[1:]:

    if s in tmp:
        ans = "No"
        break

    if s[0] != prev:
        ans = "No"
        break

    tmp.append(s)
    prev = s[-1]
print(ans)

Solution (Python):

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

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

print(ans)

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

s = []
for _ in range(n):
    s.append(input())

it = iter(s)
for p, ne in zip(it, it):
    if p[-1] != ne[0]:
        print("No")
        exit()

if s[-2][-1] != s[-1][0]:
    print("No")
    exit()

if len(set(s)) == n:
    print("Yes")
else:
    print("No")

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

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

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

Solution (Python):
N = int(input())
L = [input() for _ in range(N)]
print("Yes" if L.count(L[0])==1 and all(L.count(L[i])==1 \
                  and L[i][0]==L[i-1][-1] for i in range(1, N)) else "No")

Solution (Python):
N = int(input())
first = input()
seen = {first}
for _ in range(N-1):
    w = input()
    if w[0] != first[-1]:
        print("No")
        break
    if w in seen:
        print("No")
        break
    seen.add(w)
    first = w
else:
    print("Yes")

Solution (Python):
import math
def main():
  n = int(input())
  w = [input() for i in range(n)]
  flg=0
  
  for i in range(1,n):
    if w[i][0]!=w[i-1][len(w[i-1])-1]:
      flg=1
      break

  if flg==1 or len(set(w))!=n:
    print("No")
  else:
    print("Yes")
main()

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


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

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

Solution (Python):
from collections import Counter
import sys
N = int(input())
lst = [str(input()) for _ in range(N)]

c = Counter(lst)
for i in c:
    if lst.count(i) > 1:
        print('No')
        sys.exit()

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

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

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

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

Solution (Python):
n,*ww = open(0).read().split()

import sys
words = set()
prev = None
for w in ww:
    if w in words:
        print('No')
        sys.exit()
    words.add(w)
    
    if prev and prev[-1] != w[0]:
        print('No')
        sys.exit()
    prev = w
print('Yes')

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

for n in range(N):
    s=input()
    S.append(s)
S_set=set(S)

ans='Yes'
if len(S_set) != N:
    ans='No'

for n in range(N-1):
    n_ = n+1
    s_0=S[n][-1]
    s_1=S[n_][0]
    
    if s_0 != s_1:
        ans='No'
print(ans)

Solution (Python):
n = int(input())
l = []
flag = 0
for i in range(n):
    w = input()
    l.append(w)
for k in range(1,n):
    if  l[k-1][-1] != l[k][0]:
        flag =1
        break

    for j in range(k):
        if l[k] == l[j]:
            flag = 1
            break
        
if(flag == 1):
    print('No')
else:
    print('Yes')

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

ans = True
for i in range(1, n):
    if w[i][0] != w[i-1][len(w[i-1])-1]:
        ans = False
        break
    else:
        for j in range(0, i):
            if w[j] == w[i]:
                ans = False
                break

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

Solution (Python):
a = True
n = int(input())
p = input()
s = {p}
for i in range(n-1):
    c = input()
    if p[-1] != c[0] or c in s:
        a = False
    else:
        p = c
        s.add(p)
if a:
    print('Yes')
else:
    print('No')

Solution (Python):
n=int(input())
w=[]
j=0
for i in range(n):
    k=input()
    w.append(k)
for i in range(n):
    if i!=0:
        a=w[i]
        b=w[i-1]
        if a[0]!=b[len(b)-1]:
            print("No")
            j+=1
            break

    if w.count(w[i])>1:
        print("No")
        j+=1
        break
if j==0:
    print("Yes")

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

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

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

if not f:
    print("No")
else:
    print("Yes")

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

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

Solution (Python):
N = int(input())
Word = [input()]
Flag = True
for T in range(0,N-1):
    New = input()
    if Word[-1][-1]==New[0] and New not in Word:
        Word.append(New)
    else:
        Flag = False
        break
if Flag: print('Yes')
else: print('No')

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

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

Solution (Python):
N = int(input())
S = [input() for _ in range(N)]
d = dict()
prev = ''
for i, s in enumerate(S):
    if i > 0 and s[0] != prev:
        print('No')
        break
    if d.get(s, 0) > 0:
        print('No')
        break
    d[s] = 1
    prev = s[-1]
else:
    print('Yes')

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

Solution (Python):
import sys
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')
        sys.exit()
    else:
        for j in range(i + 1):
            if W[j] == W[i + 1]:
                print('No')
                sys.exit()
print('Yes')

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

cond = True
used = set()
last = lw[0][0]
for w in lw:
    if w in used or last != w[0]:
        cond = False
        break
    used.add(w)
    last = w[-1]

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

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

Solution (Python):
N=int(input())
H=input()
word=[]
word.append(H)
for i in range(N-1):
  S=input()
  if S in word:
    print('No')
    exit()
  else:
    if H[-1]==S[0]:
      H=S
      word.append(H)
    else:
      print('No')
      exit()
print('Yes')

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

Solution (Python):
def main():
    w=[input() for _ in range(int(input()))]
    sumi=set()
    p=w[0][0]
    for s in w:
        if s in sumi or p != s[0]:
            print("No")
            return
        sumi.add(s)
        p = s[-1]
    print("Yes")
    
if __name__ == "__main__":
    main()

Solution (Python):
def f(words):
	seen = set([words[0]])
	p = words[0]
	for w in words[1:]:
		if w in seen or p[-1] != w[0]: return False
		p = w
		seen.add(w)
	return True

print 'Yes' if f([raw_input() for _ in range(int(raw_input()))]) else 'No'

Solution (Python):
N = int(input())
ans = 'Yes'
a = set()
pre = ''
for i in range(N):
    word = input()
    if not word in a and (pre == word[0] or pre == '') and ans == 'Yes':
        ans = 'Yes'
        a.add(word)
        pre = word[-1]
    else:
        ans = 'No'
print(ans)

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

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

print(ans)

Solution (Python):









import sys
input = sys.stdin.readline

N = int(input())
S = []
for i in range(N):
    S.append(input().rstrip('\n'))

if len(set(S)) != N:
    print("No")
    exit()
else:
    for i in range(1, N):
        if S[i - 1][-1] != S[i][0]:
            print("No")
            exit()

print("Yes")

Solution (Python):
import sys

stdin = sys.stdin

ni = lambda: int(ns())
ns = lambda: stdin.readline().rstrip()
na = lambda: list(map(int, stdin.readline().split()))


N = ni()
W = []
w = input()
l = w[-1]
W.append(w)
for i in range(N-1):
    w = input()
    if w in W:
        print('No')
        break

    if not w[0] == l:
        print('No')
        break

    l = w[-1]
    W.append(w)
else:
    print('Yes')

Solution (Python):
N = int(input())
word_bank = set()
last_char = ''

for n in range(N):
  new_word = input()
  if new_word in word_bank:
    print('No')
    exit(0)
  elif n != 0 and new_word[0] != last_char:
    print('No')
    exit(0)
  else:
    word_bank.add(new_word)
    last_char = new_word[-1]

print('Yes')

Solution (Python):
N = int(input())
words = []
for _ in range(N):
    words.append(input())
print('Yes' if all(words[i].startswith(words[i-1][-1]) for i in range(1, N)) and len(set(words)) == N else 'No')

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

w = [None] * N
for i in range(N):
    w[i] = input()

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

Solution (Python):

n, *w = open(0).read().split()
s = set(w)
if len(s) != len(w):
    print("No")
    exit()
for i in range(1, int(n)):
    if w[i][0] != w[i - 1][-1]:
        print("No")
        exit()
print("Yes")

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

before = array_word[0]
for I in array_word[1:]:
    if before[-1] == I[0] and array_word.count(I) == 1:
        before = I
        continue 
    else:
        print('No')
        sys.exit()
print('Yes')

Solution (Python):
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n = ri()
li = [rr() for _ in range(n)]
if len(set(li)) != n:
  print('No')
  exit()
else:
  for i in range(n-1):
    if li[i][-1] != li[i+1][0]:
      print('No')
      exit()
  else:
    print('Yes')

Solution (Python):
n=int(input())
w=input()
tmp=w[-1:]
d={}
d[w]=1
for i in range(1,n):
    w=input()
    if w not in d:
        d[w]=1
    else:
        print("No")
        exit()
    if w[0]==tmp:
        tmp=w[-1:]
    else:
        print("No")
        exit()
print("Yes")

Solution (Python):
dic = {}
N = int(input())
pre = input()
dic[pre] = 0
flag = True
for i in range(N-1):
    s = input()
    if list(pre)[len(pre)-1]!=list(s)[0]:
        flag=False

    if s in dic:
        flag=False
    else:
        dic[s]=0

    pre = s

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

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

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

Solution (Python):
n = int(input())
pw = None
s = set()
ans = 'Yes'
for _ in range(n):
    w = input().rstrip()
    if pw is not None:
        if w[0] != pw[-1] or w in s:
            ans = 'No'
    pw = w
    s.add(w)
print(ans)

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

ans = "Yes"

if len(set(w)) != len(w):
    ans = "No"
for i in range(n-1):
    if w[i][-1] != w[i+1][0]:
        ans = "No"
        break

print(ans)

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

if len(w) != len(set(w)):
    ans = 'No'
else:
    for i in w:
        if i[0] != p:
            ans = 'No'
            break
        else:
            p = i[-1]
    else:
        ans = 'Yes'

print(ans)

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

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

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

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

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

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

Solution (Python):

import sys
from collections import deque, defaultdict
from math import sqrt, factorial





def solve():
    n = int(input())
    w = set()
    s = input()
    w.add(s)
    ans = 1
    for _ in range(n-1):
        c = input()
        if (s[-1] != c[0] or c in w): ans = 0
        w.add(c)
        s = c
    if ans:
        print("Yes")
    else:
        print("No")

t = 1

for case in range(1,t+1):
    ans = solve()




"""

4
1 2
2 4
1 3
3
2 2 4
4 5 6

6
1 2
2 3
3 4
4 5
4 6
3
3 5 6
2 17 31 5 11

"""

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

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

W=set()
s="*"
F=True
for _ in range(N):
    H=input()
    if s=="*" or (s==H[0] and H not in W):
        W.add(H)
        s=H[-1]
    else:
        F=False
if F:
    print("Yes")
else:
    print("No")

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




if '__main__' == __name__:
    resolve()

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

l = []

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

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

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

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())
l = []
pre_c = None
ans = True
for _ in range(n):
    w = input()
    

    if w in l:
        ans = False
        break
    if not(pre_c is None or pre_c == w[0]):
        ans = False
        break

    l.append(w)
    pre_c = w[-1]

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

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

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

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

Solution (Python):
n = int(input())
W = [input() for i in range(n)]
flg = 1

Word = [W[0]]
for i in range(1,n):
    s = W[i-1]
    t = W[i]
    
    if(s[-1] != t[0] or t in Word): 
        flg = 0
        break
    Word.append(t)
    
if (flg): print("Yes")
else: print("No")

Solution (Python):
n = int(input())
W = [input() for i in range(n)]
flg = 1

Word = [W[0]]
for i in range(1,n):
    s = W[i-1]
    t = W[i]
    
    if(s[-1] != t[0] or t in Word): 
        flg = 0
        break
    Word.append(t)
    
if (flg): print("Yes")
else: print("No")

Solution (Python):
N = int(input())
dic = dict()
for i in range(N):
    S = input()
    if S in dic:
        dic[S] += 1
    else:
        dic[S] = 1
    Start  = S[0]
    if i != 0:
        if Start != End or dic[S] > 1:
            print("No")
            exit()
    End = S[len(S)-1]
print("Yes")

Solution (Python):
N = int(input())
W = [input() for n in range(N)]
a = "Yes"

for n in range(N-1):
  if W[n][-1]!=W[n+1][0] or W.count(W[n])!=1:
    a = "No"

print(a)

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

list_0=[]

for i in range(N):
  W = str(input())
  if W in list_0:
    print('No')
    exit()
  else:
    list_0.append(W)

for _ in range(N-1):
  if list_0[_][len(list_0[_])-1]==list_0[_+1][0]:
    pass
  else:
    print('No')
    exit()

print('Yes')

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

used_word = []
cher = ""
for _ in range(N):
    W = input()
    if not cher:
        used_word.append(W)
        cher = W[-1]
    else:
        if W[0] == cher and W not in used_word:
            used_word.append(W)
            cher = W[-1]
        else:
            print("No")
            break
else:
    print("Yes")

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

is_ok = True

if len(W) != len(set(W)):
    is_ok = False
else:
    for i, w in enumerate(W):
        if i > 0:
            if before_w != w[0]:
                is_ok = False
                break
        
        before_w = w[-1]
    
if is_ok:
    print("Yes")
else:
    print("No")

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

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

Solution (Python):
list_w = []
flag = 0
N = int(input())
for i in range(N):
    W = input()
    list_w.append(W)
    if i >=1 and list_w[-2][-1] != W[0]:
        flag = 1
if len(set(list_w)) != N or flag == 1:
    print('No')
else:
    print('Yes')

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


if __name__ == '__main__':
    solve()

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

lis = [""]
ans = "Yes"
for i in range(1,N+1):
    W = input()
    if i == 1:
        pass
    else:
        if ((W in lis) == False) and (W[0] == lis[i-1][-1]):
            pass
        else:
            ans = "No"
    lis.append(W)

print(ans)

Solution (Python):
n=int(input())
check=[]
s=input()
check.append(s)
ans=0
for i in range(n-1):
  keep=s[-1]
  s=input()
  if keep != s[0]:
    ans=1
  if str(s) in check:
    ans = 1
  else:
    check.append(s)
print(["Yes","No"][ans])

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

Solution (Python):
N = int(input())
A = [input() for _ in range(N)]
now = A[0]
Done = set()
Done.add(A[0])
for a in A[1:]:
    if a in Done:
        print('No')
        exit()
    if now[-1] == a[0]:
        now = a
        Done.add(a)
    else:
        print('No')
        exit()
print('Yes')

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

is_ok = (len(set(W)) == N)
for i in range(1, N):
    if W[i - 1][-1] != W[i][0]:
        is_ok = False

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

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

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

Solution (Python):
n = int(input())
apple = []
count = 0
for _ in range(n):
    apple.append(str(input()))
for i in range(1,n):
    if apple[i-1][-1] == apple[i][0] and apple[i-1] not in apple[i:]:
        pass
    else:
        count = 1
        break
if apple[-1] not in apple[:-1] and count == 0 and apple[-2][-1]==apple[-1][0]:
    print("Yes")
else:
    print("No")

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



a = set()
a.add(w[0])
ck = 0
for i in range(1,n):
  if w[i] in a:
    break
  else:
    a.add(w[i])
  
  if w[i][0] != w[i-1][-1]:
    break

else:
  ck = 1

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

Solution (Python):
def resolve():
    N = int(input())
    W = [input() for _ in range(N)]
    if len(set(W)) != N:
        print("No")
        return
    l = W[0][0]
    for w in W:
        if w[0] != l:
            print("No")
            return
        l = w[-1]
    print("Yes")

resolve()

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

Solution (Python):
from collections import defaultdict
d = defaultdict(int)
N=int(input())
s=input()
d[s]+=1
x=s[-1]
for i in range(N-1):
  s=input()
  if s[0]==x and d[s]==0:
    x=s[-1]
    d[s]+=1
  else:
    print('No')
    exit(0)
print('Yes')

Solution (Python):
n = int(input())
words = [input() for i in range(n)]
mae = ''
ans = 'Yes'

for i in range(n):
    if i == 0:
        word = words[0]
        leng = len(word)
        mae = word[leng-1]
    else:
        word = words[i]
        if mae != word[0:1] or words.count(word) >= 2:
            ans = 'No'
            break
        else:
            leng = len(word)
            mae = word[leng-1]

print(ans)

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

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

Solution (Python):
n = int(input())
w = [input() for _ in range(n)]
e = w[0][-1]
cnt = 1

for i in range(1, n):
    if w[i][0] == e:
        cnt += 1
        e = w[i][-1]

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

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

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

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

l = [l]

ans = 0
for i in range(n-1):
    x = str(input())
    if x not in l and l[i][-1]==x[0]:
        l.append(x)
        continue
    else:
        ans = -10000000000
        break
if ans == 0:
    print('Yes')
else:
    print('No')

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

for i in range(N):
    s = input()
    if i == 0:
        end_w = s[0]

    if s in lis:
        print("No")
        exit()
    else:
        if s[0] == end_w:
            lis.append(s)
            end_w = s[-1]
        else:
            print("No")
            exit()

print("Yes")

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

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

Solution (Python):
n = int(input())
seen = set()
for i in range(n):
    s = input()
    if i > 0 and s[0] != pre or s in seen:
        print('No')
        break
    seen.add(s)
    pre = s[-1]
else:
    print('Yes')

Solution (Python):
n = int(input())
word_list = []
flag = True
for i in range(n):
    word = input()
    if word_list == []:
        word_list.append(word)
    else:
        if (word_list[-1][-1] == word[0]) and (word not in word_list):
            word_list.append(word)
        else:
            flag = False
            break
            
if flag:
    print('Yes')
else:
    print('No')

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

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