{"trustable":true,"sections":[{"title":"","value":{"format":"MD","content":"\u003ch3\u003e Read problems statements in \u003ca target\u003d\"_blank\" href\u003d\"https://www.codechef.com/download/translated/COOK61/mandarin/DUALPAL.pdf\"\u003eMandarin Chinese\u003c/a\u003e and \u003ca target\u003d\"_blank\" href\u003d\"https://www.codechef.com/download/translated/COOK61/russian/DUALPAL.pdf\"\u003eRussian\u003c/a\u003e as well.\u003c/h3\u003e\r\n\r\n\u003cp\u003eA number is called a \u003cem\u003eDual Palindrome\u003c/em\u003e if it\u0027s representation in bases \u003cb\u003eB1\u003c/b\u003e and \u003cb\u003eB2\u003c/b\u003e are both palindromes. e.g. Let \u003cb\u003eB1\u003c/b\u003e \u003d 3, \u003cb\u003eB2\u003c/b\u003e \u003d 4, then number 130 (in base 10) will be called a \u003cem\u003eDual Palindrome\u003c/em\u003e, as it is palindrome in base 3 (11211) as well as in base 4 (2002). However, it is not a \u003cem\u003eDual Palindrome\u003c/em\u003e for \u003cb\u003eB1\u003c/b\u003e \u003d 3 and \u003cb\u003eB2\u003c/b\u003e \u003d 5 as it\u0027s not a palindrome in base 5(1010).\u003c/p\u003e\r\n\r\n\u003cp\u003eGiven two integers \u003cb\u003eB1\u003c/b\u003e and \u003cb\u003eB2\u003c/b\u003e, Chef wants to find Dual Palindromes less than \u003cb\u003e2\u003csup\u003e60\u003c/sup\u003e\u003c/b\u003e. If there are more than 1000 Dual Palindromes, then output the first 1000 only (these numbers should be in base 10).\u003c/p\u003e\r\n\r\n\r\n\u003ch3\u003eInput\u003c/h3\u003e\r\n\u003cp\u003eThe fine line of the input contains an integer \u003cb\u003eT\u003c/b\u003e denoting the number of test cases.\u003c/p\u003e Each test case consists of a single line containing two space separated integers: \u003cb\u003eB1\u003c/b\u003e and \u003cb\u003eB2\u003c/b\u003e, respectively.\r\n\r\n\u003ch3\u003eOutput\u003c/h3\u003e\r\n\u003cp\u003eFor each test case, output a list of space separated integers which are Dual Palindromes less than \u003cb\u003e2\u003csup\u003e60\u003c/sup\u003e\u003c/b\u003e for the input bases. If there are more than 1000 Dual Palindromes, then output the first 1000 only. The numbers should be printed in an ascending order.\u003c/p\u003e\r\n\r\n\u003ch3\u003eConstraints\u003c/h3\u003e\r\n\u003cul\u003e\r\n\u003cli\u003e\u003cb\u003e1\u003c/b\u003e ≤ \u003cb\u003eT\u003c/b\u003e ≤ \u003cb\u003e5\u003c/b\u003e\u003c/li\u003e\r\n\u003cli\u003e \u003cb\u003e2\u003c/b\u003e ≤ \u003cb\u003eB1\u003c/b\u003e \u003c \u003cb\u003eB2\u003c/b\u003e ≤ \u003cb\u003e16\u003c/b\u003e \u003c/li\u003e\r\n\u003c/ul\u003e"}},{"title":"Sample 1","value":{"format":"MD","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\u003e1\r\n2 3\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e1 6643 1422773 5415589 90396755477 381920985378904469\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}