시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 2048 MB333100.000%

문제

A chess bishop attacks every square that shares a diagonal with it.

Place the maximum number of bishops on an $n \times m$ chessboard in such a way that none of them attack each other.

입력

The first line contains two integers $n$ and $m$: the dimensions of the chessboard ($1 \leq n, m \leq 10^5 + 1$).

출력

On the first line, print an integer $k$: the maximum possible number of bishops on an $n \times m$ chessboard such that they don't attack each other. On each of the next $k$ lines, print two integers: the coordinates of bishops. The first coordinate should be in the range $[1, n]$, and the second in the range $[1, m]$. If there are several possible answers, print any one of them.

예제 입력 1

2 5

예제 출력 1

6
2 5
1 5
2 3
1 1
1 3
2 1

예제 입력 2

5 5

예제 출력 2

8
1 1
1 2
5 4
1 3
5 3
1 4
5 2
1 5