問題一覧 > 通常問題

No.2226 Hello, Forgotten World!

レベル : / AI推定難易度 : 450 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (解説公開後に AC するまで非表示) / 解いたユーザー数 141
作問者 : 👑 AngrySadEight / テスター : akakimidori 👑 p-adic norikame
お気に入りにしたユーザー ProblemId : 8563 / 自分の提出
問題文最終更新日: 2023-02-10 13:51:56
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 378 (順位表) の他の問題:

Problem Statement

Hachiji-kun decided to prepare a string $S$ consisting of lowercase English letters and give it to his friend as a birthday present.

To surprise his friend, Hachiji-kun tried to make the string $S$ so that it contains helloworld as a contiguous subsequence. However, he forgot part of the string he was trying to make.

You are given a string $S$ of length $N$ consisting of lowercase English letters and ?, where ? indicates that Hachiji-kun forgot the character at that position. For Hachiji-kun, replace each ? with a lowercase English letter to restore a string that contains helloworld as a contiguous subsequence. If there are multiple such strings, find the lexicographically smallest one among them, and if there is no such string, report that.

You are given $T$ test cases; find the answer for each of them.

Input

The input is given from Standard Input in the following format.

$T$
$case_1$
$case_2$
$\vdots$
$case_T$

Each case is given in the following format.

$N$
$S$

Constraints

  • $N, T$ are integers.
  • $1 \leq T \leq 20$
  • $10 \leq N \leq 1000$
  • $S$ is a string of length $N$ consisting only of lowercase English letters and ?.

Output

Print $T$ lines. On the $i(1 \leq i \leq T)$-th line, for the $i$-th test case, print -1 if it is impossible to make the string contain helloworld as a contiguous subsequence by changing the positions of ? in $S$ to lowercase English letters. If it is possible, print the lexicographically smallest such string.

Sample

Sample 1
Input
3
13
g?e??owo??d?d
26
abcdefghijklmnopq?????????
10
helloworld
Output
ghelloworldad
-1
helloworld

For the 1st test case, the $2$-nd through $11$-th characters form helloworld, so the string indeed contains helloworld as a contiguous subsequence. Other strings such as ghelloworldld also contain helloworld as a contiguous subsequence, but note that you must print the lexicographically smallest one.

For the 2nd test case, no matter what characters the $9$ occurrences of ? are changed to, the string cannot be made to contain helloworld as a contiguous subsequence.

For the 3rd test case, helloworld itself also contains helloworld as a contiguous subsequence.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。