Aliquot Fractions#261

Aliquot Fractions

1 second
64 megabytes
Hard

In ancient Egypt, only fractions with numerators equal to one, called unit fractions of the form , and the fraction were used. Fractions with numerators greater than one were written as a sum of unit fractions. For example:

2/5 = 1/5 + 1/5,\quad 2/7 = 1/4 + 1/28.

Given natural numbers , , , and , find the number of ways to represent the fraction as a sum of unit fractions such that the number of terms does not exceed and the product of the denominators equals . Different orders of the same terms are counted as one way.

For example, the Egyptian fraction with P=2, Q=3, A=120, N=3 can be represented in ways using unit fractions:

Input

Each test consists of several test cases, with no more than cases. Each input line contains four numbers , , , and separated by spaces.

0 \le P, Q \le 800, 0 \le A \le 12000, 0 \le N \le 7.

The input ends with a line .

Output

For each test case, print the answer on a separate line.

Examples

Example 1

Loading
Loading