Codeforces Round 235 (Div. 2)
B
Sereja and Contests
Codeforces
1200
原题
← AC →
翻译中…

Sereja is a coder and he likes to take part in Codesorfes rounds. However, Uzhland doesn't have good internet connection, so Sereja sometimes skips rounds.

翻译中…

Codesorfes has rounds of two types: $*Div*1$ (for advanced coders) and $*Div*2$ (for beginner coders). Two rounds, $*Div*1$ and $*Div*2$, can go simultaneously, ($*Div*1$ round cannot be held without $*Div*2$) in all other cases the rounds don't overlap in time. Each round has a unique identifier — a positive integer. The rounds are sequentially (without gaps) numbered with identifiers by the starting time of the round. The identifiers of rounds that are run simultaneously are different by one, also the identifier of the $*Div*1$ round is always greater.

翻译中…

Sereja is a beginner coder, so he can take part only in rounds of $*Div*2$ type. At the moment he is taking part in a $*Div*2$ round, its identifier equals to $*x*$. Sereja remembers very well that he has taken part in exactly $*k*$ rounds before this round. Also, he remembers all identifiers of the rounds he has taken part in and all identifiers of the rounds that went simultaneously with them. Sereja doesn't remember anything about the rounds he missed.

翻译中…

Sereja is wondering: what minimum and what maximum number of $*Div*2$ rounds could he have missed? Help him find these two numbers.

翻译中…

Input

翻译中…

The first line contains two integers: $*x*$ $(1 ≤ *x* ≤ 4000)$ — the round Sereja is taking part in today, and $*k*$ $(0 ≤ *k* < 4000)$ — the number of rounds he took part in.

翻译中…

Next $*k*$ lines contain the descriptions of the rounds that Sereja took part in before. If Sereja took part in one of two simultaneous rounds, the corresponding line looks like: "1 $*num*_{2}$ $*num*_{1}$" (where $*num*_{2}$ is the identifier of this $*Div*2$ round, $*num*_{1}$ is the identifier of the $*Div*1$ round). It is guaranteed that $*num*_{1} - *num*_{2} = 1$. If Sereja took part in a usual $*Div*2$ round, then the corresponding line looks like: "2 $*num*$" (where $*num*$ is the identifier of this $*Div*2$ round). It is guaranteed that the identifiers of all given rounds are less than $*x*$.

翻译中…

Output

翻译中…

Print in a single line two integers — the minimum and the maximum number of rounds that Sereja could have missed.

翻译中…

Note

翻译中…

In the second sample we have unused identifiers of rounds 1, 6, 7. The minimum number of rounds Sereja could have missed equals to 2. In this case, the round with the identifier 1 will be a usual $*Div*2$ round and the round with identifier $6$ will be synchronous with the $*Div*1$ round.

翻译中…

The maximum number of rounds equals $3$. In this case all unused identifiers belong to usual $*Div*2$ rounds.

翻译中…

样例

Input #1
3 2
2 1
2 2
Output #1
0 0
InputCopy OutputCopy
Input #2
9 3
1 2 3
2 8
1 4 5
Output #2
2 3
InputCopy OutputCopy
Input #3
10 0
Output #3
5 9
InputCopy OutputCopy
题目信息
题号
401B
时间限制
1 s
内存限制
256 MB
标签
贪心
模拟
数学

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