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())
a = []
for i in range(N):
    a.append(input())
flag = True
for j in range(N-1):
    a_i = a[j]
    a_ii = a[j+1]
    if a_i[-1] != a_ii[0]:
        flag = None
        break
    for k in range(j+1, N):
        if a[j] == a[k]:
            flag = None
            break
if flag:
    print('Yes')
else:
    print('No')

Solution (Python):
N = int(raw_input().replace("\n", ""))

w_list = []

flag = True
for i in xrange(N):
    w_i = raw_input().replace("\n", "")
    if i >= 1:
        w_last = w_list[i-1]
        if w_last[-1] != w_i[0] and flag == True:
            flag = False
        if w_i in w_list and flag == True:
            flag = False
    w_list.append(w_i)

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

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

Solution (Python):
n = int(input())
list_w = list()
for i in range(n):
    list_w.append(input())
a = 0
i = 0
while i <= n-2:
    x = list_w[i]
    y = list_w[i+1]
    if x[-1] != y[0]:
        a += 1
        break
    if i > 0:
        for j in range(i):
            if x == list_w[j - 1]:
                a += 1
                break
    i += 1
if a == 0:
    print('Yes')
else:
    print('No')

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

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

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

ans = 'Yes'
pre = input()

his = {}
his[pre] = 1
for i in range(N-1):
    s = input()
    if s[0] != pre[ len(pre) - 1 ] or (s in his):
        ans = 'No'
        
    his[s] = 1
    pre = s
    
print (ans)

Solution (Python):
n = int(input())
l = []
for i in range(n):
    w = input()
    l.append(w)
l.append(w[-1])
f = l[0]
ls = set(l)
fff=0
if len(l) != len(ls):
    fff = 1
    print("No")
else:
    first = f[0]
    for i in range(n):
        if l[i][-1] == l[i+1][0]:
            continue
        else:
            fff = 1
            print("No")
            break
if fff ==0:
    print("Yes")

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

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

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

Solution (Python):
n = int(input())
w1 = input()
w = {w1}
flag = True
cw = w1
for _ in range(n-1):
    nw = input()
    if nw[0] != cw[-1] or nw in w:
        flag = False
    w.add(nw)
    cw = nw
if flag:
    print('Yes')
else:
    print('No')

Solution (Python):



N = int(input())


words = []

flag = 0

for i in range(0, N):
    
    tmp = input()
    words.append(tmp)
    if(i != 0):
        if(tmp2[-1] != tmp[0]):
            flag = 1
    tmp2 = tmp
    for j in range(0, i):
        if(words[j] == words[i]):
            flag = 1

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

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

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



j = 0
k = 1
error = 0

while j < n-1:
    str1 = list[j]
    str2 = list[j+1]
    if str1[-1] == str2[0]:
        j += 1
        continue
    else:
        error += 1
        break

while k <= n:
    count = list.count(list[-k])
    if count != 1:
        error += 1
        break
    else:
        k += 1
        continue
        
if error == 0:
    print("Yes")
else:
    print("No")

Solution (Python):
n = int(raw_input())
W = []
for _ in range(n):
    W.append(raw_input().strip())

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

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

S=0

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

if S==N-1:
    ans="Yes"
else:
    ans="No"
    
print(ans)

Solution (Python):
time=input()
w_l=[]
ch=0
for i in range(time):
    j=raw_input()
    if j in w_l:
        print("No")
        ch=1
        break
    else:
        if w_l==[]:
            w_l.append(j)
        else:
            j_1=list(w_l[-1])
            j_2=list(j)
            if j_1[-1]!=j_2[0]:
                print("No")
                ch = 1
                break
            else:
                w_l.append(j)

if ch==0:
    print("Yes")

Solution (Python):
a = int(input())
wordli = dict()
go = True
for i in range(a):
	word = input()
	if i == 0:
		wordli[word] = 1
		temp = word
	else:
		if word not in wordli and word[0] == temp[-1]:
			wordli[word] = 1
			temp = word
		else:
			print ('No')
			go = False
			break

if go == True:
	print ('Yes')

Solution (Python):
n = int(input())
s2=list(input())
k = 0
w = []
r = ''
for i in range(len(s2)):
    r += s2[i]
w.append(r)
for i in range(1,n):
    s=list(input())
    if s[0]!=s2[len(s2)-1]:
        k = 1
    r = ''
    for j in range(len(s)):
        r += s[j]
    
    if w.count(r) != 0:
        k = 1
    w.append(r)
    s2 = s
if k == 1:
    print('No')
else:
    print('Yes')

Solution (Python):
import sys
n=int(input())
a=[]
for i in range(n):
  a.append(list(map(str,input())))
  
for j in range(1,n):
  if a[j][0]!=a[j-1][-1]:
    print("No")
    sys.exit()
  for l in range(j):
    if a[l]==a[j]:
      print("No")
      sys.exit()
  
print("Yes")

Solution (Python):
x = int(input())
ANS = "Yes"
s = []

for i in range(x):
	s.append(input())
for i in range(x-1):
	if s[i+1][0] != s[i][-1]:
		ANS = "No"
		break
if len(s) == len(set(s)):
	print(ANS)
else:
	print("No")

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

correct = True
for i in range(len(w)):
    if w[i] in w[i + 1:]:
        correct = False
        break
    if i > 0 and w[i][0] != w[i - 1][-1]:
        correct = False
        break

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

Solution (Python):

N = int(input())
wardList = [input() for _ in range(N)]
ans = "Yes"
history = set()
lastCharacter = ''

for i in range(N):
    ward = wardList[i]
    if ward in history:
        ans = "No"
        break
    else:
        if i > 0:
            if lastCharacter != ward[0]:
                ans = "No"
                break
        history.add(ward)
        lastCharacter = ward[len(ward)-1]

print(ans)

Solution (Python):
num_word = int(input())
word_list = []
flag = True

for i in range(num_word):
    word_list.append(input())

for j in range(num_word - 1):
    word1 = word_list[j]
    word2 = word_list[j + 1]
    for k in range(j):
        if word1 == word_list[k]:
            flag = False
            break
    if word1[len(word1) - 1] != word2[0]:
        flag = False
        break
for l in range(num_word  - 1):
    if word_list[num_word - 1] == word_list[l]:
        flag = False

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

Solution (Python):
import sys

n = int(input())
t = input()
w = [t]

for i in range(n-1):
    s = input()
    if s in w:
        print('No')
        sys.exit()
    w += [s]

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


print('Yes')

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

flag = True
chr = 'A'
table = []
for i in range(n):
    line = input()
    if not(chr == line[0] or chr == 'A'):
        print('No')
        flag = False
        break

    if line in table:
        print('No')
        flag = False
        break
    table.append(line)
    chr = line[-1]

if flag:
    print('Yes')

Solution (Python):
word= input()
wordlist = [raw_input() for i in range(word)]
counts=0
for i in range(word):
    if i>0:
        if wordlist[i-1][-1]==wordlist[i][0]:
            for words in wordlist:
                if words==wordlist[i]:
                    counts=counts+1
            counts=counts-1
        else:
            counts=counts+1
if counts==0:
    print"Yes"
else:
    print"No"

Solution (Python):
n = int(input())
flag = True
s = []
words = []
w1 = input()
words.append(w1)
e = w1[-1]

for i in range(n-1):
    wi = input()
    if e != wi[0]:
        flag = False
    for w in words:
        if w == wi:
            flag = False
    words.append(wi)
    e = wi[-1]


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

Solution (Python):
import sys

n=int(input())
l=[]
for x in range(n):
	l.append(str(input()))
	if x>0:
		if not(l[x-1][-1] == l[x][0]) or (l[x] in l[:x]):
			print("No")
			sys.exit()
print("Yes")

Solution (Python):
n = int(input())
w = set()
wk = None

for _ in range(n):
  wi = input()
  if wi in w or wk and wk[-1] != wi[0]:
    print('No')
    break
  w.add(wi)
  wk = wi
else:
  print('Yes')

Solution (Python):
n=int(input())
s=input()
lt=[s]
lw=s[-1]
msg='Yes'
for i in range(1, n):
    s=input()
    if s[0] != lw or lt.count(s) > 0:  
        msg='No'
        break
    else:
        lw=s[-1]
        lt.append(s)
print(msg)

Solution (Python):


if __name__ == "__main__":
    N = int(input())
    pre_w = input()
    words = [pre_w]
    for i in range(N-1):
        w = input()
        if w in words:
            print("No")
            exit()
        words.append(w)

        if pre_w[-1] == w[0]:
            pre_w = w
            continue
        else:
            print("No")
            exit()
    print("Yes")

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

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

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

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

for j in range(len(word)):
    if j > 0:
        mae = word[j-1]
        ima = word[j] 
        if mae[-1] != ima[0]:
            print("No")
            exit()
for w in word:
    if word.count(w) > 1:
        print("No")
        exit()
print("Yes")

Solution (Python):
N=int(input())
count = 0
listA=[]
while (count <= N-1):
    try:
        listA.append(str(input()))
        count+=1
    except:
        break;
if(len(listA) != len(set(listA))):
    print("No")
else:
    for i in range(N-1):
        if(listA[i][-1]!=listA[i+1][0]):
            print("No")
            break
        if(i==N-2):
            print("Yes")

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

tmp = [S[0]]
flag = True
for i in range(1,N):
    if S[i-1][-1] != S[i][0]:
        flag = False
        break
    if S[i] in tmp:
        flag = False
        break
    tmp.append(S[i])

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

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

Solution (Python):
N=int(input())
W_his=[]
count=0
s_flag=1

for i in range(N):
	W_his.append(input())
	if i != 0:
		W_0=W_his[i-1]
		W_1=W_his[i]
		if W_0[-1] != W_1[0]:
			s_flag=0
			break
			
		for j in range(i-1):
			if W_his[j] == W_his[i]:
				s_flag=0
				break

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

Solution (Python):
import numpy as np

n = int(input())
w = []
for i in range(n):
    w.append(input())
result = 'Yes'

l = len(w)
w_ = list(set(w))
l_ = len(w_)

if l != l_:
    result='No'

for i in range(n-1):
    if w[i][-1] != w[i+1][0]:
        result = 'No'

print(result)

Solution (Python):
dataNum=int(input())
wordList=[]
for n in range(dataNum):
    wordList.append(input().strip())

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

char = wordList[0][-1:]
for n in range(1, len(wordList)):
    if(char != wordList[n][:1]):
        print("No")
        exit()
    char = wordList[n][-1:]

print("Yes")

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


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

Solution (Python):
n = int(input())
tango = []
count = 0
kaburi = 0
for i in range(n):
    tango.append(input())

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

for i in range(n):
    for j in range(n):
        if tango[i] == tango[j]:
            kaburi += 1



if count == 0 and kaburi == n:
    print('Yes')
else:
    print('No')

Solution (Python):
n=int(input())
siritori=[input() for i in range(n)]
tale=siritori[0][:1]
answer='Yes'
for i in range(n):
    if tale!=siritori[i][:1]:
        answer='No'
        break
    if siritori.index(siritori[i])!=i:
        answer='No'
        break
    tale=siritori[i][-1:]
print(answer)

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

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

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

check=1

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

W.sort()


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

if check==1:
    print("Yes")

else:
    print("No")

Solution (Python):
def main():
    N = input()
    lst = []
    result = 'Yes'
    for i in range(N):
        W = raw_input()
        
        if lst == []:
            lst.append(W)
            continue
        if W in lst:
            result = 'No'
            break
        elif W[0] != lst[-1][-1]:
            
            
            result = 'No'
            break
        else:
            lst.append(W)
    print(result)

if __name__ == '__main__':
    main()

Solution (Python):
import sys
from collections import deque
import copy


def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [int(input_raw[0])]
    W_set = set([])
    pre_last_char = ""
    for i in range(N):
        input_raw = read_func().strip().split()
        W = input_raw[0]
        if W not in W_set and (pre_last_char == "" or pre_last_char == W[0]):
            W_set.add(W)
            pre_last_char = W[len(W) - 1]
        else:
            print "No"
            exit()
    print "Yes"

if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
words = [input() for i in range(N)]
count=0
if len(words)==len(set(words)):
  for j in range(0,N-1):
    if words[j][-1]==words[j+1][0]:
      count+=1
  if count==N-1:
    print("Yes")
  else:
    print("No")
else:
  print("No")

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

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

def checkRule(words):
  if len(words) != len(set(words)):
    print("No")
    return

  tail= words[0][0]
  for w in  words:
    if w[0] != tail:
      print("No")
      return
    else:
      tail = w[-1]

  print("Yes")

checkRule(words)

Solution (Python):
import sys

n = int(input())

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

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

if not is_unique(w):
    print("No")
    sys.exit(0)

pre_word = w[0]
for word in w[1:]:
    
    if pre_word[-1] != word[0]:
        print("No")
        sys.exit(0)
    pre_word = word
print("Yes")

Solution (Python):
ans, s = "Yes", ''
d = {}
for _ in range(int(input())):
    t = [str(x) for x in ''.join(input())]
    if d.get(''.join(t)) != None or (_ > 0 and t[0] != s[-1]):
        ans = "No"
        break
    d.setdefault(''.join(t), 1)
    s = t
print(ans)

Solution (Python):


N = input()

list=[]
flag = True

for i in range(int(N)):
    temp=input()
    
    if str(temp) in list:
        flag=False
    list.append(temp)
    if flag==False:
        break

    str1=list[i-1]
    str2=list[i]
    if i!=0:
        if str1[-1]==str2[0]:
            flag=True
        else:
            flag=False
    if flag==False:
        break

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

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

count = int(input())

i = 0
str_list = []
while i < count:
    str_list.append(input())
    i += 1



result_a = is_uniq(str_list)

result_b = True
for i, word in enumerate(str_list):
    
    if i != 0:
        
        pre_str_tail = str_list[i - 1][-1]
        str_head = str_list[i][0]

        if pre_str_tail != str_head:
            result_b = False
            break

if result_a and result_b:
    print('Yes')
else:
    print('No')

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

ans="No"
W=[]

w = input()
W.append(w)

for i in range(N-1):
	w = input()
	if W[i][-1]!=w[0]:
		print(ans)
		exit(0)
	W.append(w)

W.sort()

for i in range(N-1):
	if W[i]==W[i+1]:
		print(ans)
		exit(0)

ans="Yes"
print(ans)

Solution (Python):
n = int(input())
ws = [str(input()) for i in range(n)]
before_w=""
ok = True
ends=[]
for i, w in enumerate(ws):
    if i == 0:
        before_w = w
        ends.append(w)
        continue
    if w[0] == before_w[-1]:
        before_w = w
        if(w in ends):
            ok=False
            break
        ends.append(w)

        continue
    else:
        ok = False
        break

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

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

array=[]

judge = 'Yes'

for i in range(N):
    word = list(raw_input())
    if word in array:
        judge = 'No'
        break
    if len(array) != 0:
        last = array[-1]
        if word[0] != last[-1]:
            judge = 'No'
            break

    array.append(word)




print judge

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

if len(W) == len(set(W)):
    accept = True
    lw = W[0][-1]
    for w in W[1:]:
        if lw != w[0]:
            accept = False
            break
        else:
            lw = w[-1]
    if accept:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Solution (Python):
import sys
n=int(raw_input())

w={}
pre_last=''
for i in range(n):
  s=raw_input()
  if s in w:
    print "No"
    sys.exit()
  else:
    w[s]=1
  now_begin=s[0:1]
  if i > 0:
    if pre_last!=now_begin:
      print "No"
      sys.exit()
  pre_last=s[-1:]
print "Yes"

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

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

n = int(input())
W = [input() for _ in range(n)]
a = []
before_tail = ""
current_first = " "
flag = True
for i in range(1,n):
    current_first = W[i][0]
    before_tail = W[i-1][-1]
    if current_first != before_tail:
        flag = False
        break

if flag and is_unique(W):
    print("Yes")
else:
    print("No")

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

s = ['' for i in range(N)]
for i in range(N):
    s[i] = str(input())

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

for i in range(1, N):
    str1 = list(s[i - 1])
    str2 = list(s[i])
    if str1[-1] != str2[0]:
        print('No')
        sys.exit()

print('Yes')

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

w = [''] * n

end = ''
res = 'Yes'

hTable = {}

for i in range(0, n):
    w[i] = str(input())

    if (i == 0 or end == w[i][0]) and (w[i] not in hTable):
        end = w[i][-1]
        hTable.setdefault(w[i])
    else:
        res = 'No'


print(res)

Solution (Python):
n=int(input())
flag=False
l=[]
for i in range(0,n):
    if(i==0):
        s=input()
        l.append(s)
    if(n==1):
        print('Yes')
        continue
    if(i>=1):
        s=input()
        li=list(st)
        if(li[-1]==s[0] and s not in l):
            flag=True
        else:
            print('No')
            exit()
        l.append(s)
    st=s
if(flag):
        print('Yes')

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

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

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

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

W = [raw_input().replace("\r", "") for _ in range(N)]

ans = "Yes"

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

    else:
        if i == 0:
            continue

        if W[i][0] != W[i-1][-1:]:
            ans = "No"
            break

print ans

Solution (Python):
a = int(input())
flg = 0
b =[]
c = ""
for i in range(a):
    s = str(input())
    for j in b:
        if s == j:
            flg = 1
    if i != 0:
        if s[0:1] != c[-1:]:
            flg = 1
    c = s
    b.append(s)
if flg == 0:
    print("Yes")
else:
    print("No")

Solution (Python):
n = int(input())
w = []
for i in range(n):
    w.append(input())
ans = "Yes"
flag = 0
for i in w:
    if w.count(i) != 1:
        flag= 1
        ans = "No"
        break

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

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

s = set()
l = []

for c in w:
    s.add(c)
    l.append([c[0], c[len(c) - 1]])

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

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

print("Yes")

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

for i in range(n):
    s = input()
    if s in w:
        flag = 0
        break
    else:
        w.append(s)

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

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

Solution (Python):
def main():
    N = int(input())
    W = [input() for n in range(N)]

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

if __name__ == '__main__':
    main()

Solution (Python):
import sys
N = int(input())
k = input()
a = []
for i in range(N-1):
    a.append(input())
lis = [k]
for words in a:
  if words in lis:
    print('No')
    sys.exit()
  elif k[-1] != words[0]:
    print('No')
    sys.exit()
  else:
    lis.append(words)
    k = words
print('Yes')

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

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

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

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

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

if (len(words)==len(set(words))):
    for i in range(N-1):
        if(words[i][-1] != words[i+1][0]):
            status = 'error'
            break
        elif(i == N-2):
            status = 'done'
else:
    status = 'error'

if(status == 'done'):
    print('Yes')
elif(status == 'error'):
    print('No')

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

for i in range(N):
    word = input()
    shiritori.append(word)
    if i == 0:
        pass
    else:
        if shiritori[i].startswith(shiritori[i-1][-1:]):
            pass
        else:
            print("No")
            exit()


if len(set(shiritori)) == N:
    print("Yes")
else:
    print("No")

Solution (Python):
import sys


def main():
    lines = [x.strip() for x in sys.stdin.readlines()]
    N = lines[0]
    words = lines[1:]
    w = words[0][-1]
    result = "Yes"
    if len(set(words)) != len(words):
        result = "No"
    else:
        for i in words[1:]:
            if i[0] != w:
                result = "No"
            w = i[-1]
    print(result)


if __name__ == '__main__':
    main()

Solution (Python):
def solve():
  n = int(input())
  words = []

  for _ in range(n):
    word = input()
    words.append(word)
  set_word = set(words)
  if len(set_word) != len(words):
    print("No")
    return 0

  for i, word in enumerate(words):
    if i > 0:
      last = words[i-1][-1]
      front = words[i][0]

      if front != last:
        print("No")
        return 0
      

  print("Yes")



solve()

Solution (Python):


n = int(raw_input())

s = []

w = raw_input()
s.append(w)

for i in range(n-1):
    w = raw_input()
    if w[0] != s[-1][-1]:
        print "No"
        exit()
    for j in s:
        if w == j:
            print "No"
            exit()
    s.append(w)
print "Yes"

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

spoken_words = []
for i in range(n):
    word = input()
    if i >= 1:
        if word in spoken_words or spoken_words[-1][-1] != word[0]:
            print("No")
            exit()
    spoken_words.append(word)
print("Yes")

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

Solution (Python):
from sys import stdin

def is_unique(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(stdin.readline().rstrip())
ans = "No"
words = []

for i in range(N):
    word = stdin.readline().rstrip()
    words.append(word)
if is_unique(words):
    ans = "Yes"
    for i in range(N-1):
        if words[i][-1] != words[i+1][0]:
            ans = "No"
print(ans)

Solution (Python):
n = int(input())
def checker(n):
    words = []
    last_one = []
    for i in range(n):
        word = input()
        wl = list(word)
        h = wl[0]
        l = wl[-1]
        if word in words:
            print('No')
            return
        if i>0 and  h != last_one[-1]:
            print('No')
            return
        words.append(word)
        last_one.append(l)
    print('Yes')
    return

checker(n)

Solution (Python):



def main(N, words):
	answer = "Yes"
	
	for j in range(1,N):
		
		if words[j] in words[:j]+words[j+1:]:
			answer = "No"
			break
		elif words[j-1][len(words[j-1])-1] != words[j][0]:
			answer = "No"
			break
	return answer
		
	
	
	
N = int(input())
words = []
try:
	while True:
		words.append(input())
except EOFError:
	pass
print(main(N,words))

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

already_list=[]
w=0
for i in range(N):
    W = input()
    if W not in already_list:
        if w==0 or w[-1]==W[0]:
            already_list.append(W)
            w=W

if len(already_list) == N:
    print('Yes')
else:
    print('No')

Solution (Python):
n=int(input())
w=[]
for i in range(n):
    w.append(input())
if n==len(list(set(w))):
  ans='Yes'
else:
  ans='No'

for i in range(n-1):
    if w[i][-1:]==w[i+1][0]:
        a=0
    else:
        ans='No'
        break
print(ans)

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

used_words = [w[0]]

def check_shiritori(b_word, a_word):
    if b_word[-1] == a_word[0]:
        return True
    else:
        return False

rule_flag = True
for i in range(1, n):
    if w[i] in used_words:
        rule_flag = False 
        break       
    if check_shiritori(w[i-1], w[i]):
        used_words.append(w[i])
    else:
        rule_flag = False
        break

if rule_flag is True:
    print("Yes")
else:
    print("No")

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

ans = "Yes"
used = {}
for i in range(n):
    if ws[i] in used or (0 < i and ws[i - 1][-1] != ws[i][0]):
        ans = "No"
        break
    used[ws[i]] = i
print(ans)

Solution (Python):

"""
Created on Sat Sep  8 18:33:41 2018
ABC109B
@author: maezawa
"""
import collections
n = int(input())
words = []
for i in range(n):
    words.append(input())

samew = collections.Counter(words)
sn = sorted(samew.values())
if sn[0] != 1 or len(set(sn)) != 1:
    print('No')
else:
    ans = 'Yes'
    for i in range(n-1):
        if words[i][-1] == words[i+1][0]:
            continue
        else:
            ans = 'No'
            break
    print(ans)

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

def chk_shiri(w):
    for i in range(n - 1):
        if w[i][-1] == w[i + 1][0]:
            continue
        else:
            return False
    return True
    
if len(w) != len(set(w)):
    print('No')
elif chk_shiri(w):
    print('Yes')
else:
    print('No')