Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

No tag edit access

The problem statement has recently been changed. View the changes.

×
C. Tournament

time limit per test

2 secondsmemory limit per test

256 megabytesinput

standard inputoutput

standard outputRecently 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*_{i1}, *s*_{i2}, ..., *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.

Examples

Input

3 2

1 5

5 1

10 10

Output

1

2

1

Input

3 2

2 2

3 3

1 10

Output

1

1

3

Input

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.

Codeforces (c) Copyright 2010-2022 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: May/16/2022 14:02:10 (g2).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|