The N-th Positive Rational Number

Given N, return the N-th term of the diagonal enumeration of positive rationals where each group of constant numerator plus denominator is listed with decreasing numerator.

Easy3MathImplementationBrute forceInterviewNo attempts yetTime limit1sMemory limit256 MB

Problem

Minho takes a discrete mathematics course. One day the professor proved that the positive rational numbers are countable and then assigned homework.

The positive rationals are listed by the following rule. Collect the fractions whose numerator and denominator have the same sum into one group, and number the groups starting from the smallest sum. The group with sum ss holds s1s-1 fractions, and inside the group they are written from the largest numerator down: s11,s22,,1s1\frac{s-1}{1}, \frac{s-2}{2}, \dots, \frac{1}{s-1}.

The listing therefore runs 11,21,12,31,22,13,41,\frac{1}{1}, \frac{2}{1}, \frac{1}{2}, \frac{3}{1}, \frac{2}{2}, \frac{1}{3}, \frac{4}{1}, \dots. The first rational is 11\frac{1}{1}, the second is 21\frac{2}{1}, the third is 12\frac{1}{2}, the fourth is 31\frac{3}{1}, and the fifth is 22\frac{2}{2}.

Fractions of equal value such as 11,22,33\frac{1}{1}, \frac{2}{2}, \frac{3}{3} count as separate terms. Nothing is reduced.

Minho does not want to do the homework by hand, so he writes a program instead. Find the NN-th rational number.

Input

The first line contains a positive integer NN. (1N10001 \le N \le 1000)

Output

If the NN-th rational number is ab\frac{a}{b}, print the numerator aa and the denominator bb on one line, separated by a space. Do not reduce the fraction.

Hint

Minho solved the homework with a program rather than by hand and derived a formula from it.