#include<stdio.h>
int main()
{
int s,n,i,sum;
scanf("%d",&s);
while(s--)
{
scanf("%d",&n);
sum=1;
for(i=0;i<n-2;i++)
{
sum*=n;
sum%=10003;
}
printf("%d\n",sum);
}
return 0;
}
/*
cayley定理
定理的理解
此定理说明用n-1条边将n个一致的顶点连接起来的
连通图的个数为n^(n-2),也可以这样
理解,将n个城市连接起来的树状公路网络有n^(n-2)种
方案。所谓树状,指的是用n-1条边将n个顶点构成一个连通图。当然,建造一个树状的公路网络将n个城市连接起来,应求其中长度最短、造价最省的一种,或效益最大的一种。Cayley定理只是说明可能方案的数目。
*/