QOJ.ac

QOJ

حد الوقت: 1 s حد الذاكرة: 1024 MB مجموع النقاط: 100 قابلة للهجوم ✓

#17923. Chocolate and Knight Game

الإحصائيات

Coco loves chess. Thinking that the movement of a standard knight is too simple, Coco created a new chess piece called the "K-Knight." A standard knight can move $1$ square horizontally and $2$ squares vertically, or $2$ squares horizontally and $1$ square vertically. The K-Knight is an extension of the knight; in one move, it can move $X$ squares horizontally and $Y$ squares vertically, or $Y$ squares horizontally and $X$ squares vertically.

The Knight Game is a single-player game played on an infinite chocolate grid. In each turn, the player moves the K-Knight according to the rules and eats the chocolate on the square where the K-Knight was previously located. The K-Knight cannot move to a square that does not have chocolate, and the game ends when the K-Knight can no longer make a move.

Coco made Hanbyeol, who lost a game of rock-paper-scissors, play the Knight Game with 99% chocolate and a K-Knight. To help Hanbyeol, who struggles to eat 99% chocolate, determine how to end the game as quickly as possible. The K-Knight starts at $(0, 0)$.

Input

The values $X$ and $Y$, representing the movement rules of the K-Knight, are given in order on a single line.

Output

On the first line, output the number of moves $K$. On the next $K$ lines, output the coordinates to which the K-Knight is moved, one per line in order. Do not output the starting position $(0, 0)$.

Examples

Input 1

1 1

Output 1

7
1 1
2 0
3 -1
2 -2
1 -3
0 -2
1 -1

Note

$0 \le X, Y \le 10^6$, and inputs where both $X$ and $Y$ are $0$ will not be given.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.