@@E. Tournament

Posted planche

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了@@E. Tournament相关的知识,希望对你有一定的参考价值。

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·104, 1 ≤ k ≤ 10) — the number of tournaments and the number of kinds of sport, respectively.

Each of the next n lines contains k integers si1, si2, ..., sik (1 ≤ sij ≤ 109), where sij 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.

Examples
input
Copy
3 2
1 5
5 1
10 10
output
1
2
1
input
Copy
3 2
2 2
3 3
1 10
output
1
1
3
input
Copy
3 2
2 3
1 1
3 2
output
1
1
2
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.

以上是关于@@E. Tournament的主要内容,如果未能解决你的问题,请参考以下文章

Codeforces 678E:Another Sith Tournament 状压DP

关于代码片段的时间复杂度

错误记录Flutter 混合开发获取 BinaryMessenger 报错 ( FlutterActivityAndFragmentDelegate.getFlutterEngine() )(代码片段

错误:E/RecyclerView:未连接适配器;跳过片段上的布局

D - Knight Tournament

Knight Tournament 伪并查集(区间合并)