Codeforces Round 443 (Div. 1)
C
Tournament
Codeforces
2700
原题
← BD →
翻译中…

Recently a tournament in $*k*$ kinds of sports has begun in Berland. Vasya wants to make money on the bets.

翻译中…

The scheme of the tournament is very mysterious and not fully disclosed. Competitions are held back to back, each of them involves two sportsmen who have not left the tournament yet. Each match can be held in any of the $*k*$ kinds of sport. Loser leaves the tournament. The last remaining sportsman becomes the winner. Apart of this, the scheme can be arbitrary, it is not disclosed in advance.

翻译中…

Vasya knows powers of sportsmen in each kind of sport. He believes that the sportsmen with higher power always wins.

翻译中…

The tournament is held every year, and each year one new participant joins it. In the first tournament, only one sportsman has participated, in the second there were two sportsmen, and so on. Vasya has been watching the tournament for the last $*n*$ years. Help him to find the number of possible winners for each of the $*n*$ tournaments.

翻译中…

Input

翻译中…

The first line contains two integers $*n*$ and $*k*$ ($1 ≤ *n* ≤ 5·10^{4}$, $1 ≤ *k* ≤ 10$) — the number of tournaments and the number of kinds of sport, respectively.

翻译中…

Each of the next $*n*$ lines contains $*k*$ integers $*s*_{*i*1}, *s*_{*i*2}, ..., *s*_{*ik*}$ ($1 ≤ *s*_{*ij*} ≤ 10^{9}$), where $*s*_{*ij*}$ is the power of the $*i*$-th sportsman in the $*j*$-th kind of sport. The sportsman with higher powers always wins. It's guaranteed that for any kind of sport all of these powers are distinct.

翻译中…

Output

翻译中…

For each of the $*n*$ tournaments output the number of contenders who can win.

翻译中…

Note

翻译中…

In the first sample:

翻译中…

In the first tournament there is only one sportsman, and he is the winner.

翻译中…

In the second tournament, there are two sportsmen, and everyone can defeat another, depending on kind of sports.

翻译中…

In the third tournament, the third sportsman in the strongest in both kinds of sports, so he is the winner regardless of the scheme.

翻译中…

样例

Input #1
3 2
1 5
5 1
10 10
Output #1
1
2
1
InputCopy OutputCopy
Input #2
3 2
2 2
3 3
1 10
Output #2
1
1
3
InputCopy OutputCopy
Input #3
3 2
2 3
1 1
3 2
Output #3
1
1
2
InputCopy OutputCopy
题目信息
题号
878C
时间限制
2 s
内存限制
256 MB
标签
数据结构
图论

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。