Telephone Number or Involution Number
Easy Accuracy: 25.95% Submissions: 81 Points: 2

Given a positive integer n. The task is to find the nth telephone number.
The telephone numbers or the involution numbers are a sequence of integers that count the ways n telephone lines can be connected to each other, where each line can be connected to at most one other line

Telephone numbers also used to derive the number of ways to place n rooks on an n x n chessboard in such a way that no two rooks attack each other, and in such a way that the configuration of the rooks is symmetric under a diagonal reflection of the board.

Input:
The first line of the input contains an integer T denoting the number of test cases. The description of each test case is as follows. Each test case contains a single line with one integer ' N ' for which you have to find the Nth telephone number.

Output:
For each N, output the Nth telephone number. Print under modulo 109 + 7.

Constraints:
1<=T<=100
1<=N<=1000

Example:
Input:

2
4
6
Output:
10
76

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.