CF1179B.Tolik and His Uncle

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

This morning Tolik has understood that while he was sleeping he had invented an incredible problem which will be a perfect fit for Codeforces! But, as a "Discuss tasks" project hasn't been born yet (in English, well), he decides to test a problem and asks his uncle.

After a long time thinking, Tolik's uncle hasn't any ideas on how to solve it. But, he doesn't want to tell Tolik about his inability to solve it, so he hasn't found anything better than asking you how to solve this task.

In this task you are given a cell field nmn \cdot m , consisting of nn rows and mm columns, where point's coordinates (x,y)(x, y) mean it is situated in the xx -th row and yy -th column, considering numeration from one ( 1xn,1ym1 \leq x \leq n, 1 \leq y \leq m ). Initially, you stand in the cell (1,1)(1, 1) . Every move you can jump from cell (x,y)(x, y) , which you stand in, by any non-zero vector (dx,dy)(dx, dy) , thus you will stand in the (x+dx,y+dy)(x+dx, y+dy) cell. Obviously, you can't leave the field, but also there is one more important condition — you're not allowed to use one vector twice. Your task is to visit each cell of the field exactly once (the initial cell is considered as already visited).

Tolik's uncle is a very respectful person. Help him to solve this task!

输入格式

The first and only line contains two positive integers n,mn, m ( 1nm1061 \leq n \cdot m \leq 10^{6} ) — the number of rows and columns of the field respectively.

输出格式

Print "-1" (without quotes) if it is impossible to visit every cell exactly once.

Else print nmn \cdot m pairs of integers, ii -th from them should contain two integers xi,yix_i, y_i ( 1xin,1yim1 \leq x_i \leq n, 1 \leq y_i \leq m ) — cells of the field in order of visiting, so that all of them are distinct and vectors of jumps between them are distinct too.

Notice that the first cell should have (1,1)(1, 1) coordinates, according to the statement.

输入输出样例

  • 输入#1

    2 3
    

    输出#1

    1 1
    1 3
    1 2
    2 2
    2 3
    2 1
  • 输入#2

    1 1
    

    输出#2

    1 1
    

说明/提示

The vectors from the first example in the order of making jumps are (0,2),(0,1),(1,0),(0,1),(0,2)(0, 2), (0, -1), (1, 0), (0, 1), (0, -2) .

首页