// Arup Guha
// 10/14/2015
// Solution to 2000 UCF HS Contest Problem: Ali's Area Code

import java.util.*;

public class area {

	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++) {

			// Read in this number.
			String number = stdin.next();

			// Add 407, if necessary...
			if (number.charAt(0) != '4') System.out.print("(407) ");
			System.out.println(number);
		}
	}
}

