376. Berland AllRound Competitions
Time limit per test: 0.5
second(s)
Memory limit: 65536
kilobytes
input: standard
output: standard
The Berland has a tradition of allround competitions. The rules of those competitions are the following. The first stage is swimming some distance, then there are
K stages of horse riding. There are
N horses located at the start of each of the riding stages (
N is the number of participatnts). For each horse, its
ridingness S_{j} is known. The more the ridingness is, the faster the horse finishes the stage. For each participant, there are three parameters: swimming skill
W_{i}, riding skill
R_{i} and strength
P_{i}. Participant who reaches the start of some riding stage (which is the finish of the previous stage) takes the horse with maximal ridingness from those who are still at the start of this stage. Each horse can participate only in one stage. If two participants reach the start of any stage simoultaneously, the one with the most strength takes the better horse. All participants have different strengths. Time required to complete the riding stage for
ith participant is equal to 2· 10
^{7} 
R_{i} 
S_{j}, for the swimming stage the time is 2 · 10
^{7} 
W_{i}. After the start of the competition (i. e. the start of the swimming stage) there are no pauses and changing or taking the horse requires no time.
Petya knows all characteristics of participants. Also he knows that the jury picks horses in such a way that on
ith stage (1 ≤
i ≤
K) the ridingness of
jth horse (1 ≤
j≤
N) is equal to
f(
i,
j) = 3A
_{i}^{2} + 5A
_{i} B_{j} + 2B
_{j}^{2}, where all
A_{i} and
B_{j} are also known.
Now Peter wants to know the order of the participants on the finish line. Help him.
Input
The first line of the input contains two integers
N and
K (1≤
N≤ 10
^{3}, 1≤
K≤ 10
^{3}).
N lines follow, containing three integers each:
W_{i},
R_{i} and
P_{i} (1 ≤
W_{i},
R_{i},
P_{i} ≤ 10
^{6}). Then there are two lines: the first is for
A, which contains
K natural numbers not greater then 10
^{3}, the second is for
B, which contains
N natural numbers not greater than 10
^{3}.
Output
Output the spaceseparated transposition of
N numbers — the order of participants. If two participants reach the finish simultaneously, they use armwrestling to determine the winner, and the participant with higher strength takes the better place.
Example(s)
sample input

sample output

4 2
2 5 3
3 1 4
3 4 1
2 2 2
2 3
4 5 6 7

2 3 1 4
