{"raw_statement":[{"iden":"statement","content":"The owls have the following equation:\n\nY = a × x2 + b × x\n\nWith a, b, and N given, they decide to put into a set the integer values of Y that are less than or equal to N and that are outputted from the equation from any positive integer x.\n\nWith that set of numbers, they come up with the problem of finding the winning digit among them.\n\nThe winning digit is a digit from 0 to 9 that will get the maximum number of points. How are points for a digit calculated you may ask? Well, be a bit more patient, I’m going to tell you now.\n\nFor each number in the set, if the digit was the most repeated digit or tied with other digits as the most repeated digit in the ith number of set S, then it would get one point from that ith number.\n\nCan you tell the owls what the winning digit is?\n\nThe first line of input is T – the number of test cases.\n\nThe first line of each test case is a, b, and N (1 ≤ a, b, N ≤ 105).\n\nFor each test case, print on a line the winning digit with the maximum number of points. If there is a tie, print the minimum digit among them. If the set is empty, print  - 1.\n\n"},{"iden":"input","content":"The first line of input is T – the number of test cases.The first line of each test case is a, b, and N (1 ≤ a, b, N ≤ 105)."},{"iden":"output","content":"For each test case, print on a line the winning digit with the maximum number of points. If there is a tie, print the minimum digit among them. If the set is empty, print  - 1."}],"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 $ a, b, N \\in \\mathbb{Z} $ with $ 1 \\leq a, b, N \\leq 10^5 $.  \nDefine the quadratic function $ Y(x) = a \\cdot x^2 + b \\cdot x $ for $ x \\in \\mathbb{Z}^+ $.  \n\nLet $ S = \\{ Y(x) \\mid x \\in \\mathbb{Z}^+, Y(x) \\leq N \\} $ be the set of valid outputs.  \n\n**Constraints**  \n1. $ 1 \\leq T \\leq 10^5 $  \n2. $ 1 \\leq a, b, N \\leq 10^5 $  \n3. $ S $ may be empty.  \n\n**Objective**  \nFor each $ y \\in S $, let $ d(y) $ be the multiset of decimal digits of $ y $.  \nFor each digit $ d \\in \\{0, 1, \\dots, 9\\} $, define its score $ s(d) $ as the number of $ y \\in S $ in which $ d $ is among the most frequently occurring digits (i.e., tied for maximum frequency in $ d(y) $).  \n\nFind $ \\min \\{ d \\in \\{0, \\dots, 9\\} \\mid s(d) = \\max_{d' \\in \\{0,\\dots,9\\}} s(d') \\} $.  \nIf $ S = \\emptyset $, output $ -1 $.","simple_statement":"Given a quadratic equation Y = a×x² + b×x, and a limit N, find all positive integer values of x that make Y ≤ N. For each such Y, count the most frequent digit(s) in its decimal representation. The digit that appears most often across all such Ys (with ties broken by choosing the smallest digit) is the winning digit. If no Y exists, return -1.","has_page_source":false}