{"raw_statement":[{"iden":"statement","content":"Minh has a box of pencils. The box is a rectangle of size M * N, where position (i, j) has a pencil with a length of exactly i * N + j (0 ≤ i ≤ M - 1,  0 ≤ j ≤ N - 1). Note that position (0, 0) does not have any pencil hence having a length of 0. \n\nHe wonders if he could select a sub-rectangle of the box and join all the pencils within that sub-rectangle together, to get a new long pencil that has a specific length L that he wants.\n\nYour task is to find a sub-rectangle of the box in which the total length of the contained pencils is L and return the area of that the sub-rectangle. If there are multiple solutions, return the smallest possible area. If there’s no such sub-rectangle, return  - 1.\n\nThe input file consists of several datasets. The first line of the input file contains the number of datasets which is a positive integer and is not greater than 150. The following lines describe the datasets. \n\nEach dataset contains three space-separated numbers M, N and L (1 ≤ M, N ≤ 106, 1 ≤ L ≤ 1012) written in one line. \n\nFor each dataset, write in one line the smallest possible area of the sub-rectangle in which the total sum of pencil lengths is L. Write in one line  - 1 if there is no such sub-rectangle.\n\n"},{"iden":"input","content":"The input file consists of several datasets. The first line of the input file contains the number of datasets which is a positive integer and is not greater than 150. The following lines describe the datasets. Each dataset contains three space-separated numbers M, N and L (1 ≤ M, N ≤ 106, 1 ≤ L ≤ 1012) written in one line. "},{"iden":"output","content":"For each dataset, write in one line the smallest possible area of the sub-rectangle in which the total sum of pencil lengths is L. Write in one line  - 1 if there is no such sub-rectangle."},{"iden":"examples","content":"Input42 3 83 3 103 3 361000000 1000000 1000000000000Output4-192"}],"translated_statement":null,"sample_group":[],"show_order":[],"formal_statement":"**Definitions**  \nLet $ M, N \\in \\mathbb{Z}^+ $ denote the dimensions of the grid, with positions $(i, j)$ for $ 0 \\leq i \\leq M-1 $, $ 0 \\leq j \\leq N-1 $.  \nThe pencil at position $(i, j)$ has length $ i \\cdot N + j $.  \n\nLet $ L \\in \\mathbb{Z}^+ $ be the target total length.\n\n**Constraints**  \n1. $ 1 \\leq M, N \\leq 10^6 $  \n2. $ 1 \\leq L \\leq 10^{12} $  \n\n**Objective**  \nFind the smallest area $ A = (i_2 - i_1 + 1) \\cdot (j_2 - j_1 + 1) $ of a sub-rectangle defined by $ i_1 \\leq i \\leq i_2 $, $ j_1 \\leq j \\leq j_2 $, such that:  \n$$\n\\sum_{i=i_1}^{i_2} \\sum_{j=j_1}^{j_2} (i \\cdot N + j) = L\n$$  \nIf no such sub-rectangle exists, return $-1$.","simple_statement":"You are given a grid of size M×N. Each cell (i, j) has a pencil of length i*N + j.  \nFind the smallest-area rectangle such that the sum of all pencil lengths inside it equals L.  \nIf no such rectangle exists, return -1.","has_page_source":false}