Two players are engaged in a game called "Nim." There are piles, each containing and candies. During a player's turn, they can choose to remove any number of candies from one pile or the same number of candies from both piles. The player who removes the last candy wins the game.
Your task is to identify all losing positions in this game where the total number of candies, n+k, does not exceed .
The input consists of a single integer (1 \le max\_sum \le 10^6).
First, output the number of losing positions. Then, list each losing position on a separate line. Each position is represented by two integers and (n \le k). The positions should be sorted in ascending order of , and for ties, in ascending order of . If there are more than 10^6 losing positions, only output the first 10^6.
Example 1