| Лимит времени 2000/4000/4000/4000 мс. Лимит памяти 65000/65000/65000/65000 Кб. Question by Ibrahim Mesecan.
 
 
   Linked Numbers 
Assume that you are given the n numbers. Find 
the maximum length of number ordering such that 
the last digit of one number (an) is 
the same as the first digit of the next number 
(an+1). 
For example the following series complies the 
Linked Numbers property:    12 235 514 However the following series does not:    12 235 415 because second number 
235 ends with 5, but the 
third number 415 starts with 4. Question:
You will be given n positive integer. By possible 
replacements, find the length of longest 
linked numbers. 
Input specification  In the first line, you will be given a number: The 
number of numbers(n) 1 ≤ n ≤ 30.
Then, in the following n lines, you will be given n 
integers which are between 0 and 12,000.
 Output specification  Show the length of the longest linked list
 
  
| Sample Input 
 
4 235
 12
 317
 514
 
 | Sample Output 
 
3 
 |  
 Для отправки решений необходимо выполнить вход.
 
 
 |