// Arup Guha
// 3/19/2016
// 2014 NY Regional Problem F: A Rational Sequence

import java.util.*;

public class f {

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);
		int numCases = stdin.nextInt();

		// Process all cases, just read in the fraction, get the next one and print.
		for (int loop=1; loop<=numCases; loop++) {

			// Get data.
			int caseNum = stdin.nextInt();
			StringTokenizer tok = new StringTokenizer(stdin.next(), "/");
			long num = Long.parseLong(tok.nextToken());
			long den = Long.parseLong(tok.nextToken());

			// Annoying.
			System.out.print(caseNum+" ");

			// Special case, end of row.
			if (den == 1) System.out.println(den+"/"+(num+1));

			// Use usual algorithm for less than 1.
			else if (num < den )System.out.println(den+"/"+(den-num));

			// Use algorithm for greater than 1.
			else {

				// Figure out how many times we had to go right.
				long cnt = num/den;
				num = num - den*cnt;

				// Now, just go across and left cnt times and print.
				long newnum = den;
				long newden = den - num + cnt*newnum;
				System.out.println(newnum+"/"+newden);
			}
		}
	}
}
