Company: Flipkart
Difficulty: easy
Primal Compass You are exploring the Primal Compass , an ancient device that reveals Dreamworlds by pointing to a sequence of prime numbers. Every prime the compass points to has a digit sum equal to a given integer N . Your task is to generate the first K prime numbers, in increasing order, whose digit sums are equal to N . The compass can only reach primes that are less than 100000 . The digit sum of a number is the sum of its decimal digits: the digit sum of 109 is 1 + 0 + 9 = 10 . Input Format The first line of input contains an integer N , representing the required digit sum. The second line of input contains an integer K , representing the number of prime numbers to be generated. Output Format Print the first K prime numbers whose digit sums equal N , separated by spaces, on a single line. If there are fewer than K such primes (less than 100000), print all the primes found. If no such prime numbers are found, print -1 . Constraints 1 <= N <= 50 1 <= K <= 10000 Sample