Moon cake betting (博饼) is a traditional Mid-autumn festival activity originated in Xiamen and then spread to southern Fujian. It began in the early Qing Dynasty. It was invented by Zheng Chenggong when he stationed in order to resolve the Mid-autumn lovesickness of the soldiers and inspire their morale. As a result, it has become a unique folk custom in Southern Fujian.

However, no one around wor knows how to play Moon cake betting, he have to play it with his brain girlfriend.
Moon cake betting is a game of dice. Each person rolls 6 dice at a time and gets corresponding prizes according to the result type.
All result types are as follows:
The rank of ZhuangYuan is compared according to the following rules:
There are also several special cases:
Now it is known that there are $$$1$$$ ZhuangYuan prize, $$$2$$$ DuiTang prizes, $$$a$$$ SanHong prizes, $$$b$$$ SiJin prizes, $$$c$$$ ErJu prizes, $$$d$$$ YiXiu prizes.
The prize rules are as follows:
Now we know that $$$n$$$ player sit together in a circle and play $$$m$$$ rounds. Player 1 starts to roll. They roll in turn $$$m$$$ times in the order of $$$(1, 2, 3, \cdots, n-1, n, 1, 2, \cdots)$$$.
If any player throw dice out of the range and get TanChu, then this roll is invalid, and he will do nothing the next round (Caution, skipped round is counted) and let the next player roll.
Given the game situation, can you find out the final prize situation of every player?
The first line contains six integers $$$n, m, a, b, c, d ~ (1 \leq n \le 10^6; ~ 0 \le m \le 10^6; ~ 1 \le a, b, c, d \le 10^9)$$$ denoting the number of players, the numbers of rounds to play, $$$a$$$ SanHong prizes, $$$b$$$ SiJin prizes, $$$c$$$ ErJu prizes, $$$d$$$ YiXiu prizes respectively.
Following $$$m$$$ lines each contains a string $$$\texttt{#}g_1\texttt{#}g_2\texttt{#}g_3\texttt{#}g_4\texttt{#}g_5\texttt{#}g_6$$$ representing the result of this throw.
If it is $$$\texttt{#}0$$$, it means that the dice is thrown out of range.
If it is between $$$\texttt{#}1$$$ and $$$\texttt{#}6$$$, it is the thrown number of dice.
Note that if someone stops for a round, this line will be blank.
Output $$$n$$$ lines.
Each line contains $$$6$$$ integers representing the final prize situation of every player, in the order of ZhuangYuan, DuiTang, SanHong, SiJin, ErJu, YiXiu.
2 10 10 10 10 10 #4#4#4#4#1#1 #1#2#3#4#5#6 #1#2#3#5#6#6 #0#4#4#4#4#4 #4#4#4#4#2#2 #4#1#4#2#4#3 #5#5#5#5#5#1 #1#1#1#1#4#4 #6#6#6#6#6#6
0 0 1 1 1 0 1 2 9 9 9 10
2 20 10 10 10 10 #2#5#5#6#6#6 #5#6#3#2#4#3 #6#3#4#1#1#3 #4#3#2#5#6#6 #2#3#3#4#4#3 #2#6#4#6#1#2 #4#4#6#4#2#1 #6#5#6#5#5#6 #6#3#1#5#2#2 #4#6#2#3#2#5 #4#1#3#3#6#6 #3#1#3#3#2#2 #6#3#5#6#1#1 #5#2#6#2#3#3 #4#1#6#6#2#5 #5#2#3#5#5#4 #5#1#1#4#3#4 #4#2#6#5#4#4 #5#2#6#3#4#4 #2#2#6#3#3#5
0 0 1 0 3 3 0 0 1 0 0 5