#P17423. [ICPC 2018 Xuzhou R] Rikka with Nice Counting Striking Back
[ICPC 2018 Xuzhou R] Rikka with Nice Counting Striking Back
Problem Description
As we know, Yuta is poor at counting numbers. Rikka is worrying about this situation, so she gives Yuta some counting tasks to practice. Here is one of them:
In computer programming, a string is traditionally a sequence of characters and a substring of a string is a contiguous sequence of characters within the string. For instance, is a string, is a substring of and is not a substring of . Moreover, the concatenation of two strings and is named as , that is, if is and is , then is .
Rikka has a string of length and she wants Yuta to count how many distinct strings in total. Here, she calls a non-empty string if
- is a substring of ; and
- is not a substring of for any non-empty string meeting the condition that and are the same string.
It is too difficult for Yuta. Can you help him?
Input Format
The input contains several test cases, and the first line contains a single integer (), the number of test cases.
For each test case, the only line contains a single string of length () with only lowercase letters.
The input guarantees that the sum of in all test cases is at most .
Output Format
For each test case, output a single line with a single integer, the answer.
6
rikkasuggeststoallthecontestants
thisisaproblemdesignedforgrandmasters
ifyoudidnotachievethat
youdbetterskiptheproblem
wishyouahighrank
enjoytheexperience
500
679
244
290
132
163