{"raw_statement":[{"iden":"statement","content":"Setsuna is almost out of money! Therefore, she always thinks about ways to get rich overnight. \n\nShe finds that buying lottery tickets is a wonderful choice, and she decides to use her lucky number as the lottery number.\n\nSetsuna uses some unique methods to pick her lucky numbers. She will first select $n$ magic cards. Each card is written with a digit between $0$ and $9$ inclusively. Then she will use some cards to construct a number. She believes that the largest number she can construct which can be divided by 4 is her lucky number.\n\nIt is unnecessary to use all the cards, and it is possible that such lucky number does not exist.\n\nBecause she is daydreaming of getting rich, only you can help her find this lucky number.\n\nThe input consists of multiple test cases. \n\nThe first line contains a single integer $t (1 <= t <= 3 times 10^5)$, indicating the number of test cases.\n\nEach of the next $t$ lines contains $10$ integers $c_0, c_1, \\\\\\\\cdots, c_9 (0 <= c_i <= 10^5, sum_{i = 0}^9 c_i > 0)$, where $c_i$ indicates the number of cards written with number $i$.\n\nIt is guaranteed that the sum of $sum_{i = 0}^9 c_i$ of all test cases does not exceed $3 times 10^5$.\n\nFor each test case given in the input, print the lucky number(without leading zero) or $-1$ if such lucky number does not exist.\n\n"},{"iden":"input","content":"The input consists of multiple test cases. The first line contains a single integer $t (1 <= t <= 3 times 10^5)$, indicating the number of test cases.Each of the next $t$ lines contains $10$ integers $c_0, c_1, \\\\\\\\cdots, c_9 (0 <= c_i <= 10^5, sum_{i = 0}^9 c_i > 0)$, where $c_i$ indicates the number of cards written with number $i$.It is guaranteed that the sum of $sum_{i = 0}^9 c_i$ of all test cases does not exceed $3 times 10^5$."},{"iden":"output","content":"For each test case given in the input, print the lucky number(without leading zero) or $-1$ if such lucky number does not exist."}],"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, let $ c_i \\in \\mathbb{Z}_{\\geq 0} $ denote the count of cards with digit $ i \\in \\{0, 1, \\dots, 9\\} $, where $ \\sum_{i=0}^9 c_i > 0 $.\n\n**Constraints**  \n1. $ 1 \\leq t \\leq 3 \\times 10^5 $  \n2. $ 0 \\leq c_i \\leq 10^5 $ for all $ i \\in \\{0, 1, \\dots, 9\\} $  \n3. $ \\sum_{i=0}^9 c_i > 0 $ for each test case  \n4. Total sum of $ \\sum_{i=0}^9 c_i $ across all test cases $ \\leq 3 \\times 10^5 $\n\n**Objective**  \nFor each test case, find the largest integer (without leading zeros) that can be formed using a non-empty subset of the available cards such that the number is divisible by 4. If no such number exists, output $-1$.  \n\nA number is divisible by 4 if and only if its last two digits form a number divisible by 4.","simple_statement":"Given digits 0-9 with counts, find the largest number (no leading zeros) you can form using some of them that is divisible by 4. If impossible, return -1.","has_page_source":false}