{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003eIf \u003ci\u003ea\u003c/i\u003e and \u003ci\u003ed\u003c/i\u003e are relatively prime positive integers, the arithmetic sequence beginning with \u003ci\u003ea\u003c/i\u003e and increasing by \u003ci\u003ed\u003c/i\u003e, i.e., \u003ci\u003ea\u003c/i\u003e, \u003ci\u003ea\u003c/i\u003e + \u003ci\u003ed\u003c/i\u003e, \u003ci\u003ea\u003c/i\u003e + 2\u003ci\u003ed\u003c/i\u003e, \u003ci\u003ea\u003c/i\u003e + 3\u003ci\u003ed\u003c/i\u003e, \u003ci\u003ea\u003c/i\u003e + 4\u003ci\u003ed\u003c/i\u003e, ..., contains infinitely many prime numbers. This fact is known as Dirichlet\u0027s Theorem on Arithmetic Progressions, which had been conjectured by Johann Carl Friedrich Gauss (1777 - 1855) and was proved by Johann Peter Gustav Lejeune Dirichlet (1805 - 1859) in 1837.\u003c/p\u003e\u003cp\u003eFor example, the arithmetic sequence beginning with 2 and increasing by 3, i.e.,\u003c/p\u003e\u003cblockquote\u003e\u003cp\u003e2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35, 38, 41, 44, 47, 50, 53, 56, 59, 62, 65, 68, 71, 74, 77, 80, 83, 86, 89, 92, 95, 98, ... ,\u003c/p\u003e\u003c/blockquote\u003e\u003cp\u003econtains infinitely many prime numbers\u003c/p\u003e\u003cblockquote\u003e\u003cp\u003e2, 5, 11, 17, 23, 29, 41, 47, 53, 59, 71, 83, 89, ... .\u003c/p\u003e\u003c/blockquote\u003e\u003cp\u003eYour mission, should you decide to accept it, is to write a program to find the \u003ci\u003en\u003c/i\u003eth prime number in this arithmetic sequence for given positive integers \u003ci\u003ea\u003c/i\u003e, \u003ci\u003ed\u003c/i\u003e, and \u003ci\u003en\u003c/i\u003e.\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eThe input is a sequence of datasets. A dataset is a line containing three positive integers \u003ci\u003ea\u003c/i\u003e, \u003ci\u003ed\u003c/i\u003e, and \u003ci\u003en\u003c/i\u003e separated by a space. \u003ci\u003ea\u003c/i\u003e and \u003ci\u003ed\u003c/i\u003e are relatively prime. You may assume \u003ci\u003ea\u003c/i\u003e \u0026lt;\u003d 9307, \u003ci\u003ed\u003c/i\u003e \u0026lt;\u003d 346, and \u003ci\u003en\u003c/i\u003e \u0026lt;\u003d 210.\u003c/p\u003e\u003cp\u003eThe end of the input is indicated by a line containing three zeros separated by a space. It is not a dataset.\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003eThe output should be composed of as many lines as the number of the input datasets. Each line should contain a single integer and should never contain extra characters.\u003c/p\u003e\u003cp\u003eThe output integer corresponding to a dataset \u003ci\u003ea\u003c/i\u003e, \u003ci\u003ed\u003c/i\u003e, \u003ci\u003en\u003c/i\u003e should be the \u003ci\u003en\u003c/i\u003eth prime number among those contained in the arithmetic sequence beginning with \u003ci\u003ea\u003c/i\u003e and increasing by \u003ci\u003ed\u003c/i\u003e.\u003c/p\u003e\u003cp\u003eFYI, it is known that the result is always less than 10\u003csup\u003e6\u003c/sup\u003e (one million) under this input condition.\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\u003e367 186 151\r\n179 10 203\r\n271 37 39\r\n103 230 1\r\n27 104 185\r\n253 50 85\r\n1 1 1\r\n9075 337 210\r\n307 24 79\r\n331 221 177\r\n259 170 40\r\n269 58 102\r\n0 0 0\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e92809\r\n6709\r\n12037\r\n103\r\n93523\r\n14503\r\n2\r\n899429\r\n5107\r\n412717\r\n22699\r\n25673\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}