#ABC109B. Shiritori

Shiritori

题目描述

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, NN, and the ii-th word he announced, WiW_i, for each ii. Determine if the rules of shiritori was observed, that is, every word announced by him satisfied the conditions.

高桥今天又独自练习_Shiritori_了。

Shiritori 是一种游戏,玩法如下:

  • 第一轮,玩家宣布任意一个词。
  • 在随后的回合中,一方宣布的单词必须满足以下条件: - 之前未宣布过该单词。 - 该单词的第一个字符与上一个单词的最后一个字符相同。

在这个游戏中,玩家要在十秒钟内尽可能多地报出单词。

我们给出了高桥宣布的单词数 NN ,以及他宣布的第 ii 个单词 WiW_i ,每个 ii 。判断高桥是否遵守了 "shiritori "的规则,即他宣布的每个词都符合条件。

输入格式

输入内容按以下格式标准输入:

NN
W1W_1
W2W_2
::
WNW_N

输出格式

如果高桥宣布的每个单词都满足条件,则打印 "是";否则,打印 "否"。

样例 #1

样例输入 #1

4
hoge
english
hoge
enigma

样例输出 #1

No

样例 #2

样例输入 #2

9
basic
c
cpp
php
python
nadesico
ocaml
lua
assembly

样例输出 #2

Yes

样例 #3

样例输入 #3

8
a
aa
aaa
aaaa
aaaaa
aaaaaa
aaa
aaaaaaa

样例输出 #3

No

样例 #4

样例输入 #4

3
abc
arc
agc

样例输出 #4

No

说明

数据规模与约定

  • NN 是满足 2N1002 \leq N \leq 100 的整数。
  • WiW_i 是长度介于 111010 (含)之间的字符串,由小写英文字母组成。

样例 11 解释

由于 "hoge "被多次宣布,因此没有遵守 "shiritori "的规则。

样例 22 解释

样例 33 解释