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

def check() :
    siri = W[0][-1]
    double = [W[0]]
    for i in range(1, N) :
        if W[i] in double :
           return 'No'
        double.append(W[i])
        
        atama = W[i][0]
        if atama != siri :
            return 'No'
            
        siri = W[i][-1]
    return 'Yes'
    
print(check())

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

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

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

print("Yes")

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

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

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

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

Solution (Python):



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


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


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

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

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

Solution (Python):
n=int(input())
S=[input() for _ in range(n)]
ans=1
for i in range(n-1):
    if (S[i][-1] == S[i+1][0])*(S[i+1] not in S[:i+1]):
        ans += 1
print("Yes" if ans == n else "No")

Solution (Python):
def slove():
    import sys
    import collections
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    lstr = ""
    d = collections.defaultdict(int)
    for i in range(n):
        s = str(input().rstrip('\n'))
        if s not in d:
            d[s]
            if lstr == "" or lstr == s[0]:
                lstr = s[-1]
            else:
                print("No")
                exit()
        else:
            print("No")
            exit()
    print("Yes")


if __name__ == '__main__':
    slove()

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

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

word = []
end = S[0][0]
for i in range(n):
	val = S[i]
	if val[0] != end or val in word:
		print ("No")
		exit()
	else:
		end = val[-1]
		word.append(val)
print ("Yes")

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

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

word_set = set()
W = str(input())
word_set.add(W)
last_char = W[len(W)-1]


for i in range(N-1):
  W = str(input())
  
  if W in word_set:
    print("No")
    break
  elif W[0]!=last_char:
    print("No")
    break
  
  last_char = W[len(W)-1]
  word_set.add(W)
else:
  print("Yes")

Solution (Python):
def slove():
    import sys
    import collections
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    d = collections.defaultdict(int)
    s = [str(input().rstrip('\n')) for _ in range(n)]
    for i in range(n):
        if i != 0:
            if s[i][0] != s[i-1][-1] or s[i] in d:
                print("No")
                exit()
        d[s[i]]
    print("Yes")


if __name__ == '__main__':
    slove()

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

for i in range(N):
  W = str(input())
  if i > 0:
    if y != W[0]:
      print("No")
      quit()
  y = W[-1]
  if W in S:
    print("No")
    quit()
  else:
    S.append(W)  
    
print("Yes")

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

check = True
for i in range(N-1):
    s = W[i]
    s_1 = W[i+1]
    if s[-1] == s_1[0]:
        continue
    else:
        check = False
        break
for i in range(N):
    if W[i] in w_dic:
        check = False
        break
    else:
        w_dic[W[i]] = 1
if check:
    print('Yes')
else:
    print('No')

Solution (Python):
from collections import defaultdict
 
N = int(input())
W = [input().strip() for _ in range(N)]
 
dic = defaultdict(int)
 
for i in range(N):
  if i == 0:
    tmp = W[i][-1]
    dic[W[i]] += 1
  else:
    if tmp != W[i][0] or dic[W[i]]:
      print("No")
      break
    else:
      dic[W[i]] += 1
      tmp = W[i][-1]
else:
  print("Yes")

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

W = [input()]
s = W[0][-1]
flag = True

for i in range(n-1):
    w = input()
    if w[0] != s:
        flag = False
        break
    W.append(w)
    s = w[-1]

if len(set(W)) != n:
    flag = False

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

Solution (Python):
n = int(input())
w = [input()]
ans = "Yes"
for _ in range(n-1):
    _w = input()
    if _w in w or w[-1][-1] != _w[0]:
        ans = "No"
    w.append(_w)

print(ans)

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

Solution (Python):
n=int(input())
s=set()
wp=input()
s.add(wp)

f=True
for i in range(n-1):
  wn=input()
  if wp[-1]!=wn[0]:
    f=False
  elif wn in s:
    f=False
  wp=wn
  s.add(wn)

print('Yes' if f==True else 'No')

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

if len(set(W))!=N:
    f=0

for i in range(N-1):
    if W[i][-1] != W[i+1][0]:
        f=0
        break

print('NYoe s'[f::2])

Solution (Python):
def valid(words):
  used = set()
  last = ""

  for w in words:
    if w in used:
      return False
    if last != "" and last[-1] != w[0]:
      return False
    last = w
    used.add(w)

  return True


n = int(input())
words = [input() for _ in range(n)]
print("Yes" if valid(words) else "No")

Solution (Python):
N = int(input())
x = set()
last = ""

for i in range(N):
    W = input()
    if W in x:
        print("No")
        exit()
    elif i != 0:
        if last != W[0]:
            print("No")
            exit()

    last = W[-1]
    x.add(W)
print("Yes")

Solution (Python):
N = int(input())
ary = []
s = 'Yes'
for i in range(N):
  w = input()
  if w in ary:
    s = 'No'
    break
  if len(ary) > 0 and w[0] != ary[-1][-1]:
    s = 'No'
    break
  ary.append(w)
    
print(s)

Solution (Python):

n=int(input())
l = []
last = ""
for i in range(n):
    s = input()
    if i == 0:
        last = s[-1]
        l.append(s)
        continue
    if last != s[0]:
        print("No")
        exit()
    last = s[-1]
    l.append(s)

if len(l) != len(set(l)):
    print("No")
else:
    print("Yes")

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

for i in range(n-1):
  if w[i][-1]!=w[i+1][0]:
    flag*=0
  else:
    flag*=1

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

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

Solution (Python):
n = int(input())
w = [str(input()) for _ in range(n)]
set_w = set(w)
checker = True
if len(set_w) == n:
    for i in range(n-1):
        if w[i][-1] == w[i+1][0]:
            continue
        else:
            checker = False
            break
    if checker:
        print('Yes')
    else:
        print('No')
else:
    print('No')

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

if len(set(W)) < N:
    print("No")
    exit()

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

print("Yes")

Solution (Python):
n = int(input())
w = [0]*n
for i in range(n):
  w[i] = input()
for i in range(1,n):
  for j in range(i):
    if w[i] == w[j]:
      print('No')
      exit()
  if w[i][0] != w[i-1][-1]:
    print('No')
    exit()
print('Yes')

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

before=input()
words.append(before)
N=N-1

for i in range(N):
    s=input()
    if before[-1] != s[0]:
        flg=False
    words.append(s)
    before=s
if len(words) != len(set(words)):
    flg=False
print("Yes" if flg else "No")

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

before = "kt"

for i in range(N):
    tmp = input()
    tmp2 = list(tmp)

    if before != "kt":
        if tmp2[0] == before and tmp not in W:
            before = tmp2[-1]
            W.append(tmp)
            continue
        else:
            print("No")
            exit()
    else:
        before = tmp2[-1]
        W.append(tmp)

print("Yes")

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

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

W = [input() for _ in range(n)]



dict = {}

for i in range(n):
    if W[i] in dict:
        print("No")
        exit()
    else:
        dict[W[i]] = 1 
header = (list(W[0]))[0]
footer = (list(W[0]))[len(list(W[0]))-1]


for i in range(1,n):
    header = (list(W[i]))[0]
    if footer != header:
        print("No")
        exit()
    footer = (list(W[i]))[len(list(W[i]))-1]

print("Yes")

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

Solution (Python):
n=int(input())
said={}
ans="Yes"
s=input()
said[s]=1
pre=s
for _ in range(n-1):
    s=input()
    if s not in said:
        if pre[len(pre)-1] == s[0]:
            said[s]=1
            pre=s
        else:
            ans="No"
            break
    else:
        ans="No"
        break


print(ans)

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

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

Solution (Python):
n = int(input())
p = ''
d = {}
for _ in range(n):
  w = input()
  if p and p[-1] != w[0]:
    print('No')
    exit()
  if w in d:
    print('No')
    exit()
  p = w[-1]
  d[w] = 1
print('Yes')

Solution (Python):
def main():
    N = int(input())
    word_list=[input() for i in range(N)]
    already_list = []
    for i, word in enumerate(word_list):
        if(i==0):
            already_list.append(word)
            continue
        if(word not in already_list and word[0] == word_list[i-1][len(word_list[i-1])-1]):
            already_list.append(word)
        else:
            print('No')
            return
    print('Yes')




if __name__ == "__main__":
    main()

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

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

ans = "Yes"

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

print(ans)

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

Solution (Python):
import collections
n = int(input())
k = []
result=[]
for i in range(n):
    a = input()
    k.append(a)
ans = collections.Counter(k)
for i in range(1,n):
    if k[i-1][-1] == k[i][0] and ans.most_common()[0][1] == 1:
        result.append("1")
    else:
        result.append("0")
aim = collections.Counter(result)
if aim.most_common()[0][1] != n-1 or aim.most_common()[0][0] =='0':
    print('No')
else:
    print('Yes')

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

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

print("Yes")

Solution (Python):
def slove():
    import sys
    import collections
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    lw = ""
    d = collections.defaultdict(list)
    for i in range(n):
        w = str(input().rstrip('\n'))
        if lw != "":
            if w[0] != lw or w in d:
                print("No")
                exit()
        lw = w[-1]
        d[w]
    print("Yes")


if __name__ == '__main__':
    slove()

Solution (Python):
N = int(input())
words = set()
_w = input()
words.add(_w)
for _ in range(N-1):
    w = input()
    if w not in words and _w[-1] == w[0]:
        words.add(w)
        _w = w
        continue
    print('No')
    exit()
print('Yes')

Solution (Python):
N = int(input())
words = [input() for _ in range(N)]
s = set()
for i, word in enumerate(words):
    if word in s:
        print('No')
        exit()
    if i != 0:
        if words[i-1][-1] == word[0]:
            s.add(word)
        else:
            print('No')
            exit()
    else:
        s.add(word)
print('Yes')

Solution (Python):
N = int(input())
words = [input()]
ans = True
for i in range(1,N):
    tmp = input()
    if (tmp in words) or words[i-1][-1] != tmp[0]:
        ans = False
    words.append(tmp)
if ans:
    print('Yes')
else:
    print('No')

Solution (Python):

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

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

Solution (Python):
n = int(input())
w = input().split()
flag = 0
for i in range(1,n):
    w.append(input())
    if w[i-1][-1] == w[i][0] and w[i] not in w[:i]:
        pass
    else:
        flag += 1
print('Yes' if flag == 0 else 'No')

Solution (Python):
n=int(input())
a=[]
b=[]
for i in range(n):
      c=input()
      a.append(list(c))
      b.append(c)
      
if len(list(set(b))) != len(a):
      print('No')
      exit()

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

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

t=[]
last=A[0][0]
f=True
for a in A:
	if last==a[0] and a not in t:
		last=a[-1]
		t.append(a)
	else:
		f=False
print('Yes' if f else 'No')

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

Solution (Python):
N = int(input())
W = [input() for i in range(N)]
ans = True
for i in range(1, N):
    if W[i][0] != W[i-1][-1]:
        ans = False
for i in range(N):
    for j in range(i+1, N):
        if W[i] == W[j]:
            ans = False
if ans:
    print('Yes')
else:
    print('No')

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


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

    ans = "Yes"
    W = [input()[:-1]]
    for _ in range(N-1):
        w = input()[:-1]
        p = W[len(W)-1]
        if w in W or w[:1]!=p[-1:]:
            ans = "No"
            break
        W.append(w)
    
    print(ans)

if __name__ == '__main__':
    main()

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

for i in range(n-1):
    x=input()
    if x in list or x[0]!=list[-1][-1]:
        print('No')
        exit()
    list.append(x)
print('Yes')

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

check_list = []
for i in range(N):
    if word_list[i] in word_list[0:i] or word_list[i] in word_list[i + 1:]:
        print('No')
        break
    else:
        for i in range(N - 1):
            if word_list[i][-1] == word_list[i + 1][0]:
                pass
            else:
                print('No')
                break
        else:
            continue 
    break
else:
    print('Yes')

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

Solution (Python):
import sys

input = sys.stdin.readline


def main():
    n = int(input())
    w = [input().strip() for _ in range(n)]
    if len(w) == len(set(w)) and all([i[-1] == j[0] for i, j in zip(w[:-1], w[1:])]):
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()

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

flg = True
if len(l) != len(set(l)):
    flg = False


for i in range(len(l)-1):
    if l[i][-1] != l[i+1][0]:
        flg = False
        break

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

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

Solution (Python):
import sys
N,*W = map(str,open(0).read().split())
N = int(N)
for i in range(N-1):
    if list(W[i])[-1] != list(W[i+1])[0]:
        print("No")
        sys.exit()
if len(W) != len(set(W)):
    print("No")
    sys.exit()
print("Yes")

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

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

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

print("Yes")

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

Solution (Python):
def main():
  n=int(input())
  w=[]
  for _ in range(n):
    w.append(input())
  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")
    
main()

Solution (Python):
import os, sys, re, math

N = int(input())
flg = False
words = []
for _ in range(N):
    w = input()
    if w in words:
        flg = True
        break
    else:
        words.append(w)

prev = words[0]
cur = ''

if flg:
    print('No')
else:
    for i in range(1,len(words)):
        cur = words[i]
        if prev[-1] == cur[0]:
            prev = words[i]
        else:
            flg = True
            print('No')
            break
    if flg == False:
        print('Yes')

Solution (Python):
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n = ni()

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

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

print('Yes')

Solution (Python):
n = int(input())
s = set()
for i in range(n):
    w = input()
    c = len(s)
    s.add(w)
    if i > 0:
        if w0[len(w0)-1] != w[0] or c+1 != len(s):
            print("No")
            exit()
    w0 = w

print("Yes")

Solution (Python):
n = int(input())
result = True
ws = set()
last = ""
for a in range(n):
    w = input()
    top = w[0]
    if (a > 0):
        if (last != top):
            result = False
            break
    ws.add(w)
    last = w[len(w) - 1]
    
if (len(ws) != n):
    result = False

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

Solution (Python):
line = raw_input()
N = int(line)
W = [raw_input() for i in range(0, N)]
ret = True
if len(W) != len(set(W)):
    ret = False
else:
    last = W[0][0]
    for word in W:
        if last != word[0]:
            ret = False
            break
        last = word[-1]

print 'Yes' if ret else 'No'

Solution (Python):
import os, sys, re, math

N = int(input())
W = []

result = 'Yes'
for i in range(N):
    w = input()
    if W and (w in W or W[-1][-1] != w[0]):
        result = 'No'
        break
    W.append(w)

print (result)

Solution (Python):
N = int(input())
As = []
ng = False
for i in range(N):
    t = input()
    if As.count(t) or (As and As[-1][-1] != t[0]):
        ng = True
    As.append(t)
print('No' if ng else 'Yes')

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

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

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

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

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

Solution (Python):
from collections import defaultdict
if __name__ == '__main__':
    N = int(input())
    words = defaultdict(int)
    before = ''
    flag = True
    for n in range(N):
        s = str(input())
        if words[s] == 0:
            if n == 0 or before[-1] == s[0]:
                words[s] += 1
                before = s
            else:
                flag = False
                break
        else:
            flag = False
            break
    if flag:
        print('Yes')
    else:
        print('No')

Solution (Python):
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    W=[input() for _ in range(n)]
    for i in range(n):
        w=W.pop()
        if w in W:
            print("No")
            return
        if W:
            if not w[0]==W[-1][-1]:
                print("No")
                return
    print("Yes")
resolve()

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

ex_list = []
for i in range(N):
    if W[i] in ex_list:
        print('No')
        break
    elif i == 0 or (i > 0 and W[i-1][-1] == W[i][0]):
        ex_list.append(W[i])
        continue
    else:
        print('No')
        break
else:
    print('Yes')

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

else:
    print("No")

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

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

w_count = Counter(w)
if max(w_count.values()) > 1:
    print("No")
    exit()

for i in range(n - 1):
    tmp1, tmp2 = w[i][-1], w[i + 1][0]

    if tmp1 != tmp2:
        print("No")
        break

    if i == n - 2:
        print("Yes")

Solution (Python):
n = int(input())
words = []
before= input()
words.append(before)
flag = True
for _ in range(n-1):
  
  s = input()
  if before[-1] != s[0]:
    flag = False
  before = s
  words.append(s)

l = len(set(words))
if l != n:
  flag = False
if flag:
  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")
    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)]

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

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

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

ans = "Yes"
b = []
c = a[0][0]
for i in a:
    if c == i[0] and i not in b:
        c = i[-1]
        b.append(i)
    else:
        ans = "No"
        break

print(ans)

Solution (Python):
N = int(input())
a = input().strip()
ind = 0
hist = [a]
for _ in range(N-1):
    b = input().strip()
    if b in hist or a[-1]!=b[0]:
        ind = 1
        break
    hist.append(b)
    a = b
if ind==0:
    print("Yes")
else:
    print("No")

Solution (Python):
N = int(input())
L = []
flag = True
for i in range(N):
    new = input()
    if new in L:
        flag = False
        break
    if L != []:
        if L[-1][-1] != new[0]:
            flag = False
            break
    L.append(new)

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

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

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

Solution (Python):
N = int(input())
a = set()
lst = []
for i in range(N):
    s = input()
    a.add(s)
    lst.append(s)
if len(a) != N:
    print('No')
    exit()
for i in range(N-1):
    if lst[i][-1] == lst[i+1][0]:
        continue
    else:
        print('No')
        exit()
print('Yes')

Solution (Python):
n=int(input())
s=[input() for i in range(n)]
if len(s) != len(set(s)):
  print("No");exit()
for c,d in zip(s[0:],s[1:]):
  if c[-1] != d[0]:
    print("No");exit()
print("Yes")

Solution (Python):
n=int(input())
s=[input() for i in range(n)]
if (len(s) != len(set(s))):
  print("No");exit()
for c,d in zip(s[0:],s[1:]):
  if c[-1] != d[0]:
    print("No");exit()
print("Yes")

Solution (Python):
n=int(input())
s=[input() for i in range(n)]
if (len(s) == len(set(s))) == 0:
  print("No")
  exit()
for c,d in zip(s[0:],s[1:]):

  if c[-1] == d[0]:
    pass
  else:
    print("No")
    exit()
print("Yes")

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

if len(set(List))!=len(List):
  print("No")

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

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

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

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

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

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

Solution (Python):
N = int(input())
A = [input() for _ in range(N)]
b=A[0][0]
for i in range(N):
  if b==A[i][0]:
    b=A[i][-1]
  else:
    print("No")
    exit()
A.sort()
for i in range(N-1):
  if A[i]==A[i+1]:
    print("No")
    exit()
print("Yes")

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

Solution (Python):
import sys


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

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

Solution (Python):
n=int(input())
word=[]
flag=0

for i in range(n):
  word.append(list(input()))
  
for i in range(n-1):
  if word[i][-1]!=word[i+1][0]:
    flag+=1
  word[i]=''.join(word[i])
word[-1]=''.join(word[-1])

for i in range(n):
  count=0
  for k in range(n):
    if word[i]==word[k]:
      count+=1
  if count>=2:
    flag+=1
    
if flag==0:
  print('Yes')
else:
  print('No')

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

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

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

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

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