시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 1024 MB 2 1 1 50.000%

문제

Pac-Man is a maze-chase video game developed in 1980s. The player controls the character “Pac-Man” to eat dots in a maze while avoiding enemy characters “ghosts.” All characters may move in four directions: up, down, left, right. The game ends when one of the following two conditions is met:

  1. Pac-Man eats all dots in the maze. In this case, the player wins.
  2. A ghost catches Pac-Man. In this case, the player loses.

Figure 1: Pac-Man gameplay (image from Wikipedia)

Adam is learning how to create games with modern programming tools. To practice the skills, he tries to reproduce the Pac-Man game with some modification. In Adam’s game, the playable character is a “ghost,” and the enemy character is “Pac-Man.” Since he changes the roles of the ghost and Pac-Man, he also changes the ending conditions of the game.

  1. Pac-Man eats all dots in the maze. In this case, the player loses.
  2. The ghost controlled by the player catches Pac-Man. In this case, the player wins.

Adam has almost developed the first full functioning version of his game. He wants to test his game and creates a simple stage for testing. The maze of the stage is based on a 10-by-10 grid. We label the cell at the intersection of row r and column c with (r, c). In this problem, rows and columns are numbered from 0 to 9. Each grid cell contains exact one dot. The exterior boundary of the grid are walls. No characters may move to the area outside of the grid. Inside the grid, there are no walls or obstacles. All characters may move freely from a cell to any cell adjacent to it. Note that two grid cells (r1, c1) and (r2, c2) are adjacent to each other if and only if |r1 − r2| + |c1 − c2| = 1.

Adam has to prepare the movements of Pac-Man for the testing. He needs a set of Pac-Man’s trajectories with diversity, but any trajectory must satisfy the following requirements.

  • Pac-Man eats all dots in the maze if it follows the trajectory.
  • Pac-Man moves at most 10000 steps.

Adam needs your help to generate a trajectory starting at cell (x, y). Please write a program to generate a trajectory of Pac-Man satisfying all requirements above and starting at cell (x, y).

입력

The input has exactly one line which consists of two space-separated integers x and y. You are asked to generate a trajectory starting at cell (x, y).

출력

You must output a requested trajectory in the following format: The trajectory is represented by m + 1 lines where m is the number of steps of the trajectory. The i-th line contains two integers ri and ci separated by exactly one space. The trajectory starts at the cell (r1, c1), and Pac-Man will be in cell (ri, ci) after moving i − 1 steps along the trajectory for 1 < i ≤ m + 1.

If there are multiple solutions, then you may output any of them.

제한

  • m ≤ 10000
  • x, y, ri, ci ∈ {0, 1, 2, 3, 4, 5, 6, 7, 8, 9} for all i ∈ {1, 2, . . . , m + 1}.
  • Cells (ri, ci) and (ri+1, ci+1) are adjacent to each other for all i ∈ {1, 2, . . . , m}.
  • {(r1, c1)} ∪ {(r2, c2)} ∪ · · · ∪ {(rm+1, cm+1)} = {(r, c) : r ∈ {0, 1, . . . , 9}, c ∈ {0, 1, . . . , 9}}

예제 입력 1

0 0

예제 출력 1

0 0
0 1
0 2
0 3
0 4
0 5
0 6
0 7
0 8
0 9
1 9
1 8
1 7
1 6
1 5
1 4
1 3
1 2
1 1
1 0
2 0
2 1
2 2
2 3
2 4
2 5
2 6
2 7
2 8
2 9
3 9
3 8
3 7
3 6
3 5
3 4
3 3
3 2
3 1
3 0
4 0
4 1
4 2
4 3
4 4
4 5
4 6
4 7
4 8
4 9
5 9
5 8
5 7
5 6
5 5
5 4
5 3
5 2
5 1
5 0
6 0
6 1
6 2
6 3
6 4
6 5
6 6
6 7
6 8
6 9
7 9
7 8
7 7
7 6
7 5
7 4
7 3
7 2
7 1
7 0
8 0
8 1
8 2
8 3
8 4
8 5
8 6
8 7
8 8
8 9
9 9
9 8
9 7
9 6
9 5
9 4
9 3
9 2
9 1
9 0

채점 및 기타 정보

  • 예제는 채점하지 않는다.