// Saif Khan - 21/03/2017
#include <bits/stdc++.h>
using namespace std;
#define rd freopen("in.txt", "r", stdin)
#define wr freopen("out.txt", "w", stdout)
#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mset(x, v) memset(x, v, sizeof(x))
#define FOR(n) for (int i = 0; i < n; i++)
using namespace std;
vector<string> split(string s) {
string tnum = "";
vector<string> v;
for (int i = 0; i < s.size(); i++) {
if (s[i] >= '0' && s[i] <= '9') {
tnum += s[i];
} else {
if (tnum != "") {
if (v.back() == "-" && v.size() - 2 >= 0 && v[v.size() - 2] == "(") {
v.pop_back();
tnum = "-" + tnum;
}
v.push_back(tnum);
tnum = "";
}
string ts = "";
ts += s[i];
v.push_back(ts);
}
}
return v;
}
bool check(string s) { return s == "+" || s == "-" || s == "*" || s == "/"; }
bool checkPriority(string a, string b) {
int aa = -1;
int bb = -1;
if (a == "+" || a == "-")
aa = 1;
else if (a == "*" || a == "/")
aa = 2;
if (b == "+" || b == "-")
bb = 1;
else if (b == "*" || b == "/")
bb = 2;
return aa >= bb;
}
vector<string> infixToPostfix(vector<string> v) {
stack<string> st;
vector<string> postfix;
for (int i = 0; i < v.size(); i++) {
if (check(v[i])) {
while (!st.empty() && st.top() != "(" && checkPriority(st.top(), v[i])) {
postfix.push_back(st.top());
st.pop();
}
st.push(v[i]);
} else if (v[i] == "(") {
st.push(v[i]);
} else if (v[i] == ")") {
while (!st.empty() && st.top() != "(") {
postfix.push_back(st.top());
st.pop();
}
st.pop();
} else {
postfix.push_back(v[i]);
}
}
while (!st.empty()) {
postfix.push_back(st.top());
st.pop();
}
return postfix;
}
double mathOperation(double t1, double t2, string s) {
if (s == "*") return t2 * t1;
if (s == "/") return t2 / t1;
if (s == "+") return t2 + t1;
if (s == "-") return t2 - t1;
return 0;
}
double toDouble(string s) {
stringstream ss;
ss << s;
double d;
ss >> d;
return d;
}
string toString(double d) {
stringstream ss;
ss << d;
return ss.str();
}
string postfixEvaluation(vector<string> v) {
stack<double> s;
double d;
for (int i = 0; i < v.size(); i++) {
if (check(v[i])) {
double d1 = s.top();
if (d1 == 0.0) {
return "Infinity";
}
s.pop();
double d2 = s.top();
s.pop();
d = mathOperation(d1, d2, v[i]);
s.push(d);
} else {
s.push(toDouble(v[i]));
}
}
return toString(d);
}
string calculate(string s) {
vector<string> v;
v = split(s);
v = infixToPostfix(v);
s = postfixEvaluation(v);
return s;
}
int main() {
ios;
int n;
cin >> n;
string s;
while (n--) {
cin >> s;
string sum = calculate(s);
if (sum != "Infinity") {
cout << fixed << setprecision(1) << toDouble(sum) << '\n';
} else {
cout << sum << '\n';
}
}
return 0;
}