logo AlgoBeat OnlineJudge
登录 注册

#217561. [ICPC 2018 Xuzhou R] Rikka with Nice Counting Striking Back

内存限制:512 MiB 时间限制:16000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

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?

输入格式

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 .

输出格式

For each test case, output a single line with a single integer, the answer.

样例

样例输入 1

6
rikkasuggeststoallthecontestants
thisisaproblemdesignedforgrandmasters
ifyoudidnotachievethat
youdbetterskiptheproblem
wishyouahighrank
enjoytheexperience

样例输出 1

500
679
244
290
132
163