Collections In Containers

아직 제출이 없습니다시간 제한2초메모리 제한256 MB

문제

A dd-dimensional collection is a set of vectors such that:

  • Each coordinate of each vector in the set is a non-negative integer number.
  • Let a vector v=(v_1,,v_d)v = (v\_1, \ldots, v\_d) belong to the set. Then every vector u=(u_1,,u_d)u = (u\_1, \ldots, u\_d) such that all u_iu\_i are non-negative integers and uu does not exceed vv coordinate-wise (that is, for every index ii from 11 to dd the inequality 0u_iv_i0 \leq u\_i \leq v\_i must hold) must belong to the set as well.

For example, (0,0),(0,1),(1,0)\\{(0, 0), (0, 1), (1, 0)\\} and (0,0),(1,0),(2,0),(3,0)\\{(0, 0), (1, 0), (2, 0), (3, 0)\\} are 22-dimensional collections, while (0,1),(1,0),(1,1)\\{(0, 1), (1, 0), (1, 1)\\}, (0,0),(1,0)\\{(0, 0), (-1, 0)\\}, and (0,0),(0,12),(0,1)\\{(0, 0), (0, \frac{1}{2}), (0, 1)\\} are not.

You have to store two identical dd-dimensional collections, each of size nn. In order to do that, you gathered nn identical dd-dimensional containers each of which has a capacity given by the capacity vector c=(c_1,,c_d)c = (c\_1, \ldots, c\_d). You decided to choose a container for each vector from each collection in such a way that every container would contain exactly one vector from the first collection and exactly one vector from the second collection. However, if two vectors v=(v_1,,v_d)v = (v\_1, \ldots, v\_d) and u=(u_1,,u_d)u = (u\_1, \ldots, u\_d) are placed in the same container, it must be verified that v_i+u_ic_iv\_i + u\_i \leq c\_i for every ii; that is, the vector v+uv + u must not exceed the capacity vector cc coordinate-wise.

It is also guaranteed that each vector from each collection fits in any container by itself; that is, each vector vv of each collection does not exceed the capacity vector cc coordinate-wise.

Finding an arrangement to place all those vectors in containers turned out to be hard, so you decided to write a program that will solve this problem.

입력

The first line of input contains two space-separated positive integers nn and dd (1nd1051 \leq n \cdot d \leq 10^5) --- the size and the dimension of each collection.

The second line of input contains dd space-separated integers c_1c\_1, \ldots, c_dc\_d (0c_i1090 \leq c\_i \leq 10^9).

Next nn lines of input contain description of the collections; ii-th of these lines contains dd space-separated integers v_i1v\_{i 1}, \ldots, v_idv\_{i d} (0v_ij1090 \leq v\_{i j} \leq 10^9) --- coordinates of ii-th vector in the collection. It is guaranteed that the described set of vectors is indeed a dd-dimensional collection according to the definition above, and v_ijc_jv\_{i j} \leq c\_j.

출력

Output nn lines, with two space-separated integers in each --- the numbers of vectors from the first and the second collection respectively that must be put in the ii-th container. The numeration of vectors in the input is 1-based. Every vector from every collection must be assigned to exactly one container.

If there is more than one possible arrangement, output any one of them. It is guaranteed that there is at least one arrangement that satisfies all the requirements.