{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003e\u003c/p\u003eElina is reading a book written by Rujia Liu, which introduces a strange way to express non-negative integers. The way is described as following:\u003cp\u003e\u003c/p\u003e\u003cp\u003eChoose \u003ci\u003ek\u003c/i\u003e different positive integers \u003ci\u003ea\u003c/i\u003e\u003csub\u003e1\u003c/sub\u003e, \u003ci\u003ea\u003c/i\u003e\u003csub\u003e2\u003c/sub\u003e, \u003cspan lang\u003d\"en-us\"\u003e…, \u003ci\u003ea\u003csub\u003ek\u003c/sub\u003e\u003c/i\u003e. For some non-negative \u003ci\u003em\u003c/i\u003e, divide it by every \u003ci\u003ea\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e (1 ≤ \u003ci\u003ei\u003c/i\u003e ≤ \u003ci\u003ek\u003c/i\u003e) to find the remainder \u003ci\u003er\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e. If \u003ci\u003ea\u003c/i\u003e\u003csub\u003e1\u003c/sub\u003e, \u003ci\u003ea\u003c/i\u003e\u003csub\u003e2\u003c/sub\u003e, …, \u003ci\u003ea\u003csub\u003ek\u003c/sub\u003e\u003c/i\u003e are properly chosen, m can be determined, then the pairs (\u003ci\u003ea\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e, \u003ci\u003er\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e) can be used to express \u003ci\u003em\u003c/i\u003e.\u003c/span\u003e\u003c/p\u003e\u003cp\u003e“It is easy to calculate the pairs from \u003ci\u003em\u003c/i\u003e, ” said Elina. “But how can I find \u003ci\u003em\u003c/i\u003e from the pairs?”\u003c/p\u003e\u003cp\u003eSince Elina is new to programming, this problem is too difficult for her. Can you help her?\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eThe input contains multiple test cases. Each test cases consists of some lines.\u003c/p\u003e\u003cul\u003e\u003cli\u003eLine 1: Contains the integer \u003ci\u003ek\u003c/i\u003e.\u003c/li\u003e\u003cli\u003eLines 2 ~ \u003ci\u003ek\u003c/i\u003e + 1: Each contains a pair of integers \u003ci\u003ea\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e, \u003ci\u003er\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e (1 ≤ \u003ci\u003ei\u003c/i\u003e ≤ \u003ci\u003ek\u003c/i\u003e).\u003c/li\u003e\u003c/ul\u003e\u003cp\u003e\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003eOutput the non-negative integer \u003ci\u003em\u003c/i\u003e on a separate line for each test case. If there are multiple possible values, output the smallest one. If there are no possible values, output \u003ctt\u003e-1\u003c/tt\u003e.\u003c/p\u003e\u003cp\u003e\u003c/p\u003e"}},{"title":"Sample","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e2\r\n8 7\r\n11 9\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e31\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Hint","value":{"format":"HTML","content":"\u003cp\u003eAll integers in the input and the output are non-negative and can be represented by 64-bit integral types.\u003c/p\u003e"}}]}