#include __int64 mod=1000000007; __int64 ans[1000001]; int main() { ans[0]=1; ans[1]=1; int i; for(i=2;i<=1000000;i++) ans[i]=(ans[i-1]+(i-1)*ans[i-2])%mod; int cases,r=1; scanf("%d",&cases); while(cases--) { int n; scanf("%d",&n); printf("Case #%d:\n%I64d\n",r++,ans[n]); } return 0; }