#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include <sstream>

using namespace std;

int main(){
	int t;
	cin>>t;
	for (int i = 1;i<=t;i++){
		/*long long p;
		cin>>p;
		char ch;
		cin>>ch;
		long long q;
		cin>>q;
		*/
		int f;
		cin>>f;
		string s;
		cin>>s;
		int a,b;
		char ch = '/';
		std::istringstream split(s);
   		std::vector<std::string> tokens;
   		for (std::string each; std::getline(split, each, ch); tokens.push_back(each));
   		a = stoi(tokens[0]);
   		b = stoi(tokens[1]);
   		long long p = (long long)(a);
   		long long q = (long long)(b);
		if(q==1){
			cout<<i<<" "<<"1"<<"/"<<p+1<<"\n";
		}
		else{
			int lev = 0;
			while(p>q){
				p = p-q;
				lev++;
			}
			q = q-p;
			p = p+q;
			for(int j = 1;j<=lev;j++){
				q = p+q;
			}
			cout<<i<<" "<<p<<"/"<<q<<"\n";
		}
	}
	return 0;
}