Time limit
2s
Memory limit
128 MB
A binary power bishop is on an infinite chessboard. If it is currently at (x, y), it may choose a nonnegative integer k that has not been used before and move diagonally by 2^k cells to one of (x + 2^k, y + 2^k), (x + 2^k, y - 2^k), (x - 2^k, y + 2^k), or (x - 2^k, y - 2^k).
The bishop starts at (0, 0) and wants to reach (x, y). Find a route that minimizes the number of visited cells.
The chessboard is infinite, and the route may visit cells with negative coordinates.
The first line contains the target coordinates x and y, separated by a space.
Both numbers are positive integers not greater than 100,000,000.
If the bishop can reach (x, y), print the minimum number of visited cells on the first line. Starting from the second line, print the visited cells in order from (0, 0) to (x, y).
Each coordinate must be printed in the form x,y. If there are multiple optimal routes, any one of them may be printed.
If the target cannot be reached, print -1 on the first line.