## Canada Day Contest 2021 - Fine Art

View as PDF

Points: 7
Time limit: 2.0s
Python 3.0s
Memory limit: 768M

Author:
Problem type

Deruikong is a highly skilled artist. He wants to build a sculpture out of wool in Minecraft. He has types of wool, the th of which is of colour ( red, green, blue using the RGB colour model). His build contains pixels, the th of which is of colour . Help Deruikong choose a good substitute for each pixel by finding the wool that minimizes . If there are multiple solutions, output the smallest value of .

#### Input Specification

The first line will contain two space-separated integers, and .

The next lines contain three space-separated integers, , , and for .

The next lines contain three space-separated integers, , , and for .

#### Output Specification

For each pixel, output the lowest index of the closest substitute.

#### Constraints

No two wool types have the same colour.

#### Sample Input 1

2 3
0 0 0
0 0 5
0 0 0
0 0 3
0 0 4

#### Sample Output 1

1
2
2

#### Sample Input 2

2 3
3 3 3
1 1 1
2 2 2
1 2 3
3 2 1

#### Sample Output 2

1
1
1