P16829 [HackerEarth] Mehta was doing his usual office work when all of a sudden, he refreshes his Gmail. It contained the mail of his not so old friend who was still jobless and asking Mehta for a certain he
提高
题目描述

Mehta was doing his usual office work when all of a sudden, he refreshes his Gmail. It contained the mail of his not so old friend who was still jobless and asking Mehta for a certain help. His Friend Verma had applied for a certain hiring challenge for some certain company. So, Verma gave Mehta a link of the contest which contained the following question. So, you being a colleague of Mehta decide to help him with his friend's task.

Task:
Given three integers A, B and K, you need to report the K^th number between A and B(both inclusive), satisfying the property that: the number does not contain a digit 'zero' and product of digits of number is a perfect square. If there doesn't exist that K^th number output "-1"(without quotes).

Input:
First Line contains the number of test cases T.
Next T lines contain 3 space separated integers A, B, K as mentioned in the task.

Output:
Output T lines as answer for every test case.

Constraints:
1 ≤ T ≤ 100
1 ≤ A ≤ B ≤ 10^18
1 ≤ K ≤ 10^7

SAMPLE INPUT
3
1 10 4
8 14 2
1 1000 23

SAMPLE OUTPUT
-1
11
119

Explanation

Sample Case#1: {1,4,9} are the only numbers that satisfy above property, so there is no 4th number, hence answer is -1.
Sample Case#2: {9,11,14} are three numbers in range [8,14] which have product of digits as perfect square, so, 2nd number in range [8,14] will be 11.

输入格式

见题面

输出格式

见题面

样例输入
11 598125188620204729 796408109138963280 3414958 263126113473286117 577665049804655234 4305811 10 15 213 1456 34523 1000000 217645033884593604 906357340499884328 3560236 333551766071424061 420913569457334384 6681760 178306623178108078 202198977821912169 4565049 270676556192590285 326059593177555844 1429470 661672400980855361 697220714498434156 7098693 403075036039876724 596384394601799697 3789949 319322829618307868 625023287235344780 5101420
样例输出
238627111416281716 556788455775475644 575971111368992299 649527872843445396 888789872575715445 636811111261373721 271111111198637291 291461267536929751 523198111411216115 171911111218289171 42711111233347926 58872115438571685 81234257659533574 18869757131528364 456329273362463375 663247856194957787 614893116595488234 461111111355481955 169616751455912537 286878695424179653 26111111114848968 118331111354958261 -1 27698391669668227 332381111255397718 553111111281552699 74111111231175659 211111111278673638 13797111196714172 557411911284974477 899861111347577875 75839958363888766 155169531375766123 778914534951437172 2188581286668658 441797811111814149 41111111219243883 113111111223513539 -1 268922116232769127 254917711424581948 125936591157827154 251111111424615416 425353645114528934 511111111463556856 78281111329441379 368427237145399858 299245566882814229 132127323683887886 433624829983645395 198111111168841139 25984861358131619 76647575872342813 383873159481735814 -1 121394278637687337 226867549656822337 571244795223779813 585991111328818641 44111111232365352 891818911146813323 754611111566791767 655311111173796717 331599817759288212 158447672294321635 411111111245758676 254333649323975736 547311111554586755 159111111438151438 411111111199121489 17151921179337785 611111111296494929 185193111116446651 46684668625323583 314842111221428322 19937946864897883 65426712589271444 179521511236687469 21919846464446641 261632136214473878 372341111174837973 4886691233569453 187111111349649676 168753861135742899 243745111368657646 53436311383524912 326718359799834951 84728959724859442 395116566279878141 365628376432771795 635521111238437711 -1