const string cmp = "helloworld"; const ll sz_t = cmp.size(); bool contains(string&s, ll x){ ll n = s.size(); assert(x + sz_t - 1 <= n); rep(i, x, x + sz_t) { if (s[i] != cmp[i - x]) { return false; } } return true; } void fill(string&s) { for(auto&&x:s) if (x == '?') x = 'a'; } bool implies(string&s, ll x){ ll n = s.size(); assert((x + sz_t - 1) <= n); rep(i, x, x + sz_t) { if (s[i] != cmp[i - x]) { if (s[i] != '?') return false; } } rep(i, x, x + sz_t) { if (s[i] == '?') s[i] = cmp[i - x]; } return true; } { REP(rd_int()){ ll @n; string @s; bool done = false; rep(i, n - sz_t + 1) { if (contains(s, i)) { fill(s); wt(s); done = true; break; } } if (done) continue; rrep(i, n - sz_t + 1) { if (implies(s, i)) { fill(s); wt(s); done = true; break; } } if (done) continue; wt(-1); } }