#include<cstdio> #include<cstring> #include<cmath> #include<algorithm> using namespace std; char s[20]; long long t, y; long long gcd(long long a, long long b) { long long t; while (b) { t = a%b; a = b; b = t; } return a; } int main() { int sb; scanf("%d", &sb); while (sb--) { long long i; scanf("%s", s); t = 0, y = 0; long long len = strlen(s); for (i = 0; i < len; i++) { if (s[i] == '.') break; t = t * 10 + s[i] - '0'; } long long o = 0; for (; i < len; i++) { if (s[i] == '.') continue; y = y * 10 + s[i] - '0'; o++; } long long e = 1; for (i = 1; i <= o; i++) e = e * 10; printf("%lld/%lld ", (t*e + y) / gcd(t*e + y, e), (e) / gcd(t*e + y, e)); } return 0; }