The Alchemist and a Simple Problem

0

0 votes
Easy-Medium
Problem

The Alchemist gives you a very simple problem, calculate (NR)%M

Input:

The first line of input contains an integer T denoting the number of test cases .

Each line of test case contains 3 space separated integers N, R and M

Output:

For each test case, output the required answer in a new line.

Constraints:

1T100

1M105

M is square free and its largest prime factor is less than 50

Subtask 1: 10 Points

1RN10

Subtask 2: 20 Points

1RN100

Subtask 3: 70 Points

1RN105

Sample Input
3
4 2 28681
3 1 43710
5 3 3655
Sample Output
6
3
10
Time Limit: 0.2
Memory Limit: 256
Source Limit:
Editor Image

?