#include <bits/stdc++.h>
using namespace std;
int main()
{
int f[1000050] = {0, 1, 1};
for (int i = 3; i <= 1000049; i++)
{
f[i] = (f[i - 1] + f[i - 2]) % 1000;
}
int n, a;
cin >> n;
while (n--)
{
cin >> a;
printf("%d\n", f[a]);
}
return 0;
}