{"raw_statement":[{"iden":"statement","content":"Povilas is developing a social network called \"Dwidder\". He almost have it finished. However, there is one major problem. Povilas is very polite and he would never publish swear words. But you can't say that about other users of \"Dwidder\".\n\nPovilas has almost solved this problem. He already prepared a dictionary which contains all the swear words. He will check every message word by word and see if any of the words are in the dictionary.\n\nHowever, \"Dwidder\" users are pretty smart. They know that if you leave the first and last letter in place and shuffle the inside ones, the word will remain readable. _For elamxpe, you can raed tihs snetence, dno't you?_ \"Dwidder\" users are not afraid to use this ability for the worse.\n\nPovilas needs your help. He is giving you the dictionary and the words from the message. You must tell if there are swear words in the message, even if the inside letters are shuffled.\n\nThe first line contains the number of test cases _T_ (T ≤ 10). In the first line of every test case there are numbers _n_ and _m_ (1 ≤ n, m ≤ 1000) — the size of the dictionary and the count of words in the message. In the following line there are _n_ strings — words from the dictionary — separated by a single space. In the next line there are _m_ strings — words from the message — separated by a single space. Every word consists of lowercase English letters and none of them are longer than 10 characters.\n\nFor each test case output one line containing “_Case #tc: s_”, where _tc_ is the number of the test case (starting from 1) and _s_ is a string consisting of zeroes and ones. The _i_-th character of the string corresponds to the _i_-th word from the message, '_1_' meaning that the word is a swear word and '_0_' that it's not.\n\n"},{"iden":"input","content":"The first line contains the number of test cases _T_ (T ≤ 10). In the first line of every test case there are numbers _n_ and _m_ (1 ≤ n, m ≤ 1000) — the size of the dictionary and the count of words in the message. In the following line there are _n_ strings — words from the dictionary — separated by a single space. In the next line there are _m_ strings — words from the message — separated by a single space. Every word consists of lowercase English letters and none of them are longer than 10 characters."},{"iden":"output","content":"For each test case output one line containing “_Case #tc: s_”, where _tc_ is the number of the test case (starting from 1) and _s_ is a string consisting of zeroes and ones. The _i_-th character of the string corresponds to the _i_-th word from the message, '_1_' meaning that the word is a swear word and '_0_' that it's not."},{"iden":"examples","content":"Input12 5pig goatpig gaot peg goat gotaOutputCase #1: 11010"}],"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\\} $, define:  \n- $ N_k, K_k \\in \\mathbb{Z}^+ $: sequence length and number of smallest elements to select.  \n- $ S_k, C_{1,k}, C_{2,k}, M_k \\in \\mathbb{Z} $: parameters for sequence generation.  \n\nLet $ A_k = (a_{k,1}, a_{k,2}, \\dots, a_{k,N_k}) $ be the sequence defined by:  \n$$\na_{k,1} = S_k, \\quad a_{k,i} = (C_{1,k} \\cdot a_{k,i-1} + C_{2,k}) \\bmod M_k \\quad \\text{for } i = 2, \\dots, N_k.\n$$\n\n**Constraints**  \n1. $ 1 \\le T \\le 20 $  \n2. For each $ k \\in \\{1, \\dots, T\\} $:  \n   - $ 1 \\le K_k \\le N_k \\le 10^6 $  \n   - $ 0 \\le S_k, C_{1,k}, C_{2,k}, M_k < 10^9 $  \n   - $ M_k \\ge 1 $\n\n**Objective**  \nFor each test case $ k $, output the $ K_k $ smallest elements of $ A_k $, sorted in ascending order.","simple_statement":"Given N, K, S, C1, C2, M, generate N numbers using:  \nA1 = S  \nAi = (C1 * Ai-1 + C2) mod M for i > 1  \nFind and print the K smallest numbers in ascending order.","has_page_source":false}