#ifndef SHO_LOCAL #include #define debug(...) ; #else #include "debug.h" #endif #define all(x) (x).begin(), (x).end() #define lb(x, a) lower_bound(all(x), (a)) - (x).begin() typedef long long ll; using namespace std; static inline vector z_algo1(const string &s) { int n = (int)s.size(); vector Z(n); int from = -1, until = -1; for (int i = 1; i < n; i++) { int &a = Z[i]; if (from != -1) { a = max(0, min(Z[i - from], until - i)); } while (i + a < n && s[i + a] == s[a]) { a++; } if (until < i + a) { until = i + a; from = i; } } Z[0] = n; return Z; } static inline vector z_algo2(const string &s) { int n = (int)s.size(); vector Z(n); int from = -1, until = -1; for (int i = 1; i < n; i++) { int &a = Z[i]; if (from != -1) { a = max(0, min(Z[i - from], until - i)); } while (i + a < n && (s[i + a] == s[a] || s[i + a] == '?' || s[a] == '?')) { a++; } if (until < i + a) { until = i + a; from = i; } } Z[0] = n; return Z; } int main() { iostream::sync_with_stdio(0), cin.tie(0); int T; cin >> T; int n; string s; const string S = "helloworld$"; while (T--) { cin >> n >> s; string t = S + s; auto Z1 = z_algo1(t); auto Z2 = z_algo2(t); bool ok = false; int l = Z1.size(), r = l; for (int i = Z1.size() - 1; i >= S.size(); i--) { if (Z1[i] >= 10) { ok = true; break; } } if (ok) { for (int i = 0; i < Z1.size(); i++) { if (t[i] == '?') t[i] = 'a'; } } else { for (int i = Z2.size() - 1; i >= (int)S.size(); i--) { if (Z2[i] >= 10) { ok = true; for (int j = 0; j < i; j++) { if (t[j] == '?') t[j] = 'a'; } for (int j = 0; j < 10; j++) { if (t[i + j] == '?') { t[i + j] = S[j]; } } for (int j = i + 10; j < (int)Z2.size(); j++) { if (t[j] == '?') t[j] = 'a'; } } } } if (!ok) cout << -1 << '\n'; else cout << t.substr(S.size()) << '\n'; } return 0; }