The Humongous Sum

5

1 votes
Hard
Problem

You are given integers and . You need to find the sum of integers , such that   and, and  have some common divisor excluding . Since this sum can be too large, print it modulo .

Input Format

The input is a single line containing  space separated integers , and .

Output Format

Print a single intger equal to the required sum modulo .

Constraints

Sample Input
12 5 27
Sample Output
248
Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

The values of which satisfy the given conditions for , and are . The sum of these numbers is equal to .

Editor Image

?