#include <bits/stdc++.h>
using namespace std;
const int MAX_CHAR=256;
int countSub(string str){
vector v(MAX_CHAR,-1);
int n=str.length();
int dp[n+1];
dp[0]=1;
for(int i=1;i<=n;i++){
dp[i]=(2*dp[i-1])%1000000007;
if(v[str[i-1]]!=-1){
dp[i]=(dp[i]-dp[v[str[i-1]]]+1000000007)%1000000007;
}
v[str[i-1]]=(i-1);
}
return dp[n]%1000000007;
}
int main() {
int t;
cin>>t;
while(t--){
string str;
cin>>str;
cout<<countSub(str)<<endl;
}
return 0;
}
//this is not working