#C9026. Unique Username Generator

    ID: 53074 Type: Default 1000ms 256MiB

Unique Username Generator

Unique Username Generator

You are given a list of existing usernames and a candidate username. Your task is to generate a unique username that conforms to the following rules:

  • The username must start with a lowercase letter and only contain lowercase letters and digits.
  • If the candidate username is not already taken, output it directly.
  • If the candidate username already exists, append the smallest positive integer (starting from 1) such that the resulting username is unique.

Formally, if we denote the candidate username as u and the set of existing usernames as S, you need to find the smallest integer \( i \ge 1 \) for which \( u + i \notin S \) holds. If \( u \notin S \), then the answer is simply \( u \).

inputFormat

The input is given through standard input (stdin). The format of the input is as follows:

n
username_1
username_2
... 
username_n
new_username

Here, n is a non-negative integer representing the number of existing usernames. If n is zero, there will be no usernames listed. The last line represents the candidate username.

outputFormat

Output a single line containing the unique username generated according to the problem requirements via standard output (stdout).

## sample
3
alice
bob
charlie
dave
dave

</p>