Chef is good at making pancakes. Generally he gets requests to serve N pancakes at once.
He serves them in the form of a stack.
A pancake can be treated as a circular disk with some radius.

Chef needs to take care that when he places a pancake on the top of the stack the radius of the pancake should not exceed the radius of the largest pancake in the stack by more than 1. 
Additionally all radii should be positive integers, and the bottom most pancake should have its radius as 1.
Chef wants you to find out in how many ways can he create a stack containing N pancakes.

------ Input Format ------ 

First line of the input contains T (T ≤ 1000) denoting the number of test cases.

T lines follow each containing a single integer N (1 ≤ N ≤ 1000) denoting the size of the required stack.

------ Output Format ------ 

For each case the output should be a single integer representing the number of ways a stack of size N can be created. As the answer can be large print it modulo 1000000007.

----- Sample Input 1 ------ 
2
1
2
----- Sample Output 1 ------ 
1
2

Source: codechef | Difficulty: MEDIUM_HARD
Tags: Dynamic programming

Preprocessing


Solutions:
MD = 1000000007
P = [[0 for x in range(1001)] for y in range(1001)]
P[1][1] = 1
for n in range(2, 1001):
	for w in range(1, n + 1):
		P[n][w] = (P[n - 1][w - 1] + w * P[n - 1][w]) % MD
t = int(input())
for i in range(t):
	N = int(input())
	tot = 0
	for w in range(1, N + 1):
		tot += P[N][w]
	r = tot % MD
	print(r)


dp = [[0 for it in range(1003)] for it in range(1003)]
dp[0][0] = 1
mod = 10 ** 9 + 7
for i in range(1, 1003):
	dp[i][0] = dp[i - 1][i - 1]
	for j in range(1, i + 1):
		dp[i][j] = (dp[i - 1][j - 1] % mod + dp[i][j - 1] % mod) % mod
for it in range(int(input())):
	n = int(input())
	print(dp[n][0])


st_pan = [[0 for _ in range(1001)] for _ in range(1001)]
st_pan[0][0] = 1
mod = 10 ** 9 + 7
for i in range(1, 1001):
	st_pan[i][0] = st_pan[i - 1][i - 1]
	for j in range(1, i + 1):
		st_pan[i][j] = (st_pan[i - 1][j - 1] % mod + st_pan[i][j - 1] % mod) % mod
for _ in range(int(input())):
	print(st_pan[int(input())][0])


st_pan = [[0 for _ in range(1001)] for _ in range(1001)]
st_pan[0][0] = 1
mod = 1000000007
for i in range(1, 1001):
	st_pan[i][0] = st_pan[i - 1][i - 1]
	for j in range(1, i + 1):
		st_pan[i][j] = (st_pan[i - 1][j - 1] % mod + st_pan[i][j - 1] % mod) % mod
for _ in range(int(input())):
	print(st_pan[int(input())][0])