Morning Run


  • محدودیت زمان: ۱ ثانیه
  • محدودیت حافظه: ۲۵۶ مگابایت

Everyday Space Runners go to the Enghelab Sports Complex for a morning run in the “Health Road”. They love to exercise and workout. The only thing bothering them is that some people are not punctual and they do not arrive on-time. After days of discussion, they decided to run individually.

They run along on the axis Ox. For every person there are three parameters characterizing their behavior: ti,si,fit_i, s_i, f_i — the moment of time when the ii-th person starts running, the start point and the end point of the run respectively. Each person moves in a straight line along the road from sis_i to fif_i with a constant speed of either 11 or 1-1 depending on the direction.

If two or more persons meet at the health road (they are at the same point at the same time, no matter which directions they are going) they all greet each other. Like in the normal life, every pair of people greet each other at most once.

You task is to calculate for every person how many people she greets while running along the health road. Please, pay attention to the fact that ii-th person may meet and greet any other person at points sis_i and fif_i.

After a person achieves the destination point fif_i she moves out of the road and cannot greet anyone else. The same rule applies to the start of the run: a person cannot greet anyone until she appears on the road.

ورودی🔗

At the first line of the input, integer NN is given – number of groups. In the each of next NN lines, there are three space-separated integers ti,si,fit_i, s_i, f_i.

1N501 \leq N \leq 50 1ti,si,fi1091 \leq t_i, s_i, f_i \leq 10^9sitis_i \neq t_i

خروجی🔗

The single line of the output should contain a sequence of nn integers r1,r2,,rnr_1, r_2, \dots, r_n separated by a space, where rir_i denotes the number of times which the ii-th person greets other people while running along the health road.

مثال‌ها🔗

ورودی نمونه ۱🔗

4
1 1 2
1 3 2
2 2 3
2 1 2
Plain text

خروجی نمونه ۱🔗

2 2 2 0
Plain text

ورودی نمونه ۲🔗

4
10 1 1000000000
10 1000000000 1
5 1 3
8 5 3
Plain text

خروجی نمونه ۲🔗

1 1 0 0
Plain text