#include using namespace std; using ll = long long; const int INF = 1e9 + 10; const ll INFL = 4e18; int main() { int T; cin >> T; while (T--) { string S; cin >> S; auto type = [&](char c) { if (c == '?') return 0; if (c == '+' || c == '-') return 1; return 2; }; bool plus = true; int N = ssize(S); for (int i = 0; i < N; i++) { if (S[i] == '+') { plus = true; } else if (S[i] == '-') { plus = false; } if (S[i] == '?') { if (!plus) { if (i == N - 1 || type(S[i - 1]) == 1 || type(S[i + 1]) == 1) { S[i] = '1'; } else { S[i] = '+'; plus = true; } } else { S[i] = '9'; } } } cout << S << '\n'; } }