#include <bits/stdc++.h>
using namespace std;
#define R(i, a, b) for (int i = (a); i < (b); ++i)
#define L(i, a, b) for (int i = (b) - 1; i >= (a); --i)
using i64 = long long;
constexpr int M = 998244353;
struct mint {
  int x;
  const int operator()() {
    return x;
  }
  mint(int _x = 0) : x(_x) {}
};
mint operator+(const mint &a, const mint &b) {
  const int x = a.x + b.x;
  return x < M ? x : x - M;
}
mint operator-(const mint &a, const mint &b) {
  const int x = a.x - b.x;
  return x < 0 ? x + M : x;
}
mint operator*(const mint &a, const mint &b) {
  return i64(a.x) * b.x % M;
}
mint &operator+=(mint &a, const mint &b) {
  a = a + b; return a;
}
mint &operator*=(mint &a, const mint &b) {
  a = a * b; return a;
}
mint pw(mint a, int x = M - 2) {
  mint res = 1;
  for (; x; x >>= 1, a *= a) if (x & 1) res *= a;
  return res;
}
int main() {
  freopen("geometry.in", "r", stdin); freopen("geometry.out", "w", stdout);
  ios::sync_with_stdio(false); cin.tie(0);
  int nT; cin >> nT;
  R(T, 0, nT) {
    int a, b, c; cin >> a >> b >> c;
    cout << ((i64(12) * a * a - 6 * a + 1) + 2) / 3 << ' ';
    if (a % 3 == 0) cout << 1 << '\n';
    else if (a % 3 == 1) cout << 2 << '\n';
    else if (a % 3 == 2) cout << 1 << '\n'; 
  }
  return 0;
}