{"raw_statement":[{"iden":"statement","content":"Given N and K, count number of permutations of [1, 2, 3...N] in which no two adjacent elements differ by more than K. For example, permutation [4, 1, 2, 3] cannot be counted for .\n\nFirst line contains T(1 ≤ T ≤ 10), the number of test cases. Each test case consists of N(1 ≤ N ≤ 15) and K(0 ≤ N) in single line.\n\nFor each test case print the required answer in one line.\n\nExample case 1. All permutations are valid.\n\nExample case 2. Permutations [1, 2, 3, [3, 2, 1]] are counted.\n\n"},{"iden":"input","content":"First line contains T(1 ≤ T ≤ 10), the number of test cases. Each test case consists of N(1 ≤ N ≤ 15) and K(0 ≤ N) in single line."},{"iden":"output","content":"For each test case print the required answer in one line."},{"iden":"examples","content":"Input22 13 1Output22"},{"iden":"note","content":"Example case 1. All permutations are valid.Example case 2. Permutations [1, 2, 3, [3, 2, 1]] are counted."}],"translated_statement":null,"sample_group":[],"show_order":[],"formal_statement":"**Definitions**  \nLet $ T \\in \\mathbb{Z} $ be the number of test cases.  \nFor each test case $ i \\in \\{1, \\dots, T\\} $:  \n- $ N_i \\in \\mathbb{Z} $ denotes the size of the set $ \\{1, 2, \\dots, N_i\\} $.  \n- $ K_i \\in \\mathbb{Z} $ denotes the maximum allowed absolute difference between adjacent elements.  \n\nLet $ \\mathcal{P}_{N_i} $ be the set of all permutations of $ \\{1, 2, \\dots, N_i\\} $.  \n\n**Constraints**  \n1. $ 1 \\leq T \\leq 10 $  \n2. For each test case $ i $:  \n   - $ 1 \\leq N_i \\leq 15 $  \n   - $ 0 \\leq K_i \\leq N_i - 1 $  \n\n**Objective**  \nFor each test case $ i $, compute the number of permutations $ \\pi \\in \\mathcal{P}_{N_i} $ such that for all $ j \\in \\{1, 2, \\dots, N_i - 1\\} $:  \n$$\n|\\pi(j+1) - \\pi(j)| \\leq K_i\n$$","simple_statement":"Count permutations of [1, 2, ..., N] where no two adjacent numbers differ by more than K.","has_page_source":false}