Infinite Sequence - 2#1212

Infinite Sequence - 2

2 seconds
128 megabytes
Very easy

Define an infinite sequence as follows:

Given , , , , and , find the -th element of the sequence (indices start from ).

Input

Five integers , , , , (0 \le n \le 10^{13}, 2 \le p, q \le 10^9, 0 \le x, y \le 10^9).

Output

Print the value of A_n.

Examples

Example 1

Loading
Loading

Example 2

Loading
Loading