#P10940. [2015杭电多校]Route Statistics

[2015杭电多校]Route Statistics

Route Statistics

Problem Description

JRY is so rich that he creates an mm demensional space and nn sight spots inside. Because of special technical problem, all the coordinates are integers between [0,2][0,2]. The roads in this space are all parallel to the axis, so the distance between two sight spots is their Manhattan distance. More specifically, if the coordinate of one sight spot is (x1,x2,,xm)(x_1,x_2,\ldots,x_m), and that of another sight spot is (y1,y2,,ym)(y_1,y_2,\ldots,y_m), then their distance is i=1mxiyi\sum_{i=1}^{m}|x_i-y_i|. JRY wants to establish some bus routes between two sight spots, so he needs to do some research first. For you, the problem is to find the total number of pairs (x,y)(x,y) for each kk, that the distance between (x,y)(x,y) is kk. Please be aware: 1. (x,x)(x,x) does not count; 2. (x,y)(x,y) and (y,x)(y, x) are identical, so that it is only one pair; 3. different sight spots may have same coordinates.

Input

The first line of the input is a single integer T (T=11)T\ (T = 11), indicating the number of testcases. For each testcase, the first line contains two integers nn and mm. Each of the following nn lines contains one string of length mm, which consists three types of characters 0,1,20, 1, 2, and the jj-th character of the ii-th string means the jj-th coordinate of the ii-th spot. It is guaranteed that the mm of the ii-th testcase is ii, and for all testcases n300000\sum n \le 300000.

Output

For each testcase, print 2m+12m+1 lines. The single number in the ii-th line of the output indicates the number of pairs of sight spots with distance i1i-1

Sample Input

2
2 1
0
1
6 2
00
01
10
11
02
00

Sample Output

0
1
0
1
7
6
1
0

Author

XJZX

Source

2015 Multi-University Training Contest 4