MOD = 1000000007 MAX_N = 1000000 MAX_K = 1000000 a = [1] * 2000001 b = [1] * 1000001 for i in xrange(1,MAX_N + MAX_K + 1): a[i] = (i * a[i - 1]) % MOD b[MAX_K] = pow(a[MAX_K], MOD - 2, MOD) for i in reversed(xrange(1, MAX_K + 1)): b[i - 1] = b[i] * i % MOD def P(x,y): if x < y: return 0 else: return a[x] * b[x - y] % MOD def C(x,y): return P(x,y) * b[y] % MOD def H(x,y): if x == 0 and y == 0: return 1 else: return C(x + y - 1,y) t = input() for i in xrange(t): print eval(raw_input())