Problem:
 Score : 200 points    Problem Statement Takahashi is practicing shiritori alone again today.  Shiritori is a game as follows:   In the first turn, a player announces any one word.  In the subsequent turns, a player announces a word that satisfies the following conditions:  That word is not announced before.  The first character of that word is the same as the last character of the last word announced.     In this game, he is practicing to announce as many words as possible in ten seconds.  You are given the number of words Takahashi announced, N , and the i -th word he announced, W_i , for each i . Determine if the rules of shiritori was observed, that is, every word announced by him satisfied the conditions.      Constraints  N is an integer satisfying 2 \leq N \leq 100 .  W_i is a string of length between 1 and 10 (inclusive) consisting of lowercase English letters.         Input Input is given from Standard Input in the following format:  N  W_1  W_2  :  W_N       Output If every word announced by Takahashi satisfied the conditions, print Yes ; otherwise, print No .        Sample Input 1 4
hoge
english
hoge
enigma      Sample Output 1 No  As hoge is announced multiple times, the rules of shiritori was not observed.       Sample Input 2 9
basic
c
cpp
php
python
nadesico
ocaml
lua
assembly      Sample Output 2 Yes       Sample Input 3 8
a
aa
aaa
aaaa
aaaaa
aaaaaa
aaa
aaaaaaa      Sample Output 3 No       Sample Input 4 3
abc
arc
agc      Sample Output 4 No

Solution (Python):
N = int(input())
W = [input() for _ in range(N)]
words = [''] * N
for i in range(N):
    if i == 0:
        words[i] = W[i]
        continue
    if (W[i] in words) or (W[i - 1][-1] != W[i][0]):
        print('No')
        break
    words[i] = W[i]
else:
    print('Yes')

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

lis = []
for _ in range(n):
    lis.append(input())
    
if len(lis) != len(set(lis)):
    print("No")
    exit()
 
tmp = lis[0][-1]
for i in range(1,n):
    if lis[i][:1] != tmp:
        print("No")
        exit()
    else:
        tmp = lis[i][-1]

print("Yes")

Solution (Python):
n=int(input())
w=[]
flag=True
for i in range(n):
    w.append(input())
    
for i in range(n-1):
    if w[i][-1]!=w[i+1][0]:
        
        flag=False

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

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

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

resolve()

Solution (Python):
def main():
    N = int(input())
    A = [input()]
    for i in range(1, N):
        W = input()
        if A[-1][-1] == W[0]:
            for j in range(i):
                if A[j] == W:
                    print("No")
                    return
            A.append(W)
        else:
            print("No")
            return
    print("Yes")

main()

Solution (Python):
def actual(n, W):
    
    if len(set(W)) != len(W):
        return 'No'

    for i in range(len(W) - 1):
        word_now, word_next = W[i], W[i + 1]

        tail = word_now[-1]
        head = word_next[0]

        if tail != head:
            return 'No'

    return 'Yes'

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

print(actual(N, W))

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

already = [W[0]]
out='Yes'
for i in range(1,N):
    if W[i-1][-1] != W[i][0]:
        out='No'
        break
    elif W[i] in already:
        out='No'
        break
    already.append(W[i])

print(out)

Solution (Python):
n = int(input())
wordlist = []
for i in range(n):
    word = str(input())
    if word in wordlist:
        print('No')
        exit()
    if wordlist and wordlist[-1][-1] != word[0]:
        print('No')
        exit()
    wordlist.append(word)
print('Yes')

Solution (Python):
N=int(input())
ok=True
W2=input()
lis=[W2]
for i in range(N-1):
    W=W2
    W2=input()
    if W2 in lis:
        ok=False
        break
    lis.append(W2)
    if(W2[0]!=W[len(W)-1]):
        ok=False
        break
if(ok):
    print("Yes")
else:
    print("No")

Solution (Python):






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





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

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

if len(w) != len(set(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())
w = []
for i in range(n):
    w.append(input())
ok = True
for i in range(n-1):
    sz = len(w[i])
    if w[i][sz-1] != w[i+1][0]: ok = False
for i in range(n):
    for j in range(n):
        if i != j and w[i] == w[j]:
            ok = False
if ok: print('Yes')
else: print('No')

Solution (Python):
if __name__ == '__main__':
    n = int(input())
    now =""
    list=[]
    flag =True

    for i in range(n):
        s =input()
        if now =="":
            now=s
            list.append(s)
        elif now[len(now)-1] != s[0] or s in list:
            flag=False
            break
        else:
            now=s
            list.append(s)
    if flag:
        print("Yes")
    else:
        print("No")

Solution (Python):
N=int(input())
A=[]
for _ in range(N):
    W=input()
    if W in A:
        print('No')
        exit()
    else:
        A.append(W)

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

Solution (Python):
n = int(input())
ws = [str(input()) for i in range(n)]
t = ws[0][0]
for w in ws:
  if ws.count(w) > 1:
    print('No')
    break
  if t[-1] != w[0]:
    print('No')
    break
  else:
    t = w
    n-=1
if n == 0:
  print('Yes')

Solution (Python):
def f(l):
  prev = l[0][0]
  memo = []
  for i in range(len(l)):
    next = l[i]
    if next[0] != prev or next in memo:
      return "No"
    prev = next[-1]
    memo.append(next)
  return "Yes"

N = int(input())
l = [input() for _ in range(N)]
print(f(l))

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

Solution (Python):
n=int(input())
l=[input() for _ in range(n)]
b=l[0][-1]
for w in l[1:]:
    if l.count(w)>1 or not w[0]==b:
        print('No')
        exit()
    b=w[-1]
print('Yes')

Solution (Python):
def resolve():
    N = int(input())
    W = []
    for _ in range(N):
        w = input()
        W.append(w)
    ans = [W[0]]
    for i in range(N-1):
        if ans.count(W[i+1]) != 0 or ans[i][-1] != W[i+1][0]:
            print("No")
            exit()
        else:
            ans.append(W[i+1])
    print("Yes")
resolve()

Solution (Python):
import math
from collections import deque
from collections import defaultdict


def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def combmod(n,r,mod):
	return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
	r=copyQueue(q)
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): 
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): 
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} 
def bitArr(n):
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): 
			k = i-a*j
			if k%b==0:
				return i
	return -1
def copyQueue(q):
	nq = queue.Queue()
	n = q.qsize()
	for i in range(n):
		x = q.get()
		q.put(x)
		nq.put(x)
	return nq
def get_sieve_of_eratosthenes(n):
	
	data = [0,0,0]
	for i in range(3,n+1,2):
		data.append(i)
		data.append(0)
	for i in range(len(data)):
		interval = data[i]
		if interval!=0:
			for j in range(i+interval,n-1,interval):
				data[j] = 0
	
	ans = data[:]
	return ans

n = readInt()
d = defaultdict(int)
p="0"
for i in range(n):
	x = input()
	if p[-1]!=x[0]:
		if p!="0":
			print("No")
			exit()
	d[x]+=1
	p = x

for i in d:
	if d[i]>1:
		print("No")
		exit()

print("Yes")

Solution (Python):
def mi():
    return map(int, input().split())

def main():
    N = int(input())
    W = [input() for _ in range(N)]
    if len(set(W)) != N:
        print('No')
        return
    for i in range(N-1):
        if W[i][-1] != W[i+1][0]:
            print('No')
            return
    print('Yes')

if __name__ == '__main__':
    main()

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

Solution (Python):
n = int(input())
w = [input() for i in range(n)]
if all(n == 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)]
x = False
if n == len(set(w)):
    if all(w[i-1][-1] == w[i][0] for i in range(1,n)):
        x = True
print('Yes' if x else 'No')

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

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

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

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

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

for i in range(1, N):
    if W[i] in word or W[i][0] != W[i-1][-1]:
        print('No')
        exit()
    word.append(W[i])

print('Yes')

Solution (Python):
N = int(input())
said = []
Wnow = input()
said.append(Wnow)

for i in range(N-1):
  Wnxt = input()
  if Wnow[-1] != Wnxt[0]:
    print('No')
    exit()
  if Wnxt in said:
    print('No')
    exit()
  said.append(Wnxt)
  Wnow = Wnxt
  
print('Yes')

Solution (Python):
import sys, math, itertools, collections, bisect 
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') 
inf = float('inf') ;mod = 10**9+7 
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n = int(input())
words = []
chk = True
for i in range(n):
    w = input()
    if i == 0:
        next = w[-1]
        words.append(w)
    else:
        if w[0] != next:
            chk = False
            words.append(w)
        else:
            if w in words:
                chk = False
                words.append(w)
            else:
                next = w[-1]
                words.append(w)
if chk == True:
    print("Yes")
else:
    print("No")

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

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

Solution (Python):
N = int(input())
Already = []
W = input()
Already.append(W)
prevWord = W
flag = True
for i in range(N-1):
    W = input()
    for j in Already:
        if j == W:
            flag = False

    if W[0] != prevWord[-1]:
        flag = False
    
    Already.append(W)
    prevWord = W

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

Solution (Python):
n = int(input())
st = set([])

tail = ''
for i in range(n):
    w = input()
    if w in st:
        print('No')
        break
    if i != 0 and w[0] != tail:
        print('No')
        break
    st.add(w)
    tail = w[-1]
else:
    print('Yes')

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

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

Solution (Python):
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

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

s = W[0][-1]

ok = True
used = set()
used.add(W[0])
for w in W[1:]:
    if s != w[0] or w in used:
        ok = False

    s = w[-1]
    used.add(w)

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

Solution (Python):
N=int(input())
B=list()
B.append(input())
ans='Yes'
for i in range(N-1):
    tmp=input()
    if tmp in B:
        ans='No'
    if tmp[0]!=B[i][-1]:
        ans='No'
    B.append(tmp)
print(ans)

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

used = {s}
ex = s[-1]

for _ in range(n-1):
  s = input()
  if s in used or s[0] != ex:
    print('No')
    break
  ex = s[-1]
  used.add(s)
else:
  print('Yes')

Solution (Python):
n=int(input())
s=set()
w=input()
s.add(w)
tmp=w[-1]
can=True
for i in range(n-1):
    w=input()
    if w in s:
        can=False
    s.add(w)
    if w[0]==tmp:
        tmp=w[-1]
    else:
        can=False
if can:
    print('Yes')
else:
    print('No')

Solution (Python):
n = int(input())
words = []
for i in range(n):
  words.append(input())
words_set = list(set(words))
ans = 'Yes'
if len(words) == len(words_set):
  b = words[0][-1]
  for i in range(1, n):
    if b == words[i][0]:
      b = words[i][-1]
    else:
      ans = 'No'
      break
else:
  ans = 'No'
print(ans)

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

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

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

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

frag='Yes'
for i in range(n):
  if a.count(a[i])!=1:
    frag='No'
    break
for i in range(n-1):
  if a[i][-1]!=a[i+1][0]:
    frag='No'
    break
    
print(frag)

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

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

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

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

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

wordset = set()

for i, word in enumerate(W):
    if i == 0:
        wordset.add(word)
        continue
    
    if word in wordset or word[0] != W[i - 1][-1]:
        print("No")
        break

    wordset.add(word)
else:
    print("Yes")

Solution (Python):


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

word = set()
word.add(W[0])
ans = 'Yes'
for i in range(1, N):
    if W[i] in word:
        ans = 'No'
        break
    if W[i-1][-1] != W[i][0]:
        ans = 'No'
        break
    word.add(W[i])

print(ans)

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

if len(W) != len(set(W)):
    print('No')
else:
    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 = [str(input()) for _ in range(n)]

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

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

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

if len(W) ==  len(set(W)) and flag:
    print('Yes')
else:
    print('No')

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

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

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

for w in range(len(Ws)):
    if Ws.count(Ws[w])>=2:
        print("No")
        exit()
        
for x in range (1,len(Ws)):
    if Ws[x][0] != Ws[x-1][-1]:
        print("No")
        exit()

print("Yes")

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

out=False
w=set([])
tmp=input()
end=tmp[-1]
w.add(tmp)

for i in range(N-1):
  tmp=input()
  if end!=tmp[0]:
    out=True
  end=tmp[-1]
  w.add(tmp)

if out or len(w)!=N:
  print("No")
else:
  print("Yes")

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

Solution (Python):
import sys

N = int(input())
W = [0]*N
for i in range(N):
    W[i] = input()
tail = W[0][-1]
past = [W[0]]
for i in range(1,N):
    head = W[i][0]
    if tail == head and not (W[i] in past):
        tail = W[i][-1]
        past.append(W[i])
    else:
        print('No')
        sys.exit()
print('Yes')

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


def solve(lis):
	if len(lis) != len(set(lis)):
		return False

	for i in range(N-1):
		if lis[i][-1] != lis[i+1][0]:
			return False

	return True

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

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

Solution (Python):
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate, product, combinations_with_replacement
import sys
import bisect
import string
import math
import time


def I(): return int(input())
def S(): return input()
def MI(): return map(int, input().split())
def MS(): return map(str, input().split())
def LI(): return [int(i) for i in input().split()]
def LI_(): return [int(i)-1 for i in input().split()]
def StoI(): return [ord(i)-97 for i in input()]
def ItoS(nn): return chr(nn+97)
def input(): return sys.stdin.readline().rstrip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def print_matrix(mat):
    for i in range(len(mat)):
        print(*['IINF' if v == IINF else "{:0=4}".format(v) for v in mat[i]])


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**19
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
show_flg = False



def main():
    N = I()
    w = []
    wc = set()

    for i in range(N):
        w.append(S())
        if w[i] in wc:
            print('No')
            return
        wc.add(w[i])

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

    print('Yes')

if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
W =[ input()]
a = 'Yes'

for i in range(1,N):
    k = input()
    W.append(k)
    if W[-2][-1]!=k[0] or len(set(W))!=(i+1):
        a = 'No'
        break

print(a)

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

Solution (Python):
n=int(input())
w=[input() for i 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())
W = [input() for _ in range(N)]
used = []
ans = "Yes"

used.append(W[0])

for x in range(N-1):
    if W[x][-1] != W[x+1][0]:
        
        ans = "No"
        break
    if W[x+1] in used:
        ans = "No"
        break
    else:
        used.append(W[x+1])

print(ans)

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()


def main():
    N = int(input())
    flag = True
    pre = input()
    done = {pre}
    for _ in range(N - 1):
        now = input()
        if now[0] != pre[-1] or now in done:
            flag = False
        pre = now
        done.add(pre)
    if flag: print("Yes")
    else: print("No")

if __name__ == "__main__":
    main()

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


s_ = input()
s_set = set([s_])

ans = 'Yes'

for _ in range(N-1):
    s = input()
    if s in s_set:
        ans = 'No'
    if s[0] != s_[-1]:
        ans = 'No'
    s_set.add(s)
    s_ = s

print(ans)

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

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

if len(S)==N:
  print("Yes")

Solution (Python):
N = int(input())
out = "Yes"
S = input()
L = []

L.append(S)
for i in range(N-1):
    T = input()
    if T in L:
        out = "No"
    if T[0]!=S[-1]:
        out = "No"
    S = T
    L.append(S)
print(out)

Solution (Python):
n=int(input())
w=[input() for _ in range(n)]
f=True
for i in range(1,n):
	if w[i-1][-1] == w[i][0]:
		f=True
	else:
		f=False
		break
if f==False:
	f=False
elif len(list(set(w))) == len(w):
	f=True
else:
	f=False
if f:
	print('Yes')
else:
	print('No')

Solution (Python):
n=int(input())
w=[input() for _ in range(n)]
f=True
for i in range(1,n):
	if w[i-1][-1] == w[i][0]:
		f=True
	else:
		f=False
		break
if f==False:
	f=False
elif len(list(set(w))) == len(w):
	f=True
else:
	f=False
if f:
	print('Yes')
else:
	print('No')

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

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

Solution (Python):
def resolve():
	n = int(input())
	ws = [input() for _ in range(n)]
	cnt = []
	for w in ws:
		if w in cnt:
			print('No')
			return
		if len(cnt) and cnt[-1][-1] != w[0]:
			print('No')
			return
		cnt.append(w)
	print('Yes')
resolve()

Solution (Python):
N = int(input())
ans = "Yes"
appeared_words = [input()]
for _ in range(N - 1):
    curr_word = input()
    if appeared_words[-1][-1] != curr_word[0] or curr_word in appeared_words:
        ans = "No"
    appeared_words.append(curr_word)
print(ans)

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

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

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

    print("Yes")

Solution (Python):
n=int(input())
lis=[input()]
ok=True
for i in range(n-1):
    a=input()
    if a in lis:
        ok=False
        break
    if lis[-1][-1]!=a[0]:
        ok=False
        break
    lis.append(a)
if ok:
    print("Yes")
else:
    print("No")

Solution (Python):
N = int(input())
W = {}
last=""
flg = True

w =[]

for i in range(N):
    w.append(str(input()))
    
cnt=0
for i in w:
    
    if i in W:
        flg = False
        break
    else:
        W[i] = 1
        
    if cnt !=0:
        if i[0] == last:
            last = i[-1]
        else:
            flg = False
            break
    else:
        last = i[-1]
            
    cnt+=1
        
if(flg == True):
    print("Yes")
else:
    print("No")

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

Solution (Python):

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


before = W[0]
for i in range(1, N):
    if W[i][0] != before[-1] or W[i] in W[:i]:
        print("No")
        exit(0)
    before = W[i]
print("Yes")

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

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

check = 0
i = 0
for i in range(len(ll)-1):
    if ll[i] in ll[i+1:]:
        check = 1
    if ll[i][len(ll[i])-1] != ll[i+1][0]:
        check = 1

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

Solution (Python):
N = int(input())
W = [input() for _ in range(N)]
if len(set(W)) != N:
  print('No')
  exit()
else:
  w = W.pop(0)
  r = w[-1]
  for w in W:
    if r == w[0]:
      r = w[-1]
    else:
      print('No')
      exit()

print('Yes')

Solution (Python):
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]

from collections import defaultdict 


N = ii()
S = [input() for _ in range(N)]
d = defaultdict()
d[S[0]] = 1
for i in range(1, N):
    if S[i] in d.keys():
        print('No')
        exit()
    d[S[i]] = 1
    if S[i][0] != S[i-1][-1]:
        print('No')
        exit()
print('Yes')

Solution (Python):
def resolve():
    n=int(input())
    w=[input() for _ in range(n)]
    chk=[]
    chk.append(w[0])
    ans='Yes'
    for i in range(1,n):
        if w[i-1][-1]!=w[i][0] or (w[i] in chk):
            ans='No'
            break
        chk.append(w[i])
    print(ans)

if __name__ == '__main__':
    resolve()

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

w = [0]*n
used = []

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


if(w[n-1] not in used):
  print("Yes")
else:
  print("No")

Solution (Python):
N = int(input())
words = set()
before = ''
now = ''
ans = 'Yes'
for i in range(N):
    now = input()
    if i == 0:
        words.add(now)
        before = now
    elif now not in words and before[-1] == now[0]:
        words.add(now)
        before = now
    else:
        ans = 'No'
        break
print(ans)

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

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



www = "YYY"
for i in range(N-1):
    if S[i][-1] != S[i+1][0]:
        www = "fuck"

qqq = "ZZZ"
S.sort()
for i in range(N-1):
    if S[i] == S[i+1]:
        qqq = "bich"

if www == "YYY" and qqq == "ZZZ":
    print("Yes")
else:
    print("No")

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



www = "YYY"
for i in range(N-1):
    if S[i][-1] != S[i+1][0]:
        www = "fuck"

qqq = "ZZZ"
S.sort()
for i in range(N-1):
    if S[i] == S[i+1]:
        qqq = "bich"

if www == "YYY" and qqq == "ZZZ":
    print("Yes")
else:
    print("No")

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

jdg = 'Yes'
if len(set(w)) != len(w):
    jdg = 'No'
    print(jdg)
    exit()

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

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

Solution (Python):
import sys

def dupchk(seq):
  return len(seq) != len(set(seq))
arrw = []

N = int(input())
for i in range(0,N):
  W = str(input())
  arrw.append(W)

if dupchk(arrw) == False:
  for i in range(0,N-1):
    if arrw[i][-1] != arrw[i+1][0]:
      print("No")
      sys.exit()
  print("Yes")
else:
  print("No")