T=int(raw_input())

cache=[-1]*10000000

modulo=1000000000+7

maxIndex=1

def makePairs(N):
    global maxIndex
    if(N<=maxIndex):
        return cache[N]
    else:
        for i in xrange(maxIndex,N+1):
            cache[i]=(cache[i-1]+((i-1)*cache[i-2])%(modulo))%modulo
     
        maxIndex=N
        return cache[N]



for _ in xrange(0,T):
    N=int(raw_input())
    cache[1]=1
    cache[0]=1

    print makePairs(N)