Given a positive integer n and a non-negative integer m, find the exact…

PYQ Accenture Hiring Assessment 2026

Given a positive integer n and a non-negative integer m, find the exact integer nth root of m. Print -1 if no integer x satisfies xn = m.

Input format

One line containing two space-separated integers n and m.

Output format

Print the non-negative integer x when xn = m exactly; otherwise print -1.

Examples

Input

Output

Explanation

3 8

2

2³ = 8

3 9

-1

No integer cube root of 9 exists.

4 16

2

2⁴ = 16

Constraints

  • 1 ≤ n ≤ 9

  • 0 ≤ m ≤ 20

Attempted by 11 students.

Sign up free to check your answer

Sign up free

Explore the full course: Coding For Placement

Loading lesson…