{"trustable":false,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003e \u003ca href\u003d\"http://uva.onlinejudge.org/external/15/1583.pdf\"\u003e\u003cimg alt\u003d\"Download as PDF\" height\u003d\"26\" src\u003d\"http://uva.onlinejudge.org/components/com_onlinejudge/images/button_pdf.png\" title\u003d\"Download as PDF\" width\u003d\"100\" /\u003e\u003c/a\u003e\u003c/p\u003e \n\u003cdiv\u003e English!!English!!English\u0026nbsp;Description!!Do it!!\n\u003c/div\u003e \n\u003cp\u003e For a positive integer \u003ci\u003eN\u003c/i\u003e , the digit-sum of \u003ci\u003eN\u003c/i\u003e is defined as the sum of \u003ci\u003eN\u003c/i\u003e itself and its digits. When \u003ci\u003eM\u003c/i\u003e is the digitsum of \u003ci\u003eN\u003c/i\u003e , we call \u003ci\u003eN\u003c/i\u003e a generator of \u003ci\u003eM\u003c/i\u003e . \u003c/p\u003e \n\u003cp\u003e For example, the digit-sum of 245 is 256 (\u003d 245 + 2 + 4 + 5). Therefore, 245 is a generator of 256.\u003c/p\u003e \n\u003cp\u003e Not surprisingly, some numbers do not have any generators and some numbers have more than one generator. For example, the generators of 216 are 198 and 207.\u003c/p\u003e \n\u003cp\u003e You are to write a program to find the smallest generator of the given integer.\u003c/p\u003e \n\u003cp\u003e \u0026nbsp;\u003c/p\u003e \n\u003ch2\u003e \u003ca\u003e Input\u003c/a\u003e\u0026nbsp;\u003c/h2\u003e \n\u003cp\u003e Your program is to read from standard input. The input consists of \u003ci\u003eT\u003c/i\u003e test cases. The number of test cases \u003ci\u003eT\u003c/i\u003e is given in the first line of the input. Each test case takes one line containing an integer \u003ci\u003eN\u003c/i\u003e , 1\u003cimg align\u003d\"MIDDLE\" alt\u003d\"$ \\le$\" height\u003d\"31\" src\u003d\"http://uva.onlinejudge.org/external/15/3355img1.png\" width\u003d\"18\" /\u003e\u003ci\u003eN\u003c/i\u003e\u003cimg align\u003d\"MIDDLE\" alt\u003d\"$ \\le$\" height\u003d\"31\" src\u003d\"http://uva.onlinejudge.org/external/15/3355img1.png\" width\u003d\"18\" /\u003e100, 000 . \u003c/p\u003e \n\u003cp\u003e \u0026nbsp;\u003c/p\u003e \n\u003ch2\u003e \u003ca\u003e Output\u003c/a\u003e\u0026nbsp;\u003c/h2\u003e \n\u003cp\u003e Your program is to write to standard output. Print exactly one line for each test case. The line is to contain a generator of \u003ci\u003eN\u003c/i\u003e for each test case. If \u003ci\u003eN\u003c/i\u003e has multiple generators, print the smallest. If \u003ci\u003eN\u003c/i\u003e does not have any generators, print 0. \u003c/p\u003e \n\u003cp\u003e The following shows sample input and output for three test cases.\u003c/p\u003e \n\u003cp\u003e \u0026nbsp;\u003c/p\u003e \n\u003ch2\u003e \u003ca\u003e Sample Input\u003c/a\u003e\u0026nbsp;\u003c/h2\u003e \n\u003cp\u003e \u0026nbsp;\u003c/p\u003e \n\u003cpre\u003e\r\n3 \r\n216 \r\n121 \r\n2005\r\n\u003c/pre\u003e \n\u003cp\u003e \u0026nbsp;\u003c/p\u003e \n\u003ch2\u003e \u003ca\u003e Sample Output\u003c/a\u003e\u0026nbsp;\u003c/h2\u003e \n\u003cp\u003e \u0026nbsp;\u003c/p\u003e \n\u003cpre\u003e\r\n198 \r\n0 \r\n1979\r\n\u003c/pre\u003e"}}]}