## Santa and Reindeer

View as PDF

Points: 7 (partial)
Time limit: 1.0s
Java 2.0s
Python 2.0s
Memory limit: 128M

Author:
Problem types
Allowed languages
Assembly, Awk, Brain****, C, C++, Clang, Clang++, COBOL, Coffee, D, Fortran, Go, Haskell, Java, JS, Kotlin, LOLCODE, Lua, Mono C#, Mono F#, NASM, NASM64, OCaml, Pascal, Perl, PHP, Processing, Python, Racket, Ruby, Rust, Sed, TCL, Text, Turing

After a long day at work, Santa comes home only to discover that his newborn reindeer have been numbered wrong by Mrs. Clause.

Normally, the baby reindeer would be numbered . However, Mrs. Clause has absentmindedly numbered the th reindeer the value of the th prime number instead.

Santa is tired, so he wants you to deal with the logistic problems that arise with this new numbering. His assistant will ask you questions. The th question will ask you for the regular number of the reindeer with the current number . You must find the value of this regular number or that no reindeer is labeled the given number.

#### Input Specification

The first line will contain two space-separated integers, and .

The next lines will each contain one integer, .

#### Output Specification

For each question, output the regular number of the reindeer in question on a separate line. If there is no reindeer with that number, output -1 instead.

#### Constraints

No further constraints.

#### Sample Input

5 4
2
5
11
20

#### Sample Output

1
3
5
-1

#### Explanation for Sample Output

is the first prime number, so its regular number is .

and are the third and fifth prime numbers respectively, so their regular numbers are and .

is not a prime number, so it has no regular number attached to it.