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())
used=[]
start=input()
used.append(start)
flag=0
for i in range(n-1):
    tmp=input()
    if start[-1]!=tmp[0] or tmp in used:
        flag=1
        break
    used.append(tmp)
    start=tmp

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

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

ans = "Yes"
check = []
head = W[0][0]
for word in W:
	if (word[0] == head) and (not (word in check)):
		check.append(word)
		head = word[-1]
	else:
		ans = "No"
		break

print(ans)

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

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

W = set()
S = input()
W.add(S)
for _ in range(N - 1):
    C = input()
    if S[-1] != C[0] or (C in W):
        print("No")
        break
    S = C
    W.add(C)
else:
    print("Yes")

Solution (Python):
N = int(input())
before = ""
all = set()
check = True
for i in range(N):
    s = input()
    if i == 0:
        before = s
        all.add(s)
    else:
        if before[-1] == s[0]:
            before = s
            all.add(s)
        else:
            check = False
if check:
    print("Yes" if len(all)==N else "No")
else:
    print("No")

Solution (Python):
N = int(input())
W = [0 for i in range(N)]
for i in range(N):
    W[i] = input()
shiritori = True
S = set(W)
if len(S) != N:
    shiritori = False


for i in range(N-1):
    length = len(W[i])
    if W[i][length-1] != W[i+1][0]:
        shiritori = False

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

Solution (Python):
n=int(input())
flg=True
se=set()
for i in range(n):
  s=input()
  if s in se:
    flg=False
  se.add(s)
  if not i:
    f,b=s[0],s[-1]
  else:
    if s[0]!=b:
      flg=False
    f,b=s[0],s[-1]
if flg:
  print("Yes")
else:
  print("No")

Solution (Python):



def judge(ws):
    used_words = {ws[0]}
    n = len(ws)
    for i in range(1, n):
        if ws[i] in used_words or ws[i - 1][-1] != ws[i][0]:
            return False
        used_words.add(ws[i])
    return True


def main():
    ws = [input() for _ in range(int(input()))]
    print("Yes" if judge(ws) else "No")


if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
flag = 0
l = []
for i in range(n):
    w = input()
    
    if i != 0:
        if (w[0] != before[-1]) or (w in l):
            flag = 1

    l.append(w)
    before = w
    


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

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

ans = 0

for i in range(n):
    W = input()
    s = set(w)
    if W in s:
        ans = 1
    w.append(W)


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


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

Solution (Python):
N = int(input())
ans = True
said = []
for i in range(N):
    word = input()
    if word in said:
        ans = False
        break
    if i != 0:
        if said[i - 1][-1] != word[0]:
            ans = False
            break
    said.append(word)
if ans:
    print("Yes")
else:
    print("No")

Solution (Python):


def main():
    n = int(input())
    arry = [input() for _ in range(n)]
    for i in range(1, n):
        if arry[i-1][-1] != arry[i][0] or len(arry) != len(set(arry)):
            print('No')
            exit()
    print('Yes')

if __name__ == '__main__':
    main()

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

Solution (Python):
import sys

n=int(input())
wordList=[input()]
for _ in range(n-1):
    word =input()
    if word in wordList:
        print("No")
        sys.exit()
    elif wordList[-1][-1]!=word[0]:
        print("No")
        sys.exit()
    wordList.append(word)
print("Yes")

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

l = w[-1]
a = []

a.append(w)

f_no = False

for n in range(N-1):
    w = input()
    if l != w[0]:
        f_no = True
    a.append(w)
    l = w[-1]

if f_no == False:
    if len(a) == len(list(set(a))):
        print('Yes')
    else:
        print('No')
else:
    print('No')

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

Solution (Python):
import numpy as np
import math





N = int(input())

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

    if new in W:
        
        print('No')
        exit(0)
    W.append(new)

    if n > 0:
        first = W[n][0]
        if first is not last:
            
            print('No')
            exit(0)
        
    last = new[len(W[n]) - 1]
    

print('Yes')

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

def judge(n):
    preword = input()
    words=[preword]

    for _ in range(n-1):
        word = input()
        if word[0] != preword[-1]: return "No"
        elif word in words: return "No"
        else:
            words.append(word)
            preword=word
    return "Yes"
        
print(judge(n))

Solution (Python):
N = int(input())
W = input()
L = []
L.append(W)
last = W[-1]
ans = 'Yes'
for _ in range(N-1):
    w = input()
    if w in L:
        ans = 'No'
    if last == w[0]:
        last = w[-1]
        L.append(w)
    else:
        ans = 'No'
print(ans)

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

if len(W) != len(set(W)):
    print('No')
    quit()

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

Solution (Python):

def main():
    n = int(input())
    words = []
    for i in range(n):
        words.append(input())
    if len(words) != len(set(words)):
        print('No')
        return
    for w1, w2 in zip(words, words[1:]):
        if w1[-1] != w2[0]:
            print('No')
            return
    print('Yes')


if __name__ == '__main__':
    main()

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

isok = True
w = input()
W.add(w)
back = w[-1]
for i in range(N-1):
    w = input()
    if w in W or w[0]!=back: isok=False
    W.add(w)
    back = w[-1]
    
if isok:
    print("Yes")
else:
    print("No")

Solution (Python):
from collections import Counter
n = int(input())
w = [input() for i in range(n)]
c = Counter(w).most_common()
if c[0][1]!=1: ans = "No"
else:
	last,ans = w[0][-1],"Yes"
	for i in w[1:]:
		if last!=i[0]: ans = "No"
		last = i[-1]
print(ans)

Solution (Python):



import array
from bisect import *
from collections import *
import fractions
import heapq 
from itertools import *
import math
import random
import re
import string
import sys

N = int(input())
prev = None
ok = True
seen = set()
for n in range(N):
    w = input()
    if prev is None:
        prev = w
    else:
        if prev[-1] != w[0]:
            ok = False
    if w in seen:
        ok = False
    seen.add(w)
    prev = w
if ok:
    print('Yes')
else:
    print('No')

Solution (Python):
N = int(input())
m = {}
prv = "!"
ok = True
for i in range(N):
    s = input()
    
    try:
        m[s]
        ok = False
    except:
        m[s] = True
        
        if prv == "!" or prv[-1] == s[0]:
            prv = s
        else:
            ok = False

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

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

W_list = []
flag=True
before = ""
for i in range(N):
    W = raw_input()
    if W in W_list:
        flag=False
    if i!=0 and W[0]!=before:
        flag=False
    W_list.append(W)
    before = W[-1]

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

Solution (Python):
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
n=i1()
from collections import defaultdict
d = defaultdict(int)
s="Yes"
for i in range(n):
 x=input()
 if i>0 and y[-1]!=x[0]:
   s="No"
 d[x]+=1
 if d[x]>1:
   s="No"
 y=x
print(s)

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

Solution (Python):
N = int(input())
rule = True
pre = input()
used = [pre]
for i in range(N-1):
    temp = input()
    if pre[-1] != temp[0] or temp in used:
        rule = False
    used.append(temp)
    pre = temp

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

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

Flag = True
words = []
for i in range(N):
    word = str(input())
    if not i==0:
        if word[0] != l:
            Flag =  False
        if word in words:
            Flag = False
    l = word[-1]
    words.append(word)

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

Solution (Python):
n = int(input())
rec = []
flag = True
t = input()
pre = t[-1]
rec.append(t)
for i in range(1, n):
    s = input()
    if s in rec:
        flag = False
    elif s[0] != pre:
        flag = False
    else:
        rec.append(s)
        pre = s[-1]

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

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

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

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


for i in range(n-1):
  if s[i][-1] != s[i+1][0]:
    count = 1
    break

s.sort()
for i in range(n-1):
  if s[i] == s[i+1]:
    count = 1

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

Solution (Python):
N = int(input())
W = [input() for _ in range(N)]
flag = True
x = W[0][-1]
for i in range(1, N):
    if x != W[i][0]:
        flag = False
        break
    x = W[i][-1]

if len(set(W)) != N:
    print("No")
elif flag == False:
    print("No")
else:
    print("Yes")

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

prev = ''
history = {}
for i in range(N):
  w = input()
  if w in history or (prev != '' and prev[-1] != w[0]):
    print('No')
    exit()
  history[w] = 1
  prev = w
print('Yes')

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

ans = True
words = []
wset = set()
for i in range(n):
    word = input()
    words.append(word)
    if word in wset:
        ans = False
    wset.add(word)

last = words[0]
for w in words[1:]:
    if last[-1] != w[0]:
        ans = False
        break
    last = w

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

Solution (Python):


INF = float('inf')


def inpl(): return list(map(int, input().split()))


N = int(input())

word = input()
S = [word]
judge = True
for _ in range(N - 1):
    t = word[-1]
    word = input()
    if word[0] != t or word in S:
        judge = False
        break
    S.append(word)

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

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


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

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

W = []
Se = set()
for i in range(N):
  st = input()
  W.append(st)
  Se.add(st)
  
if len(Se) != N:
  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())
ws = []
ans = 'Yes'
for _ in range(n):
    w = input()
    if w in ws:
        ans = 'No'
        break
    else:
        if len(ws)>0:
            if ws[-1][-1] == w[0]:
                pass
            else:
                ans = 'No'
                break    
        ws.append(w)
print(ans)

Solution (Python):
n=int(input())
w=[input() for i in range(n)]
setw=set(w)
if len(setw)!=len(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):
already = {}
n = int(input())
last = ''
for i in range(n):
  s = input()
  if (i != 0 and s[0] != last[-1]) or (s in already) :
    print('No')
    break
  last = s
  already[s] = 1
else:
  print('Yes')

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

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

cnt = 0

for i in range(1, N):
    if W[i][0] != W[i - 1][-1]:
        cnt = 1

W.sort()
for i in range(1, N):
    if W[i] == W[i - 1]:
        cnt = 1

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

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

def li(): return [int(x) for x in stdin.readline().split()]
def li_(): return [int(x)-1 for x in stdin.readline().split()]
def lf(): return [float(x) for x in stdin.readline().split()]
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(ns())
def nf(): return float(ns())

n = ni()

word = []
words = []
for _ in range(n):
    words.append(lc())
    
ok = True
for i in range(n-1):
    if words[i][-1] != words[i+1][0]:
        ok = False
        
for i in range(n):
    for j in range(i+1,n):
        if words[i] == words[j]:
            ok = False

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

Solution (Python):


if __name__ == '__main__':
    N = int(input())
    said_words = []

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

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

Solution (Python):
N = int(input())
W = input()
S = set([W])
e = W[-1]
for _ in range(N-1):
    W = input()
    if W[0] == e and not W in S:
        e = W[-1]
        S.add(W)
    else:
        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")
else:
    flag = 1
    for i in range(n-1):
        if w[i][-1] != w[i+1][0]:
            flag = 0
    
    if flag ==1:
        print("Yes")
    else:
        print("No")

Solution (Python):
N=int(input())
W=[input() for _ in[0]*N]
li=[]
for a, b in zip(W, W[1:]):
    if a in li or a[-1]!=b[0]:
        print('No')
        exit()
    li+=[a]
print('No'if W[-1]in li else 'Yes')

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

if not all([Ws.count(w) == 1 for w in Ws]):
    print('No')
else:
    f = True
    t = Ws[0][-1]
    for w in Ws[1:]:
        f &= w[0] == t
        t = w[-1]
    print('Yes' if f else 'No')

Solution (Python):
N=int(input())
said = set()
char = ""
flag = True
for i in range(N):
    word = input()
    if char != "" and word[0] != char:
        flag = False
    if word in said:
        flag = False
    said.add(word)
    char=word[len(word)-1]
if flag:
    print("Yes")
else:
    print("No")

Solution (Python):
def main():
    n = int(input())
    
    tmp = ""
    f = True
    st = []
    for i in range(n):
        w = input()
        st.append(w)
        if i > 0:
            if tmp[-1] == w[0]:
                pass
            else:
                f = False
        tmp = w
    if len(list(set(st))) != n:
        f = False
    
    print("Yes" if f else "No")

if __name__ == "__main__":
    main()

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

ans = 'Yes'
w = ws[0]
end = w[-1]
w_map = {w:1}
for i in range(1, n):
    w_next = ws[i]
    if not w_next in w_map.keys():
        w_map[w_next] = 1
    else:
        ans = 'No'
        break
    if w_next[0] != end:
        ans = 'No'
        break
    w = w_next
    end = w[-1]
print(ans)

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

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

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

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

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

for i in range(n):
    w[i] = input()
    if i > 0 and w[i-1][-1] != w[i][0]:
        print("No")
        exit()
    else:
        for j in range(i):
            if w[j] == w[i]:
                print("No")
                exit()
print("Yes")

Solution (Python):
N = int(input())
prev = input()
lst = [prev]
flg = True
for i in range(N-1):
    w = input()
    lst.append(w)
    if w[0] != prev[-1]:
        flg = False
    prev = w

lst.sort()
for i in range(N-1):
    if lst[i+1] == lst[i]:
        flg = False
        break

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

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

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

if N == len(set(W)):
    s = W[0]
    c = True
    for wi in W[1:]:
        if s[-1] != wi[0]:
            c = False
            break
        s = wi
    if c:
        print('Yes')
    else:
        print('No')
else:
    print('No')

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

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

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

Solution (Python):
'''input
9
basic
c
cpp
php
python
nadesico
ocaml
lua
assembly
'''
from sys import exit
s = set()
n = input()
arr = [raw_input().strip() for i in range(n)]
l = arr[0][-1]
s.add(arr[0])
for i in range(1,n):
	if arr[i][0] == l and (arr[i] not in s):
		s.add(arr[i])
		l = arr[i][-1]
	else:
		print "No"
		exit(0)
print "Yes"

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

from collections import Counter
counter = Counter(W).most_common()

Ans = "Yes"
if counter[0][1]>1:
    Ans = "No"
else:
    for i in range(N-1):
        if W[i][-1] != W[i+1][0]:
            Ans = "No"

print(Ans)

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

Solution (Python):


from collections import deque
import itertools as it
import sys
import math
import re

sys.setrecursionlimit(1000000)

N = input()
ls = []
m = {}
for i in range(N):
    S = raw_input()
    ls.append(S)
    m[S] = 1

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

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

print "Yes"

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

result = True

for i in range(1, N):
    if W[i-1][-1] != W[i][0]:
        result = False
        break
    if W[i] in W[:i]:
        result = False
        break

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

Solution (Python):
n=int(input())
dict1={}
flag=0
arr=[]
for i in range(n):
    s=str(input())
    if(i==0):
        dict1[s]=1
        arr.append(s)
    else:
        if(arr[-1][-1]!=s[0]):
            flag=1
        else:
            try:
                dict1[s]+=1
                flag=1
            except:
                KeyError
                dict1[s]=1
            arr.append(s)
if(flag==0):
    print("Yes")
else:
    print('No')

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

flag = 1
for i in range(n):
    oi = str(input())
    if oi in siritolist:
        flag = 0
        
    else:
        if len(siritolist) == 0:
            siritolist.append(oi)
        else:
            if list(siritolist[-1])[-1] == list(oi)[0]:
                siritolist.append(oi)
            else:
                flag = 0

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

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

used = [w[0]]
check = True
for i in range(1,n):
    if w[i] in used:
        check = False
        break
    if w[i-1][-1] != w[i][0]:
        check = False
        break
    else:
        used.append(w[i])
if check:
    print('Yes')
else:
    print('No')

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

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

print('Yes')

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

Solution (Python):
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import defaultdict
from bisect import bisect

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

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

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

Solution (Python):
na = lambda: list(map(int, input().split()))
n = int(input())
w = [input() for _ in range(n)]

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

Solution (Python):
N=int(input())
W=[input() for _ in range(N)]
Ws=len(list(set(W)))
if Ws!=len(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())
w = []
for i in range(0, n):
    w.append(input())

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

Solution (Python):
ret = "Yes"
n = input()
z = []
for i in xrange(n):
    s=raw_input()
    if z and z[-1][-1]!=s[0] or s in z:ret = "No"
    z.append(s)
print  ret

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

Solution (Python):


def main():
    N = int(input())
    pw = []
    for i in range(N):
        w = input().strip()
        if i > 0 and (w in pw or w[0] != pw[-1][-1]):
            return "No"
        pw.append(w)
    return "Yes"

print(main())

Solution (Python):
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())

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

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

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

Solution (Python):


n = int(input())
W = [input() for _ in range(n)]
dic = {}
for word in W:
    if word not in dic:
        dic[word] = True
    else:
        print('No')
        exit()
for i in range(n-1):
    if W[i][-1] != W[i+1][0]:
        print('No')
        exit()
print('Yes')

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

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

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

Solution (Python):
import sys
import math
import collections
import itertools
import array
import inspect


sys.setrecursionlimit(1000000)



def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))



def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


def lcm(n, m):
    return (n * m) // gcd(n, m)


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v



def wfs_d(D, N, K):
    """
    D: 隣接行列(距離付き)
    N: ノード数
    K: 始点ノード
    """

    dfk = [-1] * (N + 1)
    dfk[K] = 0

    cps = [(K, 0)]
    r = [False] * (N + 1)
    r[K] = True
    while len(cps) != 0:
        n_cps = []
        for cp, cd in cps:
            for i, dfcp in enumerate(D[cp]):
                if dfcp != -1 and not r[i]:
                    dfk[i] = cd + dfcp
                    n_cps.append((i, cd + dfcp))
                    r[i] = True

        cps = n_cps[:]

    return dfk



def dfs_d(v, pre, dist):
    """
    v:  現在のノード
    pre: １つ前のノード
    dist: 現在の距離

    以下は別途用意する
    D: 隣接リスト(行列ではない)
    D_dfs_d: dfs_d関数で用いる，始点ノードから見た距離リスト
    """

    global D
    global D_dfs_d

    D_dfs_d[v] = dist

    for next_v, d in D[v]:
        if next_v != pre:
            dfs_d(next_v, v, dist + d)

    return


def sigma(N):
    ans = 0
    for i in range(1, N + 1):
        ans += i
    return ans


def comb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result




dp = None


def main():
    N = int(input())
    S = [input() for _ in range(N)]

    if len(set(S)) != N:
        print("No")
        return

    i = 0
    while i < len(S) - 1:
        if S[i][-1] != S[i + 1][0]:
            print("No")
            return
        i += 1
    
    print("Yes")


main()

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

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**13
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-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 pf(s): return print(s, flush=True)


def main():
    n = I()
    ws = [S() for _ in range(n)]
    s = set(ws)
    if len(s) != n:
        return 'No'
    for i in range(n-1):
        if ws[i][-1] != ws[i+1][0]:
            return 'No'

    return 'Yes'


print(main())

Solution (Python):
N = input()
S = set()
last = '.'
for i in xrange(N):
    s = raw_input()
    if s in S:
        print "No"
        exit()
    if last != '.' and s[0] != last:
        print "No"
        exit()
    last = s[-1]
    S.add(s)
print "Yes"

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