On the planet Bitaculandia, there is an annual prestigious competition hosted by Miss M — an international team championship.
Residents from all countries of Bitaculandia participate in this competition. The championship also involves solving problems with very interesting legends, like this one, but in teams. The best teams, according to the championship results, receive prizes.
Miss M has finally received the long-awaited gifts for the championship, which need to be sent to the winners. She realized that there are many gifts. And while everything is clear with mugs and packets, there was a problem with T-shirts. Each team has three participants, and each of them ordered a T-shirt of one of $$$n$$$ colors and one of $$$m$$$ sizes. But Miss M is not sure that all the winners' wishes will be fulfilled...
Therefore, Miss M developed an algorithm according to which she will collect gifts for the teams.
Miss M decided that she needs to send back to the warehouse the T-shirts that turned out to be superfluous and order more of the T-shirts that she recorded as absent, to satisfy all the participants of the championship. To avoid sorting all the T-shirts by hand, Miss M asks you to write a program that:
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \leq n \leq 100, 1 \leq m \leq 6$$$) — the number of different colors and sizes of T-shirts, respectively.
The second line contains $$$m$$$ elements — the sizes of T-shirts delivered to Miss M. Sizes are — XS, S, M, L, XL, 2XL. It is guaranteed that the sizes are given in increasing order.
Each of the following $$$n$$$ lines contains $$$m$$$ integers $$$t_{i1}, t_{i2}, \dots, t_{im}$$$ ($$$0 \leq t_{ij} \leq 5 \cdot 10^{3}$$$) — the number of T-shirts of the $$$i$$$-th color and $$$j$$$-th size.
The next line contains one integer $$$k$$$ ($$$1 \leq k \leq 10^{5}$$$) — the number of winners.
Each of the following $$$k$$$ lines contains an integer $$$c_i$$$ ($$$1 \leq c_i \leq n$$$) and a character $$$s_i$$$ — the color and size of each T-shirt, respectively. It is guaranteed that $$$s_i$$$ is one of the $$$m$$$ sizes that were specified.
The winners' requests must be processed exactly in the order specified.
In each of the following $$$n$$$ lines, output $$$m$$$ integers $$$l_{i1}, l_{i2}, \dots, l_{im}$$$ — the number of T-shirts of the $$$i$$$-th color and $$$j$$$-th size that remained.
In each of the following $$$n$$$ lines, output $$$m$$$ integers $$$n_{i1}, n_{i2}, \dots, n_{im}$$$ — the number of T-shirts of the $$$i$$$-th color and $$$j$$$-th size that need to be purchased.
2 3S M XL1 3 03 0 391 S2 XL1 M2 XL1 M2 M1 M2 S1 XL
0 0 0 2 0 0 0 0 1 0 0 0
Suppose we have white T-shirts (index one) and black T-shirts (index two). So, we have one white T-shirt of size S, and also three white T-shirts of size M. There are three black T-shirts of size S, and also three black T-shirts of size XL.
Consider each winner:
We are left with two black T-shirts of size S.
We could not give out one white T-shirt of size XL.