$\sum^{K}_{i=1}{S_i\times{(K-i)!}}$

## Sample Input

4
3
2 1 0
3
1 0 0
4
2 1 1 0
4
1 2 1 0


## Sample Output

3 2 1
2 1 3
3 2 4 1
2 4 3 1