t=int(raw_input())
mx=0
arr=[0 for x in range(t)]
for _ in range(t):
	arr[_]=int(raw_input())
	if arr[_]>mx:
		mx=arr[_]


dp=[0 for x in range(mx+1)]
dp[1]=1
dp[2]=2
for i in range(3,mx+1):
	dp[i]=(dp[i-1]+(i-1)*dp[i-2])%1000000007
for i in range(t):
	print dp[arr[i]]