Time limit
2s
Memory limit
128 MB
Sort every reduced fraction p/q with denominator at most N in increasing order of value. Each fraction must satisfy 1 <= p < q <= N.
Find the Kth fraction in this sorted list.
The first line contains two natural numbers N and K, separated by a space.
1 <= N <= 40,000, and K does not exceed the total number of reduced fractions whose denominator is at most N.
If the Kth fraction is p/q, print p and q separated by a space. The two numbers p and q must be coprime.