#include "iostream" #include "cstdio" #include "cstring" #include "algorithm" #include "queue" #include "stack" #include "cmath" #include "utility" #include "map" #include "set" #include "vector" #include "list" #include "string" #include "cstdlib" using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair pii; #define st first #define nd second #define exp 1e-8 #define lson l, m, rt << 1 #define rson m + 1, r, rt << 1 | 1 const int MOD = 1e9 + 7; const int INF = 0x3f3f3f3f; const int MAXN = 1e6 + 6; int t, n; ll dp[MAXN]; int main(int argc, char const *argv[]) { dp[1] = 1, dp[2] = 2; for(int i = 3; i < MAXN; ++i) dp[i] = (dp[i - 1] + (i - 1) * dp[i - 2]) % MOD; scanf("%d", &t); for(int cas = 1; cas <= t; ++cas) { scanf("%d", &n); printf("Case #%d:\n", cas); printf("%lld\n", dp[n]); } return 0; }