import std.stdio, std.string, std.conv, std.ascii;

void main()
{
    foreach(_; 0 .. readln.chomp.to!int)
    {
        line = readln.chomp;
        add.writeln;
    }
}

string line;

int add()
{
    int lhs = mul;
    if(line[0] == '=') return lhs;
    switch(line[0])
    {
        case '+':
            line = line[1 .. $];
            return lhs + add;
        case '-':
            line = line[1 .. $];
            return lhs - add;
        default:
            return lhs;
    }
}

int mul()
{
    int lhs = prim;
    if(line[0] == '=') return lhs;
    switch(line[0])
    {
        case '*':
            line = line[1 .. $];
            return lhs * mul;
        case '/':
            line = line[1 .. $];
            return lhs / mul;
        default:
            return lhs;
    }
}

int prim()
{
    int r;
    if(line[0] == '(')
    {
        line = line[1 .. $];
        r = add;
        line = line[1 .. $];
    }
    else while(line[0] != '=')
    {
        if(line[0].isDigit)
        {
            r = r * 10 + (line[0] - '0');
            line = line[1 .. $];
        } 
        else break;
    }
    return r;
}