#C514. Minimum Book Exchange Rounds

    ID: 48756 Type: Default 1000ms 256MiB

Minimum Book Exchange Rounds

Minimum Book Exchange Rounds

In a book exchange competition, there are n participants, each initially bringing one unique book. The goal is to determine the minimum number of exchange rounds required so that one designated participant (participant 1) exchanges her/his book with every other participant. In one round, participant 1 exchanges with one other participant. Thus, the minimum number of rounds is \(n - 1\).

Your task is to output the number of rounds followed by the list of exchange pairs. Each exchange pair should be denoted as two integers \(u\) and \(v\) where \(u = 1\) and \(v\) is the other participant.

Example:

Input:
4
1 2 3 4

Output: 3 1 2 1 3 1 4

</p>

inputFormat

The input is given from stdin in the following format:

  • The first line contains an integer \(n\) representing the number of participants.
  • The second line contains \(n\) space-separated integers representing the books each participant brings.

outputFormat

Output to stdout:

  • The first line contains a single integer \(n - 1\), the minimum number of exchange rounds.
  • Each of the next \(n - 1\) lines should contain two integers \(1\) and \(v\) (with \(v\) ranging from 2 to \(n\)), representing an exchange between participant 1 and participant \(v\).
## sample
4
1 2 3 4
3

1 2 1 3 1 4

</p>