At the end of the week, John asked Mary to send him an urgent sales report. In a hurry to leave for her holiday, Mary copy-pasted the sales sheet into an email, sent it, then turned off her phone and left for a place where she would be unreachable for two weeks.
When John opened the message, he discovered that every space had been stripped out. Fortunately, he remembered the exact shape of the report:
P1 P2 ... PN followed by the word Totals. Products are numbered consecutively from 1 to N.TP, followed by the total sold of each product (the column sums over all sellers), and finally the grand total (the sum of those column totals).All quantities are non-negative integers. A quantity of zero is written as a single 0, and a positive quantity has no leading zeros. No seller's name begins with the letters TP.
Because the spaces are gone, more than one report may be consistent with the same run of digits. Help John rebuild the report; when several reconstructions are possible, output the lexicographically smallest one (defined in Output).
The first line contains an integer C, the number of reports. Each report is then given, with all spaces removed, on consecutive lines: a header line, one line per seller, and finally the TP line.
Constraints:
TP.For each report, print the reconstructed report, one line per original line, with items separated by a single space and no trailing space. Do not print blank lines between reports.
If several reconstructions are consistent with the input, print the lexicographically smallest one. To compare two candidate reports, list all of their integers in reading order — for each seller row its N quantities followed by its row total, taken in the given seller order, then the totals row's column sums followed by the grand total — and compare these two integer sequences element by element; the smaller report is the one with the smaller value at the first position where they differ.