#include using namespace std; #define rep(i, l, r) for (int i = (int)(l); i<(int)(r); i++) #define ll long long string replace(string s, char x, char y) { for (char& c : s) { if (c == x) c = y; } return s; } void solve() { string S; cin >> S; S += "+"; vector> T; string last = "+"; string now = ""; rep(i, 0, S.size()) { if (S[i] == '+' or S[i] == '-') { T.emplace_back(last, now); last = S[i]; now.clear(); } else { now += S[i]; } } string ans = ""; for (auto[c, s] : T) { // cout << c << " " << s << endl; ans += c; if (c == "+") { ans += replace(s, '?', '9'); } else { if ((int)s.size() <= 2) { ans += replace(s, '?', '1'); } else { bool f = false; for (int i = 1; i < (int)s.size()-1; i++) { if (s[i] == '?') { string l = s.substr(0, i); string r = s.substr(i+1, (int)s.size()); ans += replace(l, '?', '1'); ans += "+"; ans += replace(r, '?', '9'); f = true; break; } } if (!f) { ans += replace(s, '?', '1'); } } } } for (int i = 1; i < (int)ans.size(); i++) cout << ans[i]; cout << endl; } int main() { int T; cin >> T; while(T--) solve(); }