11#!/usr/bin/env python3.8
2+ # https://note.nkmk.me/python-union-find/
3+ from collections import defaultdict
4+
5+ class UnionFind ():
6+ def __init__ (self ,n ):
7+ self .n = n
8+ self .parents = [- 1 ]* n
9+
10+ def find (self ,x ):
11+ if self .parents [x ]< 0 :
12+ return x
13+ else :
14+ self .parents [x ]= self .find (self .parents [x ])
15+ return self .parents [x ]
16+
17+ def union (self ,x ,y ):
18+ x = self .find (x )
19+ y = self .find (y )
20+
21+ if x == y :
22+ return
23+
24+ if self .parents [x ]> self .parents [y ]:
25+ x ,y = y ,x
26+
27+ self .parents [x ]+= self .parents [y ]
28+ self .parents [y ]= x
29+
30+ def size (self ,x ):
31+ return - self .parents [self .find (x )]
32+
33+ def same (self ,x ,y ):
34+ return self .find (x )== self .find (y )
35+
36+ def members (self ,x ):
37+ root = self .find (x )
38+ return [i for i in range (self .n )if self .find (i )== root ]
39+
40+ def roots (self ):
41+ return [i for i ,x in enumerate (self .parents )if x < 0 ]
42+
43+ def group_count (self ):
44+ return len (self .roots ())
45+
46+ def all_group_members (self ):
47+ group_members = defaultdict (list )
48+ for member in range (self .n ):
49+ group_members [self .find (member )].append (member )
50+ return group_members
51+
52+ def __str__ (self ):
53+ return '\n ' .join (f'{ r } :{ m } ' for r ,m in self .all_group_members ().items ())
54+
55+
56+ N ,M = map (int ,input ().split ())
57+
58+ edges = []
59+ for i in range (N ):
60+ edges .append ((i ,i + N ))
61+
62+ for i in range (M ):
63+ a ,b ,c ,d = input ().split ()
64+ a = int (a )
65+ c = int (c )
66+ a -= 1
67+ c -= 1
68+ if b == 'B' :
69+ a += N
70+ if d == 'B' :
71+ c += N
72+ edges .append ((a ,c ))
73+
74+ uf = UnionFind (2 * N )
75+ cnt = 0
76+ for edge in edges :
77+ if uf .same (edge [0 ],edge [1 ]):
78+ cnt += 1
79+ uf .union (edge [0 ],edge [1 ])
80+
81+ # print(cnt)
82+ # print(uf.all_group_members())
83+ print (cnt ,uf .group_count ()- cnt )