import java.io.*;
import java.math.*;
import java.util.*;
public class RR
{
public static void main
(String[] args
) { Scanner sc
= new Scanner
(System.
in); int ntest = sc.nextInt();
for(int test = 1; test <= ntest; ++test) {
if (s.charAt(0) == '.') s = "0" + s;
if (s.indexOf('.') < 0) {
s = s + ".0";
}
if (s.indexOf('(') < 0) {
s = s + "(0)";
}
Fraction res = new Fraction();
String a
= s.
substring(0, s.
indexOf('.'));
String b
= s.
substring(s.
indexOf('.') + 1, s.
indexOf('(')); if (b.length() == 0) bb = "0";
String c
= s.
substring(s.
indexOf('(') + 1, s.
indexOf(')')); res = res.add(new Fraction(
));
System.
out.
println("Case #" + test
+ ": " + res
); }
}
}
class Fraction
{
Fraction() {
}
this.tu = tu;
this.mau = mau;
} else {
this.tu = this.tu.divide(g);
this.mau = this.mau.divide(g);
}
}
this.tu = a;
}
return tu + "/" + mau;
}
Fraction add(Fraction a) {
return new Fraction(tu.multiply(a.mau).add(a.tu.multiply(mau)), a.mau.multiply(mau));
}
}
aW1wb3J0IGphdmEuaW8uKjsKaW1wb3J0IGphdmEubWF0aC4qOwppbXBvcnQgamF2YS51dGlsLio7CgpwdWJsaWMgY2xhc3MgUlIKewogICAgcHVibGljIHN0YXRpYyB2b2lkIG1haW4oU3RyaW5nW10gYXJncykgewogICAgICAgIFNjYW5uZXIgc2MgPSBuZXcgU2Nhbm5lcihTeXN0ZW0uaW4pOwogICAgICAgIGludCBudGVzdCA9IHNjLm5leHRJbnQoKTsKCiAgICAgICAgZm9yKGludCB0ZXN0ID0gMTsgdGVzdCA8PSBudGVzdDsgKyt0ZXN0KSB7CiAgICAgICAgICAgIFN0cmluZyBzID0gc2MubmV4dCgpOwogICAgICAgICAgICBpZiAocy5jaGFyQXQoMCkgPT0gJy4nKSBzID0gIjAiICsgczsKCiAgICAgICAgICAgIGlmIChzLmluZGV4T2YoJy4nKSA8IDApIHsKICAgICAgICAgICAgICAgIHMgPSBzICsgIi4wIjsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAocy5pbmRleE9mKCcoJykgPCAwKSB7CiAgICAgICAgICAgICAgICBzID0gcyArICIoMCkiOwogICAgICAgICAgICB9CgogICAgICAgICAgICBGcmFjdGlvbiByZXMgPSBuZXcgRnJhY3Rpb24oKTsKICAgICAgICAgICAgU3RyaW5nIGEgPSBzLnN1YnN0cmluZygwLCBzLmluZGV4T2YoJy4nKSk7CgogICAgICAgICAgICByZXMgPSBuZXcgRnJhY3Rpb24obmV3IEJpZ0ludGVnZXIoYSkpOwoKICAgICAgICAgICAgU3RyaW5nIGIgPSBzLnN1YnN0cmluZyhzLmluZGV4T2YoJy4nKSArIDEsIHMuaW5kZXhPZignKCcpKTsKICAgICAgICAgICAgU3RyaW5nIGJiID0gYjsKICAgICAgICAgICAgaWYgKGIubGVuZ3RoKCkgPT0gMCkgYmIgPSAiMCI7CgogICAgICAgICAgICByZXMgPSByZXMuYWRkKG5ldyBGcmFjdGlvbihuZXcgQmlnSW50ZWdlcihiYiksIEJpZ0ludGVnZXIudmFsdWVPZigxMCkucG93KGJiLmxlbmd0aCgpKSkpOwoKICAgICAgICAgICAgU3RyaW5nIGMgPSBzLnN1YnN0cmluZyhzLmluZGV4T2YoJygnKSArIDEsIHMuaW5kZXhPZignKScpKTsKICAgICAgICAgICAgcmVzID0gcmVzLmFkZChuZXcgRnJhY3Rpb24oCiAgICAgICAgICAgICAgICBuZXcgQmlnSW50ZWdlcihjKSwKICAgICAgICAgICAgICAgIEJpZ0ludGVnZXIudmFsdWVPZigxMCkucG93KGMubGVuZ3RoKCkpLnN1YnRyYWN0KEJpZ0ludGVnZXIuT05FKQogICAgICAgICAgICAgICAgICAgIC5tdWx0aXBseShCaWdJbnRlZ2VyLnZhbHVlT2YoMTApLnBvdyhiLmxlbmd0aCgpKSkKICAgICAgICAgICAgKSk7CgogICAgICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oIkNhc2UgIyIgKyB0ZXN0ICsgIjogIiArIHJlcyk7CiAgICAgICAgfQogICAgfQp9Cg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