Davy Jones wants his men to line up on parade. The pirates line up in pairs, ordered from shortest to tallest. However, the two pirates in a single pair may differ in height by at most 2 inches.
The pairing works as follows. Consider the pirates from shortest to tallest. Take the shortest pirate who is not yet paired; if the next shortest remaining pirate differs from him in height by at most 2 inches, the two of them form a pair. If no pirate is sufficiently near his height (within 2 inches) — or there are no pirates left — then this unpaired pirate is forced to walk the plank!
You may assume that no two pirates have exactly the same height.
The input is a list of pirates. Each line contains a pirate's name and his height in inches as an integer.
Print the pairs of pirates, one pair per line, ordered from the shortest pair to the tallest. In each pair, print the shorter pirate's name first. Any pirate forced to walk the plank must not be listed.