Chess
Petro Pyatochkin has recently developed a keen interest in chess. To familiarize himself with the strategies of renowned players, he decided to watch all the games from a friendly match between the capital's team and the team from the village of Velyki Olympiytsi.
Each player has a skill level, represented by a natural number. A player from one team can compete against a player from the other team if their skill levels differ by no more than d, a specified non-negative integer. Each game involves one player from each team, and no player can participate in more than one game.
Petro wants to witness as many games as possible. To achieve this, he enlisted the help of a wizard to adjust the skill levels of all players on the village team by the same integer amount, maximizing the number of possible games. Note that after the adjustment, some players' skill levels might become negative.
Given the skill levels of all players and the value d, determine:
the amount by which the skill levels of the village players should be adjusted to maximize the number of games;
a pairing of players from the opposing teams that results in this maximum number of games (only one such pairing needs to be provided).
Input
The first line of the input contains 3 integers:
N — the number of players on the village team (1 ≤ N ≤ 200);
M — the number of players on the capital team (1 ≤ M ≤ 200);
d — the maximum allowable difference in skill levels for players to compete (0 ≤ d ≤ 10^9).
All subsequent numbers are natural and do not exceed 10^9.
The second line contains N numbers representing the skill levels of the village team players.
The third line contains M numbers representing the skill levels of the capital team players.
Output
The first line of the output should contain two integers: K — the maximum number of games possible after the wizard's adjustment (even if no change is made) and D — the adjustment amount for the village players' skill levels to achieve K games.
The next K lines should list K unique pairs of natural numbers, one per line. Each pair consists of a player number from the village team and a player number from the capital team, respectively, who should compete to achieve a total of K games. The pairs can be listed in any order.