#K37587. Unique Username Generation

    ID: 26009 Type: Default 1000ms 256MiB

Unique Username Generation

Unique Username Generation

You are given a list of existing usernames and the first and last name of a new user. Your task is to generate a unique username for the user by concatenating the first and last name in lowercase. If the resulting username already exists in the list, you should append the smallest positive integer (starting from 1) to the username to make it unique.

Formally, let \( u = (\text{first_name} + \text{last_name}) \) in lowercase. If \( u \) is not present in the set of existing usernames, then output \( u \). Otherwise, find the smallest positive integer \( k \) such that \( u + k \) (i.e. the concatenation of \( u \) and \( k \)) is not in the existing usernames list, and output that.

The input is read from stdin and the answer should be printed on stdout.

inputFormat

The input consists of multiple lines:

  1. The first line contains an integer \( n \), the number of existing usernames.
  2. The next \( n \) lines each contain an existing username.
  3. The last line contains two strings separated by spaces: the first name and the last name of the new user.

All usernames and names consist only of alphanumeric characters.

outputFormat

Output a single line containing the unique username generated according to the rules described.

## sample
5
johnsmith
maryjane
johnsmith1
alicecooper
bobmarley
Jane Doe
janedoe