// Arup Guha
// 9/7/2013
// Solution to UCF JV Practice Problem G: Spiral

import java.util.*;

public class g {

	final public static double BASE = Math.pow(.5, 1/1.5);

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);
		int numCases = stdin.nextInt();

		// Process each case.
		for (int loop=0; loop<numCases; loop++) {
			int n = stdin.nextInt();
			int[] pair = getPair(n);
			System.out.println("("+pair[0]+","+pair[1]+")");
		}
	}

	// Returns the mapped coordinate, (x,y) where x is the row and y the column.
	public static int[] getPair(int n) {

		int[] ans = new int[2];

		// Simple base case to avoid div by 0.
		if (n == 1)
			return ans;

		// Find the largest odd square less than n.
		int square = (int)(Math.sqrt(n)-1e-5);
		if (square%2 == 0) square--;

		// Figure out the rank of this item on this iteration of the spiral.
		int leftover = n - square*square - 1;

		// This is which side it's on. 0 is left, 1 is down, 2 left, 3 up.
		int side = leftover/(square+1);
		int onSide = leftover - side*(square+1);

		// In each of these calculations one of the two coordinates is fixed and the
		// other is simply based on how far down this side we've moved.
		if (side == 0) {
			ans[0] = -square/2 + onSide;
			ans[1] = (square+1)/2;
		}
		else if (side == 1) {
			ans[0] = (square+1)/2;
			ans[1] = (square+1)/2 - onSide - 1;
		}
		else if (side == 2) {
			ans[0] = (square+1)/2 - onSide - 1;
			ans[1] = -(square+1)/2;
		}
		else {
			ans[0] = -(square+1)/2;
			ans[1] = -(square+1)/2 + onSide + 1;
		}

		return ans;
	}
}