#K66162. Assign Unique Identifiers

    ID: 32360 Type: Default 1000ms 256MiB

Assign Unique Identifiers

Assign Unique Identifiers

You are given a series of registration groups for a conference. Each group contains a list of attendee names that registered together. Your task is to assign a unique identifier for each attendee in the order they registered, up to a maximum number of allowed attendees.

The unique identifier for an attendee from the i-th registration group and the j-th attendee in that group is formatted as: \(A{i}-{j}\).

Note: Once the total number of assigned identifiers reaches the maximum allowed attendees, the assignment must stop even if there are remaining names in the current or subsequent groups.

inputFormat

The input is read from standard input and is formatted as follows:

  1. The first line contains an integer max which is the maximum allowed number of attendees.
  2. The second line contains an integer n which is the number of registration groups.
  3. For each registration group, there are two lines:
    1. The first line is an integer k representing the number of names in this group.
    2. The second line contains k names separated by spaces.

If there are no registration groups, n will be 0.

outputFormat

Print the assigned unique identifiers to the standard output, one per line, in the order the attendees registered. If no attendees are assigned an identifier, output nothing.

## sample
5
3
2
John Doe
3
Alice Bob Charlie
2
Eve Frank
A1-1

A1-2 A2-1 A2-2 A2-3

</p>