Counting linear congruential generators

A linear congruential generator (LCG) is a triple of integers (A, C, M) used to generate pseudorandom numbers by the formula xn+1=(Axn+C) mod M applied recurrently to a chosen initial value x0.

The task

By the assumption that there are ranges specified for the parameters A, C, M, count the number of full length period LCGs for which M is the product of exactly P distinct primes (where P is a given number).

Hint: It might be helpful to use the inclusion-exclusion principle.


Input

The input consists of four lines. The first line contains integers Amin, Amax. The second line contains integers Cmin, Cmax. The third line contains integers Mmin, Mmax. Each pair of integers is separated by a space. The fourth line contains an integer P. The following limits hold:
1 ≤ AminAmax ≤ 3 × 1011, 1 ≤ CminCmax ≤ 3 × 1011, 1 ≤ MminMmax ≤ 2 × 1010, MmaxAmax, 2 ≤ P ≤ 9.

Output

The output consists of one line containing integer R which is equal to the number of LCGs (A, C, M) that meet the following conditions:

It holds that R does not exceed 5 × 1016.

Example 1

Input
3 14
3 6
2 7
2
Output
2
The two feasible LCGs are as follows:

Example 2

Input
10 126
20 30
4 46
3
Output
14
The fourteen feasible LCGs are as follows:

Public data

The public data set is intended for easier debugging and approximate program correctness checking. The public data set is stored also in the upload system and each time a student submits a solution it is run on the public dataset and the program output to stdout and stderr is available to him/her.
Link to public data set