#arc130b. [arc130_b]Colorful Lines

[arc130_b]Colorful Lines

Problem Statement

We have an HtimesWH\\times W grid. Initially, the squares are unpainted.

You will paint these squares. There are CC colors available, numbered 1,2,ldots,C1, 2, \\ldots, C.

The painting process will be given as QQ queries. The ii-th query contains integers ti,ni,cit_i, n_i, c_i, which represents the following action.

  • If ti=1t_i = 1: paint all squares in the nin_i-th row with Color cic_i.
  • If ti=2t_i = 2: paint all squares in the nin_i-th column with Color cic_i.

Painting a square with Color cc makes the color of that square Color cc, regardless of its previous state.

Find the number of squares painted in each of Color 1,2,ldots,C1, 2, \\ldots, C after the whole process.

Constraints

  • 2leqHleq1092\\leq H\\leq 10^9
  • 2leqWleq1092\\leq W\\leq 10^9
  • 1leqCleq3times1051\\leq C\\leq 3\\times 10^5
  • 1leqQleq3times1051\\leq Q\\leq 3\\times 10^5
  • tiin1,2t_i\\in \\{1,2\\}
  • 1leqnileqH1\\leq n_i\\leq H if ti=1t_i = 1
  • 1leqnileqW1\\leq n_i\\leq W if ti=2t_i = 2
  • 1leqcileqC1\\leq c_i\\leq C

Input

Input is given from Standard Input in the following format:

HH WW CC QQ t1t_1 n1n_1 c1c_1 vdots\\vdots tQt_Q nQn_Q cQc_Q

Output

Print a line containing the numbers of squares painted in Color 1,2,ldots,C1, 2, \\ldots, C, with spaces in between.


Sample Input 1

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

Sample Output 1

0 8 3 3 0 0

The process changes the colors of the squares as follows. Here, . denotes an unpainted square.

.....   66666   66666   64666   64626   22222
.....   .....   .....   .4...   .4.2.   .4.2.
.....   .....   33333   34333   34323   34323
.....   .....   .....   .4...   .4.2.   .4.2.

Sample Input 2

1000000000 1000000000 3 5
1 1 2
1 2 2
1 3 2
1 4 2
1 5 2

Sample Output 2

0 5000000000 0