{"raw_statement":[{"iden":"statement","content":"It is always fun to play with dice, here is one interesting game:\n\nYou are given n fair dice with 6 faces, the faces does not necessarily have values from 1 to 6 written on them. instead, they can have any values from 1 to 100 written on them.\n\nSuppose you threw the n dice one after another, let us define the result of the throws as the multiplication of the numbers you get from each dice mod 109 + 7. \n\nYou task is to find how many different ways you can get the result of the dice throws equal to x.\n\nThe first line contains an integer T, where T is the number of test cases.\n\nThe first line of each test case contains two integers n and x (1 ≤ n ≤ 14) (0 ≤ x < 109 + 7), where n is the number of the dice and x is the required result from the throws.\n\nThen n lines follow, the ith line contains 6 integers fi1, fi2, ..., fi6 (1 ≤ fij ≤ 100), giving the values of ith dice's faces.\n\nFor each test case, print a single line containing how many different ways you can get the result of the dice throws equal to x\n\n"},{"iden":"input","content":"The first line contains an integer T, where T is the number of test cases.The first line of each test case contains two integers n and x (1 ≤ n ≤ 14) (0 ≤ x < 109 + 7), where n is the number of the dice and x is the required result from the throws.Then n lines follow, the ith line contains 6 integers fi1, fi2, ..., fi6 (1 ≤ fij ≤ 100), giving the values of ith dice's faces."},{"iden":"output","content":"For each test case, print a single line containing how many different ways you can get the result of the dice throws equal to x"}],"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 $ k \\in \\{1, \\dots, T\\} $:  \n- Let $ n_k \\in \\mathbb{Z} $ be the number of dice, with $ 1 \\leq n_k \\leq 14 $.  \n- Let $ x_k \\in \\mathbb{Z} $ be the target result modulo $ M = 10^9 + 7 $, with $ 0 \\leq x_k < M $.  \n- Let $ F_k = (F_{k,1}, F_{k,2}, \\dots, F_{k,n_k}) $ be a tuple of dice, where each $ F_{k,i} = \\{f_{i,1}, f_{i,2}, \\dots, f_{i,6}\\} \\subseteq \\{1, 2, \\dots, 100\\} $ is the multiset of face values of the $ i $-th die.\n\n**Constraints**  \n1. $ 1 \\leq T \\leq \\text{unspecified} $  \n2. For each $ k \\in \\{1, \\dots, T\\} $:  \n   - $ 1 \\leq n_k \\leq 14 $  \n   - $ 0 \\leq x_k < 10^9 + 7 $  \n   - $ 1 \\leq f_{i,j} \\leq 100 $ for all $ i \\in \\{1, \\dots, n_k\\} $, $ j \\in \\{1, \\dots, 6\\} $\n\n**Objective**  \nFor each test case $ k $, compute the number of tuples $ (v_1, v_2, \\dots, v_{n_k}) $ such that:  \n$$\nv_i \\in F_{k,i} \\quad \\text{for all } i \\in \\{1, \\dots, n_k\\}, \\quad \\text{and} \\quad \\prod_{i=1}^{n_k} v_i \\equiv x_k \\pmod{10^9 + 7}\n$$","simple_statement":"You have n dice, each with 6 faces showing numbers from 1 to 100.  \nThrow all dice once, multiply the results, and take modulo 10^9+7.  \nCount how many different ways to get the product equal to x.","has_page_source":false}