316. Code Tanks

Time limit per test: 0.25 second(s)
Memory limit: 65536 kilobytes
input: standard
output: standard

Hopefully yesterday you participated in the fascinating Code Game Challenge event. And now you have a unique chance to play on the side of the organizers team. You need to solve one of the many challenging tasks organizers have met during the Code Game Challenge preparation process.

The problem is the following. You are given the log of one match with N tanks participating. The log is a sequence of successful bullet shots, i.e. hits. Shots are listed in the log in the order of the corresponding bullet hit the target tank as this happened in the match. You need to calculate the number of hit points and the score of each tank at the end of the match.

Here are the Code Game Challenge rules essential for this problem:

The first line of the input contains two integer numbers N and M (2 ≤ N ≤ 6; 1 ≤ M ≤ 4000), where N is the number of tanks participating in the match and M is the number of shots fired. The following M lines contain the descriptions of the shots. Each description consists of two different integer numbers from 1 to N. The first one is the number of the tank which fired the shot and the second one is the number of the tank which was hit by the shot.

Write N lines to the output, one line for each tank, in the order of the tank numbers. Write two integer numbers to each line — the number of hit points and the number of score points of the corresponding tank at the end of the match.

sample input
sample output
3 3
2 1
1 2
2 1
84 45
92 52
100 50

Online Contester Team © 2002 - 2010. All rights reserved.