#K36437. Taco Pair Sums

    ID: 25754 Type: Default 1000ms 256MiB

Taco Pair Sums

Taco Pair Sums

Given a list of n integers and a target integer \(T\), your task is to find all unique pairs \((a, b)\) such that:

\(a + b = T\)

Each element in the list can be used at most once in forming the pairs. The list can contain duplicate numbers but once an occurrence is used in a pair, it cannot be used again. Print each valid pair on a new line, with the two numbers separated by a space.

Note: The list should be processed in sorted order. When multiple pairs are possible, select the pair which uses the smallest available numbers first.

inputFormat

The input is read from stdin and has the following format:

  1. An integer n denoting the number of elements in the list.
  2. A line with n space-separated integers.
  3. An integer T denoting the target sum.

outputFormat

For each pair found, output the two integers separated by a space on a new line. The pairs should be printed in the order they are discovered. If no valid pair exists, do not output anything.

The output is written to stdout.

## sample
6
1 5 7 -1 5 4
6
-1 7

1 5

</p>