import std.algorithm, std.array, std.bigint, std.conv, std.stdio, std.typecons, std.range; string solve(string exp) { char[][] nums; bool[] is_neg; if (exp[0] == '-') { is_neg ~= true; exp = exp[1 .. $]; } else { is_neg ~= false; } char[] num; foreach (c; exp) { if (c.among!('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '?')) { num ~= c; } else if (c == '+') { nums ~= num; is_neg ~= false; num.length = 0; } else if (c == '-') { nums ~= num; is_neg ~= true; num.length = 0; } else assert(0); } nums ~= num; foreach (i; 0 .. nums.length) { if (is_neg[i]) { if (nums[i][0] == '?') nums[i][0] = '1'; if (nums[i][$-1] == '?') nums[i][$-1] = '9'; auto qi = nums[i].countUntil('?'); if (qi > 0) nums[i][qi] = '+'; nums[i] = nums[i].replace('?', '9'); } else { nums[i] = nums[i].replace('?', '9'); } } string result; if (is_neg[0]) result = "-"; result ~= nums[0]; foreach (i; 1 .. nums.length) { result ~= is_neg[i] ? "-" : "+"; result ~= nums[i]; } return result; } void main() { auto n = readln[0..$-1].to!uint; iota(n).map!(i => readln[0 .. $-1].solve).each!writeln; }