# 后缀数组+贪心+隔板法

if(ra[sa[i]+1]>ra[sa[i+1]+1]) m++,如果m大于25，那么就是无解，

C(25-m+n+1-1,n+1-1)= C(25-m+n,n) 但是会爆ll，用java大数即可

import java.math.BigInteger;
import java.util.Scanner;

public class Main
{

public static int N = 100010;
public static int[] sa = new int[N];
public static int[] ra = new int[N];

public static void main(String[] args)
{
Scanner cin = new Scanner(System.in

);
int t = cin.nextInt();
while(t-- != 0)
{
int n = cin.nextInt();
sa[0] = n+1;
for(int i = 1; i <= n; ++i)
{
sa[i] = cin.nextInt();
ra[sa[i]] = i;
}
if(n == 1)
{
System.out.println(26);
continue;
}
int m = 0;
for(int i = 1; i < n; ++i)
{
if(ra[sa[i]+1] > ra[sa[i+1]+1]) ++m;
}
if(m > 25)
{
System.out.println(0);
continue;
}
int hh = 25-m;
BigInteger h = BigInteger.valueOf(hh);
BigInteger n1 = BigInteger.valueOf(n);
BigInteger ans = BigInteger.ONE;
for(BigInteger i = BigInteger.valueOf(n+1); i.compareTo(n1.add(h)) <= 0; i = i.add(BigInteger.ONE))
{
ans = ans.multiply(i);
}
for(BigInteger i = BigInteger.ONE; i.compareTo(h) <= 0; i = i.add(BigInteger.ONE))
{
ans = ans.divide(i);
}
System.out.println(ans);
}

}

}