#K11521. Stone Position in a Triangular Array

    ID: 23487 Type: Default 1000ms 256MiB

Stone Position in a Triangular Array

Stone Position in a Triangular Array

You are given a positive integer k which represents the overall position of a stone in a triangular arrangement. In this arrangement, the first row contains 1 stone, the second row 2 stones, the third row 3 stones, and so on. Your task is to determine the row number and the position of the stone within that row.

In other words, find r and p such that:

\( \sum_{i=1}^{r-1} i < k \leq \sum_{i=1}^{r} i \)

and then \( p = k - \sum_{i=1}^{r-1} i \).

For example, if k = 5, then the stone is in row 3 and is the 2nd stone in that row.

inputFormat

The first line of input contains a single integer T (T ≥ 1) which denotes the number of test cases. Each of the following T lines contains a single positive integer k representing the overall position of a stone.

outputFormat

For each test case, output two integers separated by a space: the row number and the column (position) of the stone in that row. Each result should be printed on a new line.

## sample
3
5
10
12
3 2

4 4 5 2

</p>