#include<iostream> #include<cstdio> #include<cstring> #define maxn 1000010 #define ll long long usingnamespacestd;
constint p = 1000000007;
int n;
char s[maxn];
int nxt[maxn], dep[maxn]; ll ans; voidinit_nxt(char *s){ nxt[1] = 0; dep[1] = 1; int k = 0, t = 0, d = 0, n = strlen(s + 1); for (int i = 2; i <= n; ++i) { while (k && s[i] != s[k + 1]) k = nxt[k]; if (s[i] == s[k + 1]) ++k; nxt[i] = k; dep[i] = dep[k] + 1; while (t && s[i] != s[t + 1]) t = nxt[t]; if (s[i] == s[t + 1]) ++t; while (t && t > i / 2) t = nxt[t]; ans = ans * (dep[t] + 1) % p; } }
voidwork(){ scanf("%s", s + 1); ans = 1; init_nxt(s); cout << ans << endl; }
intmain(){ int T; cin >> T; while (T--) work(); return0; }