P28889 [洛谷] Father and Son
普及+
题目描述

Problem Background

A common scene in university boys' dormitories:

$A:$ "I forgot to bring tissue, come to the bathroom and save me!"

$B:$ "Call me dad."

$A:$ "Dad!"

$............................................$

$A:$ "I'm out of money, can you lend me some?"

$B:$ "Call me dad."

$A:$ "Dad!"

A month later,

$B:$ "Can you return the money to me now?"

$A:$ "Call me dad."

$B:$ "Dad!"

Problem Description

In boys' dormitories across the country, there are always various chaotic father-son relationships.

Suppose now we have a dormitory with different $n$ people, each person has at most one "father," can have multiple "sons," and there is exactly one person who does not have a "father" (after all, the dorm leader deserves some respect, and everyone can be the dorm leader).

Now the question arises, for a dormitory with $n$ people, what is the maximum number of possible father-son relationships, with everyone having a direct or indirect father-son relationship.

Input Format

The first line contains a non-negative integer $t$, indicating the number of test cases.

The next $t$ lines each contain an integer $n$, indicating the number of people.

Output Format

There are $t$ lines in total, each containing an integer, representing the number of relationships.

Since the answer may be large, we need to output the answer modulo $10^9+9$.

Sample Input and Output

Sample Input #1

1
3

Sample Output #1

9

Sample Input #2

1
323

Sample Output #2

283888610

Notes

  • For $10\%$ of the data, it is guaranteed that $t=0$;
  • For another $30\%$ of the data, it is guaranteed that $n≤5$;
  • For $100\%$ of the data, $t≤10^4$, $1\le n\le10^9$.
输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
1 3
样例输出
9