''' HackerEarth - Vibhu and His Mathematics
	NguyenDatSE '''
from math import factorial

MOD = int(1e9 + 7)

def computePOS(population):
	mems = [0 for p in xrange(population + 1)]
	mems[0] = 1		# All single
	mems[1] = 1

	for p in xrange(2, population + 1):
		mems[p] = (mems[p - 1] + mems[p - 2] * (p - 1)) % MOD

	return mems

if __name__ == '__main__':
	T = int(raw_input())
	Ns = []
	for t in xrange(T):
		Ns.append(int(raw_input()))

	maxn = max(Ns)
	results = computePOS(maxn)
	for n in Ns:
		print results[n]