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: Div1 (for advanced coders) and Div2 (for beginner coders). Two rounds, Div1 and Div2, can go simultaneously, (Div1 round cannot be held without Div2) 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 Div1 round is always greater.

Sereja is a beginner coder, so he can take part only in rounds of Div2 type. At the moment he is taking part in a Div2 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 Div2 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 num2 num1" (where num2 is the identifier of this Div2 round, num1 is the identifier of the Div1 round). It is guaranteed that num1 - num2 = 1. If Sereja took part in a usual Div2 round, then the corresponding line looks like: "2 num" (where num is the identifier of this Div2 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.

Sample test(s)
Input
3 2 2 1 2 2
Output
0 0
Input
9 3 1 2 3 2 8 1 4 5
Output
2 3
Input
10 0
Output
5 9
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 Div2 round and the round with identifier 6 will be synchronous with the Div1 round.

The maximum number of rounds equals 3. In this case all unused identifiers belong to usual Div2 rounds

codeforces 235 div2 B. Sereja and Contests的更多相关文章

  1. codeforces 235 div2 C Team

    题目:http://codeforces.com/contest/401/problem/C 题意:n个0,m个1,求没有00或111的情况. 这么简单的题..... 做题的时候脑残了...,今天,贴 ...

  2. codeforces 235 div2 A. Vanya and Cards

    Vanya loves playing. He even has a special set of cards to play with. Each card has a single integer ...

  3. [codeforces 235]A. LCM Challenge

    [codeforces 235]A. LCM Challenge 试题描述 Some days ago, I learned the concept of LCM (least common mult ...

  4. Codeforces #180 div2 C Parity Game

    // Codeforces #180 div2 C Parity Game // // 这个问题的意思被摄物体没有解释 // // 这个主题是如此的狠一点(对我来说,),不多说了这 // // 解决问 ...

  5. Codeforces #541 (Div2) - E. String Multiplication(动态规划)

    Problem   Codeforces #541 (Div2) - E. String Multiplication Time Limit: 2000 mSec Problem Descriptio ...

  6. Codeforces #541 (Div2) - F. Asya And Kittens(并查集+链表)

    Problem   Codeforces #541 (Div2) - F. Asya And Kittens Time Limit: 2000 mSec Problem Description Inp ...

  7. Codeforces #541 (Div2) - D. Gourmet choice(拓扑排序+并查集)

    Problem   Codeforces #541 (Div2) - D. Gourmet choice Time Limit: 2000 mSec Problem Description Input ...

  8. Codeforces #548 (Div2) - D.Steps to One(概率dp+数论)

    Problem   Codeforces #548 (Div2) - D.Steps to One Time Limit: 2000 mSec Problem Description Input Th ...

  9. 【Codeforces #312 div2 A】Lala Land and Apple Trees

    # [Codeforces #312 div2 A]Lala Land and Apple Trees 首先,此题的大意是在一条坐标轴上,有\(n\)个点,每个点的权值为\(a_{i}\),第一次从原 ...

随机推荐

  1. Todo&Rocket

    Todo是怎么实现的? 前面两篇博客分别介绍了MVC和Backbone.js的逻辑,但是实战获真知,在来一篇来显示下Todo是怎么通过Backbone.js连接起来的. 忽略掉所有的代码,我们只是打开 ...

  2. 《Linux内核分析》第二周学习报告

    <Linux内核分析>第二周学习报告 ——操作系统是如何工作的 姓名:王玮怡  学号:20135116 第一节 函数调用堆栈 一.三个法宝 二.深入理解函数调用堆栈 三.参数传递与局部变量 ...

  3. 20135202闫佳歆--week4 课本第5章学习笔记

    第五章 系统调用 一.与内核通信 系统调用在用户控件进程和硬件设备之间添加了一个中间层,作用如下" 为用户空间提供了一种硬件的抽象接口 系统调用保证了系统的稳定和安全 每个进程都运行在虚拟系 ...

  4. 5月29,48h,Geekathon,创业极客的梦想起点

    http://mp.weixin.qq.com/s?__biz=MjM5ODQ3MDIwMg==&mid=213768178&idx=1&sn=0a607fac483f3eab ...

  5. Feature List

    我组最终决定所做的软件工程项目是Bing词典(UWP)的背单词模块,下面是初步定下的Feature List. 按用户场景变化顺序列举(假设是新用户): 1.用户可通过点击“背单词”标识或按钮进入背单 ...

  6. Beat版本冲刺(七)

    目录 组员情况 组员1:胡绪佩 组员2:胡青元 组员3:庄卉 组员4:家灿 组员5:恺琳 组员6:翟丹丹 组员7:何家伟 组员8:政演 组员9:黄鸿杰 组员10:何宇恒 组员11:刘一好 展示组内最新 ...

  7. Windows 64位环境的Java 服务配置

    有个任务,需要远程起调Windows64服务器下的程序,那么需要在Windows服务器中注入一个deamon服务,都知道Linux环境做成后台服务非常简单,nohup &很快能解决问题,但wi ...

  8. oracle-表空间剩余空间大小占比查询

    select tablespace_name, max_gb, used_gb, round(100 * used_gb / max_gb) pct_used from (select a.table ...

  9. Linux_MySql_tar_安装(转)

    系统版本:CentOs 7.* Mysql版本:5.7.17(自己测试版本) 根据博主[大大的橙子]博文转载记录(大部分照搬了,只修改少许部分) 一.基本环境部署 #卸载系统自带的Mariadb [r ...

  10. [JZOJ 5402] God Knows

    终于搞完了这乡里别题目 $ $ 考虑一个 \(dp\) ,设 \(f[i]\) 表示最后一个匹配选 \((i,p[i])\) 的最小费用 首先我们考虑答案长什么样 假设根据 \(p[i]\) 排序 , ...