#K16276. Total Units Sold

    ID: 24543 Type: Default 1000ms 256MiB

Total Units Sold

Total Units Sold

You are given sales data over a period of multiple days. The first line of the input contains two integers \(n\) and \(d\), where \(n\) is the number of items and \(d\) is the number of days.

For each day, the input starts with an integer \(m\) that indicates the number of sales records for that day, followed by \(m\) lines. Each of these lines contains two integers: the item ID and the number of units sold for that transaction. Items are numbered from 1 to \(n\).

Your task is to compute and output the total units sold for each item over all days.

Note: The total for an item is the sum of the units sold across all days. Formally, if \(a_{ij}\) represents the units sold for item \(i\) in the \(j\)-th transaction, then the total units sold for item \(i\) is \(\sum a_{ij}\).

inputFormat

The input is given via standard input (stdin) with the following format:

Line 1: Two space-separated integers (n) and (d), representing the number of items and the number of days, respectively. For each of the next (d) days:

  • A line containing an integer (m), the number of sales records for that day.
  • (m) subsequent lines, each containing two space-separated integers: the item ID and the number of units sold.

outputFormat

Output (n) lines to standard output (stdout). The i-th line should contain a single integer representing the total units sold for item i.## sample

3 2
2
1 10
3 5
1
2 7
10

7 5

</p>