1 #include<iostream>
2 #include<cstring>
3 #include<cstdio>
4 using namespace std;
5 char a[201];
6 int f(int n) //快速幂 ,求2011的n次方并求余10000;
7 {
8 if(n==0)return 1;
9 if(n==1)return 2011;
10 int b=f(n/2)%10000;
11 b=(b*b)%10000;
12 if(n%2==1)b=(b*2011)%10000;
13 return b;
14 }
15 int main()
16 {
17 int l,k,x=0;
18 cin>>k;
19 for(int i=1;i<=k;++i)
20 {
21 x=0;
22 memset(a,0,sizeof(a));//一定要赋初值0
23 scanf("%s",a);
24 l=strlen(a);
25 if(l==1)x=a[0]-'0'; //将字符串转为数字;
26 else if(l==2)x=10*(a[0]-'0')+(a[1]-'0');
27 else if(l==3)x=100*(a[0]-'0')+10*(a[1]-'0')+(a[2]-'0');
28 else for(int i=l-4;i<=l-1;++i)
29 x=x*10+(a[i]-'0');
30 cout<<f(x)<<endl;
31 }
32 return 0;
33 }