import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
sc.nextLine();
long[] ans =new long[t];
for(int i =0;i<t;i++) {
String x = sc.nextLine();
long count = countSub(x);
ans[i]=count;
}
for(int i =0;i<t;i++) {
System.out.println(ans[i]%1000000007);
}
}
public static long countSub(String str) {
final int MAX_LENGTH=256;
int mod=1000000007;
int[] last = new int[MAX_LENGTH];
Arrays.fill(last, -1);
int n = str.length();
long[] dp = new long[n+1];
dp[0]=1;
for(int i =1;i<=n;i++) {
dp[i] = (2*dp[i-1])%mod;
if(last[(int)str.charAt(i-1)]!= -1) {
dp[i] = (((dp[i] - dp[last[(int)str.charAt(i-1)]]))+mod)%mod;
}
last[(int)str.charAt(i-1)]= i-1;
}
return dp[n];
}
}
code compiled but run time error showing…i.e testcases patially executed