Problem Statement
You are given three integers , and .
You have the following infinite sequence \(S = [1 \small\text{ mod } \normalsize k,\ \ \ (1 + 2) \small\text{ mod }\normalsize k,\ \ \ (1 + 2 + 3) \small\text{ mod }\normalsize k,\ ... ]\), in other words \(S_i = (\sum_{j=1}^ij) \small\text{ mod }\normalsize k\).
Determine at which index (one-indexed) the occurrence of is in the sequence if occurs at least times, otherwise output .
Input Format
Your first line will contain three space-separated integers , and respectively.
Output Format
You should output a single integer, representing the index (one-indexed) in at which the occurrence of appears. If it does not appear at least times, then output .
Constraints
Sample Cases
Input 1
1 1 10
Output 1
1
Input 2
2 1 10
Output 2
6
Input 3
20 2 13
Output 3
124
Input 4
20 2 10
Output 4
-1
Template
n, x, k = map(int, input().split())
# print your output
Comments