# Altimetrik Java Hiring Challenge | Powers Everywhere! | Answer

Today Omar is studying a math lecture, then he decides to solve its exercises. After finishing the study, Omar now thinks in the following question. There are many special numbers that could be in the formula where indicates the base number, indicates the power number. But there are also many numbers that couldn't be formed in this formula so the question is to find the minimum absolute difference between a given number and the nearest special number.

Note: for a special number, integers .

Can you help Omar in this exercise ?

Input:

Given an integer , number of test cases.

For each test case:

In the first line: given an integer , the number of queries.

Then next lines follow, each line has an integer .

For each test case:

In the first line: given an integer , the number of queries.

Then next lines follow, each line has an integer .

Output:

For each test case: answer the queries, every result in a separate line.

Constraints:

.

.

.

.

.

Note: In large Input files: use faster input, output methods.

Explanation