시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 256 MB 46 28 27 64.286%

문제

진수는 동생 지수로부터 크기가  n × m인 마법의 체스판을 받았다. 마법의 체스판은 신기한 기능이 많이 있는데 그중에는 체스판의 색상을 반전시킬 수 있는 기능이 있다. 이 기능을 사용하면 칸들을 포함하는 직사각형을 선택하여 하얀색은 검은색으로 검은색은 하얀색으로 바꿀 수 있다.

초기에는 칸들의 색상이 일반적인 체스판처럼 칠해져 있다. 다르게 말하면 변을 공유하는 칸들은 서로 색상이 다르다. 진수는 위에서 설명한 기능을 최소한으로 이용하여 모든 칸의 색상을 같게 하고 싶다. 하지만 아무리 고민해도 방법을 찾지 못하였다. 그래서 진수는 당신에게 이 문제를 풀어 달라고 요청했다.

입력

첫 번째 줄에 행과 열의 개수를 나타내는 두 개의 정수 n과 m이 주어진다.  (1 ≤ n, m ≤ 50)

출력

첫 번째 줄에는 반전 횟수 k를 출력한다.

다음 k개 줄에는 줄 마다 직사각형의 모서리를 포함하는 좌표와 마주보는 모서리의 좌표를 출력한다. 

행은 1번부터 n번까지 있으며 열은 1부터 m번까지 있다.

예제 입력 1

2 2

예제 출력 1

2
1 1 1 1
2 2 2 2
W3sicHJvYmxlbV9pZCI6IjEwNTg5IiwicHJvYmxlbV9sYW5nIjoiMCIsInRpdGxlIjoiXHViOWM4XHViYzk1XHVjNzU4IFx1Y2NiNFx1YzJhNFx1ZDMxMCIsImRlc2NyaXB0aW9uIjoiPHA+XHVjOWM0XHVjMjE4XHViMjk0IFx1YjNkOVx1YzBkZCBcdWM5YzBcdWMyMThcdWI4NWNcdWJkODBcdWQxMzAgXHVkMDZjXHVhZTMwXHVhYzAwICZuYnNwO24gJnRpbWVzOyBtXHVjNzc4IFx1YjljOFx1YmM5NVx1Yzc1OCBcdWNjYjRcdWMyYTRcdWQzMTBcdWM3NDQgXHViYzFiXHVjNTU4XHViMmU0LiBcdWI5YzhcdWJjOTVcdWM3NTggXHVjY2I0XHVjMmE0XHVkM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