#include <iostream>
#include <cmath>
using namespace std;
pair<int, int> fun(long long k) {
// Direct calculation of n using quadratic formula
int n = ceil((-1.0 + sqrt(1 + 8.0 * k)) / 2.0);
// Sum of elements before the nth row
long long count = (n * (n - 1)) / 2;
// Find m
int m = k - count - 1;
return {m, n};
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T;
cin >> T;
while (T--) {
long long k;
cin >> k;
pair<int, int> result = fun(k);
cout << result.first << " " << result.second << "\n";
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8Y21hdGg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKcGFpcjxpbnQsIGludD4gZnVuKGxvbmcgbG9uZyBrKSB7CiAgICAvLyBEaXJlY3QgY2FsY3VsYXRpb24gb2YgbiB1c2luZyBxdWFkcmF0aWMgZm9ybXVsYQogICAgaW50IG4gPSBjZWlsKCgtMS4wICsgc3FydCgxICsgOC4wICogaykpIC8gMi4wKTsgIAoKICAgIC8vIFN1bSBvZiBlbGVtZW50cyBiZWZvcmUgdGhlIG50aCByb3cKICAgIGxvbmcgbG9uZyBjb3VudCA9IChuICogKG4gLSAxKSkgLyAyOwogICAgCiAgICAvLyBGaW5kIG0KICAgIGludCBtID0gayAtIGNvdW50IC0gMTsKCiAgICByZXR1cm4ge20sIG59Owp9CgppbnQgbWFpbigpIHsKICAgIGlvczo6c3luY193aXRoX3N0ZGlvKGZhbHNlKTsKICAgIGNpbi50aWUobnVsbHB0cik7CiAgICAKICAgIGludCBUOwogICAgY2luID4+IFQ7CiAgICAKICAgIHdoaWxlIChULS0pIHsKICAgICAgICBsb25nIGxvbmcgazsKICAgICAgICBjaW4gPj4gazsKICAgICAgICAKICAgICAgICBwYWlyPGludCwgaW50PiByZXN1bHQgPSBmdW4oayk7CiAgICAgICAgY291dCA8PCByZXN1bHQuZmlyc3QgPDwgIiAiIDw8IHJlc3VsdC5zZWNvbmQgPDwgIlxuIjsKICAgIH0KICAgIAogICAgcmV0dXJuIDA7Cn0K