#include #include #include #include #include using namespace std; typedef long long LL; const LL mod = 1000000007; const int MAXN = 100010; int a[MAXN]; LL dp[MAXN]; int main() { int T; scanf("%d", &T); while(T--) { int n; scanf("%d", &n); memset(dp, 0, sizeof dp); bool wr = false; for(int i = 1 ; i < n ; i++) { scanf("%d", &a[i]); if(i + a[i] > n) wr = true; } if(wr) { printf("0\n"); continue; } for(int i = 2 ; i < n ; i++) { if(a[i] == a[i - 1] - 1 || a[i - 1] == 0); else wr = true; } if(wr) { printf("0\n"); continue; } dp[n] = 26; for(int i = n - 1 ; i >= 1 ; i--) { if(a[i] == 0) dp[i] = (25 * dp[i + 1]) % mod; else { dp[i] = (dp[i + a[i]]) % mod; } } printf("%I64d\n", dp[1]); } return 0; }