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 num_2 num_1" (where num_2 is the identifier of this Div2 round, num_1 is the identifier of the Div1 round). It is guaranteed that num_1 - num_2 = 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.


-----Examples-----
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.

Difficulty: EASY

Solutions:
(X, n) = list(map(int, input().split()))
Taken = [True] * (X + 1)
for i in range(n):
	x = list(map(int, input().split()))
	if x[0] == 1:
		Taken[x[1]] = False
		Taken[x[2]] = False
	else:
		Taken[x[1]] = False
cnt = 0
minn = 0
maxx = 0
ans = 0
for i in range(1, X):
	if Taken[i]:
		cnt += 1
		maxx += 1
	else:
		ans += cnt // 2
		if cnt % 2 != 0:
			ans += 1
		cnt = 0
ans += cnt // 2
if cnt % 2 != 0:
	ans += 1
print(ans, maxx)


(n, q) = map(int, input().split())
v = [0] * (n - 1)
for i in range(q):
	li = [int(i) for i in input().split()]
	v[li[1] - 1] = 2
	if li[0] == 1:
		v[li[2] - 1] = 1
ma = v.count(0)
mi = 0
for i in range(n - 1):
	if v[i] == 0:
		v[i] = 2
		mi += 1
		if i != n - 2 and v[i + 1] == 0:
			v[i + 1] = 1
print(mi, ma)


(x, k) = list(map(int, input().split()))
a = [False] * x
for i in range(k):
	o = list(map(int, input().split()))
	a[o[1]] = True
	if o[0] == 1:
		a[o[2]] = True
cnt1 = cnt2 = d = 0
for i in range(1, x):
	if a[i]:
		d = 0
	else:
		d ^= 1
		cnt1 += d
		cnt2 += 1
print(cnt1, cnt2)


(x, k) = list(map(int, input().split()))
a = [0]
u = [False] * x
k = k + 1
for i in range(1, k):
	o = list(map(int, input().split()))
	a.append(o[1])
	if o[0] == 1:
		u[o[1]] = True
a.append(x)
k = k + 1
a = sorted(a)
cnt1 = cnt2 = 0
for i in range(1, k):
	if u[a[i - 1]]:
		last = a[i - 1] + 1
	else:
		last = a[i - 1]
	cnt1 += a[i] - last >> 1
	cnt2 += a[i] - last - 1
print(cnt1, cnt2)


from itertools import groupby
R = lambda : map(int, input().split())
(x, k) = R()
a = [0] * (x - 1)
for _ in range(k):
	l = list(R())
	if l[0] == 1:
		a[l[2] - 1] = 1
	a[l[1] - 1] = 1
b = [len(list(g)) for (k, g) in groupby(a) if k == 0]
print(sum((l // 2 + l % 2 for l in b)), sum(b))


import math
(x, k) = map(int, input().split())
a = [0] * x
for i in range(k):
	c = list(map(int, input().split()))
	if len(c) == 2:
		a[c[1]] = 1
	else:
		a[c[1]] = 1
		a[c[2]] = 1
max = 0
min = 0
for i in range(x):
	if a[i] == 0:
		max += 1
max -= 1
min = max
i = 1
while i < x - 1:
	if a[i] == 0 and a[i + 1] == 0:
		min -= 1
		i += 1
	i += 1
print(min, max)


(x, k) = [int(x) for x in input().split()]
used = [0, x]
for i in range(k):
	(a, *l) = [int(x) for x in input().split()]
	used += l
used.sort()
m = M = 0
for i in range(len(used) - 1):
	M += used[i + 1] - used[i] - 1
	m += (used[i + 1] - used[i]) // 2
print(m, M)


def read_ints():
	return list(map(int, input().strip().split()))
(t, k) = read_ints()
all = []
for _ in range(k):
	avail = list(read_ints())
	for x in avail[1:]:
		all.append(x)
all.sort()
(res_min, res_max) = (0, 0)
last = 0
for num in all:
	d = num - last
	res_min += d // 2
	res_max += d - 1
	last = num
d = t - last
res_min += d // 2
res_max += d - 1
print(res_min, res_max)


import math
(x, k) = map(int, input().split(' '))
given = [0 for x in range(x - 1)]
for _ in range(k):
	a = list(map(int, input().split(' ')))
	if a[0] == 2:
		given[a[1] - 1] = 1
	else:
		given[a[2] - 1] = 1
		given[a[1] - 1] = 1
cmax = 0
for y in range(x - 1):
	if given[y] == 0:
		cmax = cmax + 1
pp = 0
t = 0
ss = x - 1
while t < ss:
	if t < ss - 1 and given[t] == 0 and (given[t + 1] == 0):
		pp = pp + 1
		t = t + 2
	else:
		t = t + 1
print(cmax - pp, cmax)


def main():
	(x, k) = map(int, input().split())
	l = [(0, 0)]
	for _ in range(k):
		tmp = list(map(int, input().split()))
		l.append((tmp[1], tmp[-1]))
		l.sort()
	l.append((x, x))
	mi = ma = 0
	for ((a, b), (c, _)) in zip(l, l[1:]):
		x = c - b
		mi += x // 2
		ma += x - 1
	print(mi, ma)

def __starting_point():
	main()
__starting_point()


(x, n) = map(int, input().strip().split())
s = set(range(1, x))
for _ in range(n):
	xs = list(map(int, input().strip().split()))
	if xs[0] == 2:
		s.remove(xs[1])
	else:
		s.remove(xs[1])
		s.remove(xs[2])
(m, i) = (0, 0)
s = sorted(s)
while i < len(s):
	if i == len(s) - 1:
		m += 1
		break
	elif s[i] == s[i + 1] - 1:
		m += 1
		i += 2
	else:
		m += 1
		i += 1
print(m, len(s))


(x, n) = map(int, input().split())
s = set()
for i in range(n):
	l = list(map(int, input().split()))
	for j in range(1, len(l)):
		s.add(l[j])
m = []
for i in range(1, x):
	if i not in s:
		m.append(i)
max = len(m)
min = 0
while len(m) > 0:
	if len(m) == 1:
		min += 1
		break
	if m[-1] - m[-2] == 1:
		m.pop()
	m.pop()
	min += 1
print(min, max)


(x, k) = map(int, input().split())
s = set()
for i in range(k):
	a = list(map(int, input().split()))
	if a[0] == 1:
		s.add(a[1])
		s.add(a[2])
	else:
		s.add(a[1])
smax = set()
smin = set()
for i in range(1, x):
	if not i in s and (not i + 1 in s) and (not i in smin):
		smin.add(i + 1)
	if not i in s:
		smax.add(i)
	if not i in s and i + 1 in s:
		smin.add(i)
print(len(smin), len(smax))


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def fact(x):
	if x == 0:
		return 1
	else:
		return x * fact(x - 1)

def lower_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] >= num:
			answer = middle
			end = middle - 1
		else:
			start = middle + 1
	return answer

def upper_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] <= num:
			answer = middle
			start = middle + 1
		else:
			end = middle - 1
	return answer

def abs(x):
	return x if x >= 0 else -x

def binary_search(li, val, lb, ub):
	ans = 0
	while lb <= ub:
		mid = (lb + ub) // 2
		if li[mid] > val:
			ub = mid - 1
		elif val > li[mid]:
			lb = mid + 1
		else:
			ans = 1
			break
	return ans
(n, k) = map(int, input().split())
check = [0] * n
check[-1] = 1
check.insert(0, 1)
for i in range(k):
	contest = list(map(int, input().split()))
	contest = contest[1:]
	for i in contest:
		check[i] = 1
cnt = check.count(0)
(ind, pair) = (0, 0)
cntpair = 0
for i in range(n):
	if check[i] == 0 and check[i + 1] == 0:
		pair += 1
	elif pair != 0:
		pair += 1
		ind += pair % 2
		cntpair += pair // 2
		pair = 0
for i in range(1, n):
	if check[i] == 0 and check[i - 1] != 0 and (check[i + 1] != 0):
		ind += 1
print(ind + cntpair, cnt)


(x, k) = map(int, input().split())
a = [1] * x
for i in range(k):
	s = input().split()
	if s[0] == '1':
		a[int(s[1])] = 0
		a[int(s[2])] = 0
	else:
		a[int(s[1])] = 0
i = 1
t = 0
while i < x:
	if a[i] == 1:
		if i + 1 < x and a[i + 1] == 1:
			t += 1
		i += 2
	else:
		i += 1
print(sum(a[1:]) - t, sum(a[1:]))


(n, k) = map(int, input().split())
rounds = []
rounds.append(0)
rounds.append(n)
for i in range(k):
	arr = [int(i) for i in input().split()]
	if arr[0] == 1:
		rounds.append(arr[1])
		rounds.append(arr[2])
	else:
		rounds.append(arr[1])
rounds.sort()
ansmax = 0
ansmin = 0
for i in range(len(rounds) - 1):
	if rounds[i + 1] - rounds[i] - 1 > 0:
		ansmin += (rounds[i + 1] - rounds[i] - 1) // 2 + (rounds[i + 1] - rounds[i] - 1) % 2
		ansmax += rounds[i + 1] - rounds[i] - 1
print(ansmin, ansmax)


(x, k) = list(map(int, input().split()))
r = []
for i in range(k):
	l = list(map(int, input().split()))
	for i in l[1:]:
		r.append(i)
r.sort()
f = []
j = 0
for i in range(1, x):
	if j <= len(r) - 1:
		if i == r[j]:
			j = j + 1
		else:
			f.append(i)
	else:
		f.append(i)
(m1, m2) = (0, len(f))
i = 0
while i < len(f):
	if i + 1 <= len(f) - 1 and f[i + 1] - f[i] == 1:
		i = i + 2
		m1 = m1 + 1
	else:
		m1 = m1 + 1
		i = i + 1
print(m1, m2)


R = lambda : map(int, input().split())
(x, k) = R()
li = [-1] * (x + 1)
for i in range(k):
	inp = list(R())
	if inp[0] == 2:
		li[inp[1]] = 2
	else:
		li[inp[1]] = 2
		li[inp[2]] = 1
minm = 0
maxm = 0
d = 0
for i in range(1, x):
	if li[i] > 0:
		d = 0
	else:
		d ^= 1
		minm += d
		maxm += 1
print(minm, maxm)


(x, k) = map(int, input().split())
arr = [0, x]
for i in range(k):
	(t, *lst) = [int(i) for i in input().split()]
	arr += lst
arr.sort()
(a, b) = (0, 0)
for i in range(len(arr) - 1):
	a += (arr[i + 1] - arr[i]) // 2
	b += arr[i + 1] - arr[i] - 1
print(a, b)


(x, k) = map(int, input().split())
vis = [0] * x
for i in range(k):
	a = [int(x) for x in input().split()]
	if len(a) == 2:
		q = a[1]
		vis[q] = 1
	else:
		(q, r) = (a[1], a[2])
		vis[q] = 1
		vis[r] = 1
maxi = 0
for i in range(1, x):
	if vis[i] == 0:
		maxi += 1
mini = maxi
i = 2
while i < x:
	if vis[i] == 0 and vis[i - 1] == 0:
		mini -= 1
		i += 1
	i += 1
print(mini, maxi)


(x, k) = map(int, input().split(' '))
d = []
l = []
for i in range(k):
	s = list(map(int, input().split(' ')))
	d.append(s[1])
	if s[0] == 1:
		d.append(s[2])
max_n = 0
min_n = 0
for i in range(1, x):
	if i not in d:
		max_n += 1
for i in range(1, x):
	if i not in d and i + 1 not in d and (i not in l):
		min_n += 1
		l.append(i)
		l.append(i + 1)
	elif i not in d and i not in l:
		min_n += 1
		l.append(i)
print(str(min_n) + ' ' + str(max_n))


(x, k) = map(int, input().split(' '))
hs = [0] * 4001
hs[x] = 1
for i in range(k):
	li = list(map(int, input().split(' ')))
	hs[li[1]] = 1
	if li[0] == 1:
		hs[li[2]] = 1
mx = 0
for i in range(1, x):
	if hs[i] == 0:
		mx += 1
mi = mx
i = 2
while i < x:
	if hs[i] == 0 and hs[i - 1] == 0:
		mi -= 1
		i += 1
	i += 1
print(mi, mx)


(x, k) = map(int, input().split())
r = [(x, x)]
for i in range(k):
	l = [int(x) for x in input().split()]
	r.append((l[1], l[2]) if l[0] == 1 else (l[1], l[1]))
r.sort()
(v1, v2, prev) = (0, 0, 0)
for cr in r:
	v1 += (cr[0] - prev) // 2
	v2 += cr[0] - prev - 1
	prev = cr[1]
print(v1, v2)


import sys
inp = sys.stdin.readlines()
ii = 0
out = []
(x, k) = map(int, inp[ii].split())
ii += 1
roundshappened = []
for round in range(k):
	data = [int(d) for d in inp[ii].split()]
	ii += 1
	for d in data[1:]:
		roundshappened.append(d)
skipped = []
for x in range(1, x):
	if x not in roundshappened:
		skipped.append(x)
used = []
minimum = 0
for i in range(1, len(skipped)):
	if skipped[i - 1] + 1 == skipped[i] and skipped[i] not in used and (skipped[i - 1] not in used):
		minimum += 1
		used.append(skipped[i - 1])
		used.append(skipped[i])
minimum += len(skipped) - len(used)
maximum = len(skipped)
sys.stdout.write(str(minimum) + ' ' + str(maximum))


(x, k) = map(int, input().split())
p = [1] * 4001
p[0] = p[x] = 0
for i in range(k):
	t = list(map(int, input().split()))
	if t[0] == 1:
		p[t[1]] = p[t[2]] = 0
	else:
		p[t[1]] = 0
s = a = b = 0
for i in p:
	if i:
		s += 1
	elif s:
		a += s
		b += (s + 1) // 2
		s = 0
print(str(b) + ' ' + str(a))


import sys
f = sys.stdin
(x, k) = map(int, f.readline().strip().split())
a = []
for i in range(k):
	a += list(map(int, f.readline().strip().split()))[1:]
a.sort()
sub = list(set(range(1, x)) - set(a))
max = len(sub)
i = 0
sync = 0
while i < len(sub) - 1:
	if sub[i + 1] - sub[i] == 1:
		i += 1
		sync += 1
	i += 1
min = max - sync
print(min, max)


(x, k) = map(int, input().split())
a = [0] * x
q = x - 1
for i in range(k):
	s = list(map(int, input().split()))
	a[s[1] - 1] = 1
	if len(s) == 3:
		a[s[2] - 1] = 1
	q -= len(s) - 1
p = 0
for i in range(x - 1):
	if a[i] == 0:
		p += 1
		if a[i + 1] == 0:
			a[i + 1] = 1
print(p, q)


(x, k) = list(map(int, input().split()))
arr = [1] * (x - 1)
for i in range(k):
	a = list(map(int, input().split()))
	if a[0] == 1:
		arr[a[2] - 1] = 0
	arr[a[1] - 1] = 0
maxv = sum(arr)
arrn = []
cl = 0
for i in range(x - 1):
	if arr[i] == 1:
		arrn.append(i)
		cl += 1
minv = 0
if arrn:
	c = 0
	i = 0
	while i < cl - 1:
		if arrn[i + 1] - arrn[i] == 1:
			c += 1
			i += 2
		else:
			i += 1
	minv = maxv - c
print(minv, maxv)


import math
(n, m) = [int(x) for x in input().split()]
a = []
for i in range(m):
	l = [int(x) for x in input().split()][1:]
	a += l
a.sort()
if len(a) != 0:
	(ni, na) = (math.ceil((a[0] - 1) / 2), a[0] - 1)
	for i in range(1, len(a)):
		ni += math.ceil((a[i] - a[i - 1] - 1) / 2)
		na += a[i] - a[i - 1] - 1
	print(ni + math.ceil((n - 1 - a[-1]) / 2), na + n - 1 - a[-1])
else:
	print(n // 2, n - 1)


(x, k) = map(int, input().split())
a = []
mi = x - 1
for i in range(k):
	q = list(map(int, input().split()))
	if q[0] == 1:
		a.append(q[1])
		a.append(q[2])
		mi -= 2
	else:
		a.append(q[1])
		mi -= 1
a.append(x)
i = 1
ma = 0
while i < x:
	if not i in a:
		if not i + 1 in a:
			i += 2
		else:
			i += 1
		ma += 1
	else:
		i += 1
print(ma, mi)


(x, k) = map(int, input().split())
l = set(range(1, x))
for i in range(k):
	k = list(map(int, input().split()))
	if k[0] == 2:
		l.discard(k[1])
	else:
		l.discard(k[1])
		l.discard(k[2])
t = list(l)
t.sort()
count = 0
i = 1
while i < x:
	if i in l and i + 1 in l:
		count = count + 1
		i = i + 2
	else:
		i = i + 1
print(len(t) - count, len(t))


(x, k) = [int(i) for i in input().split()]
missed = [0] * x
for i in range(k):
	divs = [int(i) for i in input().split()]
	if divs[0] == 1:
		missed[divs[1]] = 1
		missed[divs[2]] = 1
	else:
		missed[divs[1]] = 1
max_answer = missed.count(0) - 1
good_subarrs = 0
i = 1
while i <= x - 1:
	if i < x - 1 and missed[i] == 0 and (missed[i + 1] == 0):
		good_subarrs += 1
		i += 2
	else:
		i += 1
print(max_answer - good_subarrs, max_answer)


R = lambda : map(int, input().split())
(n, m) = R()
a = set([i for i in range(1, n)])
for _ in range(m):
	b = list(R())
	for i in b[1:]:
		a.remove(i)
a = list(a)
n1 = len(a)
a.append(-1)
(c1, c2) = (0, 0)
for i in range(n1):
	if c2 == 0:
		if a[i] + 1 == a[i + 1]:
			c1 += 1
			c2 = 1
		else:
			c1 += 1
	else:
		c2 = 0
print(c1, n1)


def main():
	(x, t) = list(map(int, input().split()))
	markers = [1] * (x - 1)
	for c in range(t):
		r = [int(n) for n in input().split()]
		markers[r[1] - 1] = 0
		if r[0] == 1:
			markers[r[2] - 1] = 0
	c = 0
	max_num = 0
	min_num = 0
	for i in markers:
		if i:
			c += 1
			continue
		if c:
			max_num += c
			min_num += c + 1 >> 1
		c = 0
	if c:
		max_num += c
		min_num += c + 1 >> 1
	print(min_num, max_num)

def __starting_point():
	main()
__starting_point()


a = [int(i) for i in input().split(' ')]
present = a[0]
number = a[1]
l = [0 for i in range(present - 1)]
while number:
	a = [int(i) for i in input().split(' ')]
	if a[0] == 2:
		l[a[1] - 1] = 2
	else:
		l[a[1] - 1] = 2
		l[a[2] - 1] = 1
	number -= 1
maxi = l.count(0)
mini = 0
c = l
for i in range(present - 2):
	if c[i] == 0 and c[i + 1] == 0:
		mini += 1
		c[i] = 2
		c[i + 1] = 1
mini += c.count(0)
print(mini, maxi)


(n, m) = map(int, input().split())
set_ = set(range(1, n))
count_min = 0
for i in range(m):
	a = list(map(int, input().split()))
	if a[0] == 2:
		set_ = set_ - {a[1]}
	else:
		set_ = set_ - {a[1]}
		set_ = set_ - {a[2]}
a = list(set_)
a.sort()
i = 0
while i < len(a):
	if i + 1 <= len(a) - 1:
		if a[i + 1] - a[i] == 1:
			count_min = count_min + 1
			i = i + 1
		else:
			count_min = count_min + 1
	else:
		count_min = count_min + 1
	i = i + 1
print(count_min, len(a))


def STR():
	return list(input())

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def MAP2():
	return map(float, input().split())

def LIST():
	return list(map(int, input().split()))

def STRING():
	return input()
import string
import sys
from heapq import heappop, heappush
from bisect import *
from collections import deque, Counter, defaultdict
from math import *
from itertools import permutations, accumulate
dx = [-1, 1, 0, 0]
dy = [0, 0, 1, -1]
(x, k) = MAP()
if k == 0:
	x -= 1
	print(ceil(x / 2), x)
	exit(0)
visited = [0] * (x + 9)
visited[x] = 1
for i in range(k):
	l = LIST()
	visited[l[1]] = 1
	if len(l) == 3:
		visited[l[2]] = 1
(mn, mx) = (0, 0)
v = []
for i in range(1, x):
	if visited[i] == 0:
		v.append(i)
		mx += 1
if len(v) != 0:
	prev = v[0]
	mn = 1
	for i in range(1, len(v)):
		if v[i] - prev != 1:
			prev = v[i]
			mn += 1
		else:
			continue
print(mn, mx)


def main():
	(x, k) = map(int, input().split())
	(l1, l2) = ([], [0])
	for _ in range(k):
		tmp = list(map(int, input().split()))
		l1.append(tmp[1])
		l2.append(tmp[-1])
	l1.sort()
	l2.sort()
	l1.append(x)
	mi = ma = 0
	for (a, b) in zip(l1, l2):
		x = a - b
		mi += x // 2
		ma += x - 1
	print(mi, ma)
main()


from sys import stdin, stdout
(x, k) = map(int, stdin.readline().split())
p = [1] * 4002
p[0] = p[x] = 0
for i in range(k):
	t = list(map(int, stdin.readline().split()))
	if t[0] == 1:
		p[t[1]] = p[t[2]] = 0
	else:
		p[t[1]] = 0
s = a = b = 0
for i in p:
	if i:
		s += 1
	elif s:
		a += s
		b += (s + 1) // 2
		s = 0
stdout.write(str(b) + ' ' + str(a))


I = lambda : map(int, input().split())
(x, k) = I()
R = [0, x]
for _ in range(k):
	(_, *r) = I()
	R += r
R.sort()
max_ = min_ = 0
for i in range(len(R) - 1):
	min_ += (R[i + 1] - R[i]) // 2
	max_ += R[i + 1] - R[i] - 1
print(min_, max_)


def main():
	(x, k) = map(int, input().split())
	A = [0] * x
	mx = x - 1
	for i in range(k):
		s = list(map(int, input().split()))
		A[s[1] - 1] = 1
		if len(s) == 3:
			A[s[2] - 1] = 1
		mx -= len(s) - 1
	mn = 0
	for i in range(x - 1):
		if A[i] == 0:
			mn += 1
			if A[i + 1] == 0:
				A[i + 1] = 1
	print(mn, mx)
main()


(x, k) = map(int, input().split())
v = [0] * (x + 1)
v[0] = 1
v[x] += 1
for i in range(k):
	p = [int(i) for i in input().split()]
	v[p[1]] += 1
	if p[0] == 1:
		v[p[2]] += 1
(mini, maxi) = (0, 0)
flag = False
for i in range(x):
	if v[i] == 0:
		maxi += 1
		if v[i + 1] == 0 and (not flag):
			mini += 1
			flag = True
		else:
			flag = False
print(maxi - mini, maxi)


(curr, k) = map(int, input().split())
done = []
unused = []
for i in range(k):
	op = list(map(int, input().split()))
	op.pop(0)
	for j in op:
		done.append(j)
i = 1
while i < curr:
	if not i in done:
		unused.append(i)
	i += 1
i = 0
res = 0
while i < len(unused):
	if i + 1 < len(unused) and unused[i] + 1 == unused[i + 1]:
		i += 2
	else:
		i += 1
	res += 1
print(res, end=' ')
print(len(unused))