#include<iostream>
#include"string"
#include"math.h"
using namespace std;
int measure(long long int x, long long int y);
int main()
{
int n;
cin >> n;
string a;
for (int i = 0; i < n; i++)
{
cin >> a;
int x;
x = a.size();
int x1 = x - 2;
long long sum = 0;
for (int i = 2; i < x; i++)
{
sum = sum + (a[i] - '0') * pow(10, x - i - 1);
}
long long int b = pow(10, x1);
long long int z = measure(sum, b);
cout << sum / z << "/" << b / z << endl;
}
return 0;
}
int measure(long long int x, long long int y)
{
long long int z = y;
while (x % y != 0)
{
z = x % y;
x = y;
y = z;
}
return z;
}