MOD = 1000000007 a = [1] * 2000001 b = [1] * 1000001 for i in xrange(1,2000001): a[i] = (i * a[i - 1]) % MOD b[1000000] = pow(a[1000000], MOD - 2, MOD) for i in reversed(xrange(1, 1000001)): 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())