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 = input()
a = []
for i in range(n):
	a.append(raw_input())
for i in range(1, n):
	if a[i - 1][-1] != a[i][0]:
		print 'No'
		exit()
if len(set(a)) != n:
	print 'No'
	exit()
print 'Yes'

Solution (Python):
import sys

n=int(input())
w=[]
flag=True
for i in range(n):
    w+=[input()]
if(n!=len(set(w))):
    print('No')
    sys.exit()

f=w[0][0]
e=w[0][-1]
for i in range(1,n):
    if(e==w[i][0]):
        e=w[i][-1]
        continue
    else:
        flag=False
        break
    
if(flag):print('Yes')
else:print('No')

Solution (Python):
import sys
n=int(input())
sp=input()
l=set()
for _ in range(n-1):
    sn=input()
    if (sn in l) or (sp[-1]!=sn[0]):
        print('No')
        sys.exit()
    l.add(sp)
    sp=sn
print('Yes')

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

w1 = input()
L.append(w1)
for i in range(N - 1):
	w2 = input()
	if L.count(w2) == 1:
		judge = "No"
		break
	elif w1[-1] != w2[0]:
		judge = "No"
		break
	else:
		L.append(w2)
		w1 = w2

print(judge)

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

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

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

endOneWord = W[0][0]

for i in range(N):
    
    if(W.count(W[i]) > 1):
        print("No")
        exit()

    
    if(endOneWord != W[i][0]):
        print("No")
        exit()

    endOneWord = W[i][-1]

print("Yes")

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

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

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

Solution (Python):
import sys
n=int(input())
word=[]
word.append('０')
for i in range(1,n+1):
    word.append(input())
    for j in range(0,i):
        if word[j]==word[i]:
            print('No')
            sys.exit()
        else:
            j+=1
    if (i>1)& (word[i-1][len(word[i-1])-1]!=word[i][0]):
        print('No')
        sys.exit()

print('Yes')

Solution (Python):
import sys

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

for i in range(n):
    for j in range(i):
        if w[i] == w[j]:
            print('No')
            sys.exit()
    
    if i != 0:
        if w[i-1][len(w[i-1]) - 1] != w[i][0]:
            print('No')
            sys.exit()

print('Yes')

Solution (Python):
N = int(input())
W = ['']*N
ans = True
for i in range(N):
    W[i] = input()
    if i >= 1 and W[i-1][-1] != W[i][0]:
        ans = False
        
if len(set(W)) != len(W):
    ans = False

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

Solution (Python):



def get_line():
    return input()


def get_tokens():
    return get_line().split()


def get_ints():
    return [int(_) for _ in get_tokens()]


def main():
    n, = get_ints()
    w = []
    for i in range(n):
        v = get_line()
        w.append(v)

    s = set()
    ok = True
    s.add(w[0])
    last_v = w[0]
    for i in range(1, n):
        v = w[i]
        if v[0] != last_v[-1]:
            ok = False
        if v in s:
            ok = False
        s.add(v)
        last_v = v

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


if __name__ == '__main__':
    main()

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

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

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

x = 0

for i in range(n-1):
	if w[i][len(w[i])-1] != w[i+1][0] or w.count(w[i])!=1:
		x +=1
if x==0:
	print("Yes")
else:
	print("No")

Solution (Python):
import sys

c=[]
N=int(input())
word = [input() for l in range(N)]






for i in range(0,N-1):
    letter1=list(word[i])

    letter2=list(word[i+1])


    if letter1[-1]==letter2[0]:

        continue
    else:
        print("No")
        sys.exit()

for i in range(N):
    for j in range(N):

        if i==j:
            continue
        elif word[i]==word[j]:
            print("No")
            sys.exit()
print("Yes")

Solution (Python):

N=int(input())
W=[]
flag=0
for i in range(N):
    W.append(input())
for i in range(N-1):
    if W[i][-1]!=W[i+1][0]:
        flag=1
        break
if len(set(W))!=N:
    flag=1
if flag==1:
    print('No')
else:
    print('Yes')

Solution (Python):

n = int(input())
li = []
for i in range(n):
    li.append(list(input()))
for j in range(n-1):
    if li[j][-1] == li[j+1][0]:
        for k in range(j):
            if li[j] == li[k] or li[-1] == li[k]:
                print('No')
                exit()
    else:
        print('No')
        exit()
print('Yes')

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

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

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())
siritori_list = list()
for i in range(n):
    siritori_list.append(input())
for ii in range(n):
    word = siritori_list.pop(0)
    if siritori_list:
        if not(word[-1] == siritori_list[0][0]) or word in siritori_list:
            print("No")
            break
else:
    print("Yes")

Solution (Python):
N = int(input())
L =[]
count = 0
for i in range(N):
    Str = str(input())
    L.append(Str)

for i in range(N):
    for k in range(N):
        if L[i] == L[k] and i != k:
            count += 1
            break

for i in range(N):
        if i < N-1:
            if L[i][len(L[i])-1] != L[i+1][0]:
                count += 1


if count > 0:
    print("No")
else:
    print("Yes")

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

import collections

for i in range(n):
    if i < n-1:
        if w[i][-1] == w[i+1][0]:
            a = a
        else:
            a = 0

c = collections.Counter(w)
if c.most_common()[0][1] > 1:
    a = 0
else:
    a = a

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

Solution (Python):
import sys

N = int(input())

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

ret = "Yes"

dict = {}
for w in W:
    if w in dict:
        dict[w] += 1
        if dict[w] >= 2:
            
            ret = "No"
    else:
        dict[w] = 1


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

print(ret)

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

flag = "Yes"

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

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

Solution (Python):
shi_num = int(input())
words = [input() for _ in range(shi_num)]
result = [words[0]]
last_alph = words[0][-1]
for word in words[1:]:
    if (word not in result) and word[0] == last_alph:
        last_alph = word[-1]
        result.append(word)
    else:
        break

if len(result) == shi_num:
    print('Yes')
else:
    print('No')

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

if len(set(W)) != 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())

lastch = ''
answer = 'Yes'
words = []
for i in range(n):
    word = list(input())
    words.append(''.join(word))
    if lastch != word[0] and i != 0:
        answer = 'No'
    lastch = word[-1]

if len(set(words)) != len(words):
    answer = 'No'

print(answer)

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

w = []

for i in range(n):
    w.append(list(input()))



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

print("Yes")

Solution (Python):
N = int(input())
words = list(input() for _ in range(N))
done = []
for w in words:
  if len(done) == 0:
    done.append(w)
  else:
    if w in done or (done[-1])[-1] != w[0]:
      print('No')
      exit()
    else:
      done.append(w)
print('Yes')

Solution (Python):
def solution(w):
    pre = { }
    cur = w[0]
    pre[cur] = True
    for i in xrange(1, len(w)):
        if cur[-1] != w[i][0]:
            return False
        cur = w[i]
        if cur in pre:
            return False
        pre[cur] = True
    return True

def main():
    n = int(raw_input().strip())
    a = [raw_input().strip() for i in xrange(n)]
    if solution(a):
        print 'Yes'
    else:
        print 'No'

if __name__ == '__main__':
    main()

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

if(len(W) != len(set(W))):
    ans = "No"

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

print(ans)

Solution (Python):
n = int(input())
W = []
Hantei = True

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

for i in range(n):
    if W.count(W[i]) > 1:
        Hantei = False
        break

for i in range(n-1):
    if W[i][-1] != W[i+1][0]:
        Hantei = False

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

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

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

Solution (Python):
n=int(input())
w=[input() for _ in range(n)]
flag=0
for i in range(n):
  if flag==1:
    break
  for j in range(i+1,n):
    if w[i]==w[j]:
      flag=1
      break
for i in range(n-1):
  if flag==1:
    break
  if w[i][-1]!=w[i+1][0]:
    flag=1
    break
if flag==1:
  print("No")
else:
  print("Yes")

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


def f():
  used = set()
  prev = input()
  used.add(prev)
  for i in range(n-1):
    word = input()

    if word in used:
      return 'No'
    else:
      used.add(word)
    
    if word[0] == prev[-1]:
      prev = word
      continue
    else:
      return 'No'
    
  return 'Yes'

print(f())

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

Solution (Python):
import collections

N = int(input())

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


c = collections.Counter(W)

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

if (len(c.keys())) == N and (cnt == N-1):
    print("Yes")
else:
    print("No")

Solution (Python):
import sys
n = int(input())
dic=[]
for i in range(n):
    inp = input()
    if inp in dic:
        print("No")
        sys.exit()
    else:
        if len(dic) > 0 and inp[0] != dic[-1][-1]:
            print("No")
            sys.exit()
        dic += [inp]
print("Yes")

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

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

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

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

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

Solution (Python):
N = int(input())
L={}
for i in range(N):
    if i>0:
        prev = t[-1]
    t = input()
    if t in L:
        print("No")
        break
    L[t] = 1
    if i>0:
        if t[0] != prev:
            print ("No")
            break
            
else:
    print ("Yes")

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

Solution (Python):


n = int(input())

words = [str(input()) for _ in range(n)]

_word = str()
able = True

for index, word in enumerate(words):
    if index == 0:
        _word = word
    else:
        if ( word not in words[:index]) & (word[0] == _word[-1]):
            _word = word
        else:
            able = False
            break

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

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
if len(w) != len(set(w)):
  Flag = False
print("Yes" if Flag else "No")

Solution (Python):


def is_unique2(seq):
    seen = []
    unique_list = [x for x in seq if x not in seen and not seen.append(x)]
    return len(seq) == len(unique_list)

n=int(input())

line=[]

for i in range(n):
    line.append(list(input()))
    

flag=is_unique2(line)


for i in range(n-1):
    if line[i][-1]!=line[i+1][0]:
        flag=False  



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

Solution (Python):
N = int(input())
s = set()
pre = ""
flag = True
for i in range(N):
    w = input()
    if len(s) == 0:
        pre = w[-1]
        s.add(w)
        continue
    else:
        if w[0] != pre:
            flag = False
        elif w in s:
            flag = False
        else:
            pre = w[-1]
            s.add(w)

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

Solution (Python):
n=int(input())
lis=[]
for _ in range(n):
  lis+=[input()]
lis2=list(set(lis))
if len(lis2)!=n:
  print("No")
else:
  correct=True
  i=0
  while correct and i<n-1:
    if lis[i][-1]!=lis[i+1][0]:
      correct=False
    i+=1
  if correct:
    print("Yes")
  else:
    print("No")

Solution (Python):
N = int(input())
strings = [input()]
judge = 0
for i in range(1, N):
  final_character = strings[i - 1][-1]
  strings.append(input())
  initial_character = strings[i][0]
  if final_character == initial_character:
    continue
  else:
    judge = 1
    break

if len(strings) != len(set(strings)):
  judge = 1
  
if judge == 0:
  print("Yes")
else:
  print("No")

Solution (Python):

from sys import stdin
n = int(input())
W = stdin.read().splitlines()
if n != len(set(W)):
    print("No")
    exit()
for i in range(n-1):
    if W[i][-1] != W[i+1][0]:
        print("No")
        exit()
print("Yes")

Solution (Python):

from sys import stdin
s_list = []

n = int(stdin.readline().rstrip())

for i in range(n):
    s = stdin.readline().rstrip()
    if i == 0:
        s_shiri = s[-1]
        s_list.append(s)
    else:
        if s[0] == s_shiri:
            s_shiri = s[-1]
            s_list.append(s)
        else:
            print("No")
            exit()
            
s_check =  list(set(s_list))

if len(s_list) == len(s_check):
    print("Yes")
else:
    print("No")

Solution (Python):

n = int(input())
words = [ input() for _ in range(n) ]
ans = True
if len(set(words)) != n:
    ans = False
for i in range(n - 1):
    if words[i][-1] != words[i + 1][0]:
        ans = False
print(['No', 'Yes'][ans])

Solution (Python):
import sys

n = int(input())

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

Solution (Python):
def func():
    n = int(input())
    w = []
    for i in range(n):
        w.append(input())
    if len(set(w)) != n:
        print("No")
        return
        
    before = ""
    for wn in w:
        if before != "" and wn[0] != before[-1]:
            print("No")
            break
        before = wn
    else:
        print("Yes")
func()

Solution (Python):
"""
A,B = map(int,input().split())
answer = 'Yes'

if A%2 == 0:
	answer = 'No'
if B%2 == 0:
	answer = 'No'
	
print(answer)
"""

N = int(input())
W = list(map(str,[input() for i in range(N)]))

answer = 'Yes'


ww = set(W)
if len(W) != len(ww):
	answer = 'No'



for i in range(1,N):
	wnext = W[i]
	wforword = W[i-1]
	
	if wnext[0] != wforword[len(wforword)-1]:
		answer = 'No'

print(answer)

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

w = []

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

flag = True

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

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

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

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

res = 'Yes'
temp = []
tail = w[0][0]
for word in w:
    if word in temp:
        res = 'No'
        break

    temp.append(word)

    if tail != word[0]:
        res = 'No'
        break

    tail = word[-1]

print(res)

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

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

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

Solution (Python):
def shiritori(n, string_list):

    if len(string_list)!=len(set(string_list)):
        return False

    for i in range(1,n):
        if string_list[i-1][-1]!=string_list[i][0]:
            return False

    return True


def main():
    n = int(input())
    string_list = [input() for i  in range(n)]

    if shiritori(n, string_list):
        print('Yes')
    else :
        print('No')

if __name__=='__main__':
    main()

Solution (Python):
def solve():
    sameFlag = False
    N = int(input())
    words = []
    for i in range(N):
        s = input()
        if(s in words):
            sameFlag = True
        words.append(s)
    if(sameFlag):
        print('No')
        return
    current = ''
    for i in range(N):
        if(i != 0):
            if(words[i][0] != current):
                print('No')
                return
        current = words[i][-1]
    print('Yes')

solve()

Solution (Python):
n = int(input())
seq = []
seq.append(str(input()))
count = 1
while count < n:
  seq.append(str(input()))
  if seq[-2][-1] != seq[-1][0]:
    print("No")
    break
  count += 1
else:
  if len(seq) != len(set(seq)):
    print("No")
  else:
    print("Yes")

Solution (Python):
n = int(input())
words = []
 
for i in range(n):
  word = input()
  if i >= 1:
    if word in words or word[0] != words[-1][-1]:
      print('No')
      break
      
  words.append(word)

else:
  print('Yes')

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

for i, e in enumerate(A):
    if i == 0: continue
    if A.count(e) != 1 or A[i - 1][-1] != A[i][0]:
        print('No')
        break
    if i == n - 1:
        print('Yes')

Solution (Python):
w = []
c = int(raw_input())
for i in xrange(c):
    hatugen = raw_input()
    w.append(hatugen)
last = ''
first = ''
ruled = True
if len(set(w)) != len(w):
    ruled = False
for i in w:
    if i == w[0]:
        last = i[-1]
    else:
        first = i[0]
        if first == last:
            pass
        else:
            ruled = False
        last = i[-1]
print('Yes' if ruled else 'No')

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

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

def shiritori(s):
  if len(s) != len(set(s)):
    return False
  
  for i in range(n-1):
    if s[i][-1] != s[i+1][0]:
      return False
  
  return True

if __name__ == '__main__':
  if shiritori(s):
    print("Yes")
  else:
    print("No")

Solution (Python):
def si():

    n = int(input()) 
    tk = [input() for i in range(n)]
    tu = len(set(tk))
    l =[]
    k = []

 
        
    oo = 0


    while oo < tu:
        t = tk[oo]
        l.append(t[0])
        k.append(t[-1])
        oo += 1
        
    oo = 0


    while oo < tu-1:
        if k[oo] != l[oo+1]:
            return False
        
        oo += 1


    if tu != n:
        return False
    
    return True
    
if si():
    print("Yes")
else:
    print("No")

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

Solution (Python):
n = int(input())
w = [""] * n 
result = "Yes"

for i in range(n):
    tmp = input()
    if tmp in w:
        result = "No"
    w[i] = tmp 
for i in range(n-1):
    if w[i][-1] == w[i+1][0]:
        pass
    else:
        result = "No"
print(result)

Solution (Python):
n = int(input())
list = []
for i in range(n):
    a = input()
    list.append(a)
def is_unique(seq):
    return len(seq) == len(set(seq))

if is_unique(list) == False:
    print('No')

else:
    s = 0
    for k in range(n-1):
        a = list[k]
        b = list[k + 1]
        if a[-1] == b[0]:
            s += 1
        else:
            print('No')
            break
    if (s+1) == n:
        print('Yes')
    else:
        pass

Solution (Python):
import sys
n = int(input())
a = list()
for i in range(n):
    a.append(input())
b = list()
for i in range(n):
    if a[i] not in b:
        b.append(a[i])
    else:
        continue
if len(b) != len(a):
    print("No")
    sys.exit()
for i in range(len(b)-1):
    if b[i][-1] == b[i+1][0]:
        pass
    else:
        print("No")
        break
else:
    print("Yes")

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

Solution (Python):
import sys

n = int(input())

words = {}
latest = ''

for i in range(n):
    text = input()
    if latest != '':
        if latest[len(latest) -1] != text[0]:
            print("No")
            sys.exit()
    latest = text
    if text in words:
        print("No")
        sys.exit()
    words[text] = 1

print("Yes")

Solution (Python):
d = {}

i = int(input())

for m in range(i):
	word = input()
	d[m] = word
for n in range(1, i):
	a = d[n-1]
	b = d[n]
	if a[-1] != b[0]:
		print('No')
		exit()
for x in range (i-1):
	for j in range (x+1, i):
		if d[x] == d[j]:
			print('No')
			exit()
print('Yes')

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

word =  [input() for i in range(N)]

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

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

Solution (Python):
d = {}

i = int(input())

for m in range(i):
	word = input()
	d[m] = word
for n in range(1, i):
	h = n - 1
	a = d[h]
	b = d[n]
	if a[-1] == b[0]:
		continue
	else:
		print('No')
		exit()
for x in range (i - 1):
	for j in range (x + 1, i):
		if d[x] == d[j]:
			print('No')
			exit()
print('Yes')

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

word =  [input() for i in range(N)]

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

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

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

word = [input() for i in range(N)]




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

print('Yes')

Solution (Python):

N = int(input())

word = []
for i in range(N):
    word.append(input())

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

print('Yes')

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

word = []
for i in range(N):
    word.append(input())

for i in range(N - 1):
    if word.count(word[i]) != 1:
        print('No')
        exit()

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

print('Yes')

Solution (Python):
N = int(input())
W_list = [input() for _ in range(N)]
used = set()

used.add(W_list[0])
ans = True
for i in range(1, N):
    if W_list[i-1][-1] != W_list[i][0]:
        ans = False
    if W_list[i] in used:
        ans = False
    used.add(W_list[i])

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

Solution (Python):
n=int(input())
s=[input() for i in range(n)]
p=list(s[0])[0]
from collections import Counter
c=Counter(s)
if [1 for i in range(n)]!=list(c.values()):
    print("No")
    exit()
else:
    for i in s:
        a=list(i)[0]
        b=list(i)[-1]
        if p==a:
            p=b
        else:
            print("No")
            exit()
print("Yes")

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

for i, word in enumerate(w):
    if i is not 0:
        if word[0] is not w[i-1][-1] or word in history:
            print("No")
            exit()
    history.append(word)
print("Yes")

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

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

Solution (Python):
import sys
N=int(input())
w=[]
flag="Yes"

for i in range(N):
  w.append(input())

if len(set(w))<len(w):
  flag="No"

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

print(flag)

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

Solution (Python):


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

    for i in range(n):
        for j in range(i + 1, n):
            if w[i] == w[j]:
                print("No")
                exit()

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

    print("Yes")

if __name__ == "__main__":
    main()

Solution (Python):
import sys

N = int(input())

result = ""

words = [input() for i in range(N)]

if not len(words) == len(set(words)):
    result = "No"
    print(result)
    sys.exit()

for i in range(N-1):
    before = words[i]
    after = words[i + 1]

    if before[-1] == after[0]:
        continue

    else:
        result = "No"
        print(result)
        sys.exit()

result = "Yes"
print(result)

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

def solve():
	
	for i in range(n): 
		for j in range(i+1,n): 
			if l[i] == l[j]:
				print("No")
				return 

	for i in range(n-1):
		actual = l[i+1]
		next_word = l[i]
		if actual[0] != next_word[len(next_word)-1]:
			print("No")
			return 

	print("Yes")

solve()

Solution (Python):
def is_unique(seq):
    return len(seq) == len(set(seq))

flag = "Yes"
N = int(input())
word = input()
list = [word]
for i in range(N - 1):
    word = input()
    if list[i][len(list[i]) - 1] != word[0]:
        flag = "No"
        break
    list.append(word)
if not is_unique(list):
    flag = "No"
print(flag)

Solution (Python):
def hasMultiWord(W):
    for i in range(len(W)-1):
            if W[i] in W[i+1:]:
                return True
    return False


def isPrevTailEqualNextHead(W):
    for i in range(1, len(W)):
        if W[i-1][-1] != W[i][0]:
            return False
    return True


def main():
    W = []
    N = int(input())
    for _ in range(N):
        W.append(input())
    print(['No', 'Yes'][not hasMultiWord(W) and isPrevTailEqualNextHead(W)])


if __name__ == '__main__':
    main()

Solution (Python):
import collections, os, re


n = int(input())

words = set()
last = ''

ans = True

for i in range(n):
    s = input()
    if (i > 0 and last[-1] != s[0]) or s in words:
        ans = False

    words.add(s)


    last = s

print('{}'.format('Yes' if ans else 'No'))

Solution (Python):
N = int(input())
ls = []
flag = True
bChar = ""
for n in range(0, N):
  ch = input()
  if n == 0:
    ls.append(ch)
  else:
    if (ch in ls) or (bChar[-1:] != ch[0:1]):
      flag = False
  ls.append(ch)
  bChar = ch
if flag == True:
  print('Yes')
else:
  print('No')

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

Solution (Python):
il = lambda: list(map(int, input().split()))
ils = lambda n, s="int(input())": [eval(s) for _ in range(n)]

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

Solution (Python):


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

if len(W) == len(set(W)):
    is_unique = True
else:
    is_unique = False

shiri = True
if is_unique:
    for i in range(N-1):
        shiri = W[i][-1] == W[i+1][0]
        if not shiri:
            break

if shiri and is_unique:
    print("Yes")
else:
    print("No")