<?xml version="1.0" encoding="Windows-1251"?>
<CATS version="1.0">
<Problem title="Sales Report" lang="en" author="A. Klenin" tlimit="4" mlimit="16"
    inputFile="input.txt" outputFile="output.txt" stdChecker="nums">

<ProblemStatement>
<p>The Unknown Trading Company have installed a new inventory-tracking system, which
stores a complete database of goods and trading points worldwide.
Each salespoint and each item was assigned an integer unique identifier (id).
For every sale, the system logs id of the item, number of items sold, and id of the salespoint.
</p>
<p>Your task is to output a summary report, tabulating total sales by items and salespoints.
The report must be a two-dimensional table, with the first row containing item ids in increasing order,
first column containing salespoint ids in increasing order, and values inside the table
representing total sales of corresponding item from the corresponding salespoint.
The value in first column of the first row must be &amp;minus;1.
The values in cells without corresponding sales must be 0.
</p>
</ProblemStatement>

<InputFormat>
Input contains number of records <i>N</i>, followed by <i>N</i> triplets of integers
<i>q<sub>i</sub></i> <i>s<sub>i</sub></i> <i>v<sub>i</sub></i>, where
 <i>q<sub>i</sub></i> -- item id,
 <i>s<sub>i</sub></i> -- salespoint id, 
 <i>v<sub>i</sub></i> -- number of items sold.
</InputFormat>

<OutputFormat>
Output file must a table as described above, row-by-row.
</OutputFormat>

<ProblemConstraints>
1 &amp;le; <i>N</i> &amp;le; 500000,
1 &amp;le; <i>q<sub>i</sub></i>, <i>s<sub>i</sub></i>, <i>v<sub>i</sub></i> &amp;le; 10<sup>9</sup>,
the summary table will have no more than 10<sup>8</sup> cells,
the summary value in each cell will not exceed than 2<sup>31</sup>&amp;minus;1.
</ProblemConstraints>

<Sample rank="1">
  <SampleIn>4
10 1 3
20 2 5
10 2 2
20 2 1
</SampleIn>
  <SampleOut>-1 10 20
1 3 0
2 2 6</SampleOut>
</Sample>

<Sample rank="2">
  <SampleIn>1
1 1 5
</SampleIn>
  <SampleOut>-1 1
1 5</SampleOut>
</Sample>

<Solution name="sol" src="report.dpr"/>
<Generator name="g" src="g.dpr"/>
<TestRange from="1" to="8"><In src="t%0n"/><Out use="sol"/></TestRange>
<Test rank="9"><In use="g" param="i 100"/><Out use="sol"/></Test>
<Test rank="10"><In use="g" param="r 100"/><Out use="sol"/></Test>
<Test rank="11"><In use="g" param="R 1000"/><Out use="sol"/></Test>
<Test rank="12"><In use="g" param="q 1000"/><Out use="sol"/></Test>
<Test rank="13"><In use="g" param="I 1000"/><Out use="sol"/></Test>
<Test rank="14"><In use="g" param="q 500000"/><Out use="sol"/></Test>

</Problem>
</CATS>