//hdu2520
#include <iostream>
using namespace std;
int main()
{
long t, v, s, i;
int T;
cin >> T;
while(T--)
{
cin >> t;
v = s = 1;
i = t - 1;
while(i--)
{
v += 2;
s += v;
}
cout << s % 10000 <<endl;
}
return 0;
}