{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003eGiven a \u003ci\u003eN\u003c/i\u003e × \u003ci\u003eN\u003c/i\u003e matrix A, whose element in the \u003ci\u003ei\u003c/i\u003e-th row and \u003ci\u003ej\u003c/i\u003e-th column \u003ci\u003eA\u003csub\u003eij\u003c/sub\u003e\u003c/i\u003e is an number that equals \u003ci\u003ei\u003c/i\u003e\u003csup\u003e2\u003c/sup\u003e + 100000 × \u003ci\u003ei\u003c/i\u003e + \u003ci\u003ej\u003c/i\u003e\u003csup\u003e2\u003c/sup\u003e - 100000 × \u003ci\u003ej\u003c/i\u003e + \u003ci\u003ei\u003c/i\u003e × \u003ci\u003ej\u003c/i\u003e, you are to find the \u003ci\u003eM\u003c/i\u003e-th smallest element in the matrix. \u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eThe first line of input is the number of test case.\u003cbr\u003eFor each test case there is only one line contains two integers, \u003ci\u003eN\u003c/i\u003e(1 ≤ \u003ci\u003eN\u003c/i\u003e ≤ 50,000) and \u003ci\u003eM\u003c/i\u003e(1 ≤ \u003ci\u003eM\u003c/i\u003e ≤ \u003ci\u003eN\u003c/i\u003e × \u003ci\u003eN\u003c/i\u003e). There is a blank line before each test case. \u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003eFor each test case output the answer on a single line.\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\u003e12\r\n\r\n1 1\r\n\r\n2 1\r\n\r\n2 2\r\n\r\n2 3\r\n\r\n2 4\r\n\r\n3 1\r\n\r\n3 2\r\n\r\n3 8\r\n\r\n3 9\r\n\r\n5 1\r\n\r\n5 25\r\n\r\n5 10\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e3\r\n-99993\r\n3\r\n12\r\n100007\r\n-199987\r\n-99993\r\n100019\r\n200013\r\n-399969\r\n400031\r\n-99939\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}