Farey sequences
Execution time limit is 1 second
Runtime memory usage limit is 128 megabytes
A fraction h / k is called a proper fraction if it lies between 0 and 1 and if h and k have no common factors. For any positive integer n ≥ 1, the Farey sequence of order n, F[n]
, is the sequence of all proper fractions with denominators which do not exceed n together with the "fraction" 1 / 1, arranged in increasing order. So, for example, F[5]
is the sequence:
For a given n, you are to find the k-th fraction in the sequence F[n]
.
Input
Input consists of a sequence of lines containing two natural numbers n and k, 1 ≤ n ≤ 1000 and k sufficiently small such that there is the k-th term in F[n]
. (The length of F[n]
is approximately 0.3039635n^2).
Output
For each line of input print one line giving the k-th element of F[n]
in the format as shown in example.
Examples
Input #1
Answer #1
Submissions 940
Acceptance rate 54%