Time Limit: 1 second(s) | Memory Limit: 64 MB |
You are given 3 integers A, B and C per line, you have to find a prime number that has A digit B exactly times. As there could be multiple prime numbers that have A digit exactly B times, you’re given another integer C to find out a particular prime. So you have to print Cth prime number(0 indexed) that has A digit exactly B times (assuming that all primes are sorted initially). You are allowed to find primes between range (2 ≤ p ≤ 10^6).
Input
Input starts with an integer T (≤100000), denoting the number of test cases.
Each case has a line containing 3 integers a (0 ≤ a ≤ 9), b (1 ≤ b ≤ 5), c (0 ≤ c ≤ 49) denoting digit identifier, number of occurrences of that digit and which prime that satisfy the previous two criteria, respectively.
Output
For each case, print the prime number. If it’s not found print “Not Found!”(without quotes).
Sample Input |
Output for Sample Input |
6 2 1 30 9 5 30 2 1 1 2 2 2 9 3 1 1 4 1 |
Case 1: 1213 Case 2: Not Found! Case 3: 23 Case 4: 229 Case 5: 2999 Case 6: 11113 |
Developed and Maintained by
JANE ALAM JAN |
Copyright © 2012
LightOJ, Jane Alam Jan |