#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define forn(i,n) for(int i=0;i>=1; } return ret; } int main() { #ifdef LOCAL freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout); #endif // LOCAL a[1]=1; a[2]=2; for(int i=3;i<=maxn;i++) { a[i]=(a[i-1]+((i-1)*a[i-2])%MOD)%MOD; } int T; scanf("%d",&T); int cnt=1; while(T--) { int n; scanf("%d",&n); printf("Case #%d:\n%I64d\n",cnt++,a[n]); } return 0; }