Package for this problem was not updated by the problem writer or Codeforces administration after we’ve upgraded the judging servers. To adjust the time limit constraint, solution execution time will be multiplied by 2. For example, if your solution works for 400 ms on judging servers, then value 800 ms will be displayed and used to determine the verdict.

Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

No tag edit access

C. Anniversary

time limit per test

2 secondsmemory limit per test

256 megabytesinput

standard inputoutput

standard outputThere are less than 60 years left till the 900-th birthday anniversary of a famous Italian mathematician Leonardo Fibonacci. Of course, such important anniversary needs much preparations.

Dima is sure that it'll be great to learn to solve the following problem by the Big Day: You're given a set *A*, consisting of numbers *l*, *l* + 1, *l* + 2, ..., *r*; let's consider all its *k*-element subsets; for each such subset let's find the largest common divisor of Fibonacci numbers with indexes, determined by the subset elements. Among all found common divisors, Dima is interested in the largest one.

Dima asked to remind you that Fibonacci numbers are elements of a numeric sequence, where *F*_{1} = 1, *F*_{2} = 1, *F*_{n} = *F*_{n - 1} + *F*_{n - 2} for *n* ≥ 3.

Dima has more than half a century ahead to solve the given task, but you only have two hours. Count the residue from dividing the sought largest common divisor by *m*.

Input

The first line contains four space-separated integers *m*, *l*, *r* and *k* (1 ≤ *m* ≤ 10^{9}; 1 ≤ *l* < *r* ≤ 10^{12}; 2 ≤ *k* ≤ *r* - *l* + 1).

Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use cin, cout streams or the %I64d specifier.

Output

Print a single integer — the residue from dividing the sought greatest common divisor by *m*.

Examples

Input

10 1 8 2

Output

3

Input

10 1 8 3

Output

1

Codeforces (c) Copyright 2010-2020 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Jan/26/2020 16:29:52 (f3).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|