Infinite Sequence#1211

Infinite Sequence

1 second
128 megabytes
Very easy

Define the infinite sequence as follows:

Input

Three integers , and (0 \le n \le 10^{12},\ 2 \le p, q \le 10^9).

Output

Print the value of A_n.

Examples

Example 1

Loading
Loading

Example 2

Loading
Loading