using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
static string InputPattern = "InputX";
static List<string> GetInputList()
{
var WillReturn = new List<string>();
if (InputPattern == "Input1") {
WillReturn.Add("5 3");
WillReturn.Add("3 R 5 B");
WillReturn.Add("5 R 3 B");
WillReturn.Add("4 R 2 B");
//1 2
}
else if (InputPattern == "Input2") {
WillReturn.Add("7 0");
//0 7
}
else if (InputPattern == "Input3") {
WillReturn.Add("7 6");
WillReturn.Add("5 R 3 R");
WillReturn.Add("7 R 4 R");
WillReturn.Add("4 B 1 R");
WillReturn.Add("2 R 3 B");
WillReturn.Add("2 B 5 B");
WillReturn.Add("1 B 7 B");
//2 1
}
else {
string wkStr;
while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
}
return WillReturn;
}
static int mN;
static void Main()
{
List<string> InputList = GetInputList();
int[] wkArr = InputList[0].Split(' ').Select(pX => int.Parse(pX)).ToArray();
mN = wkArr[0];
// 1からNが青色
// N+1から2Nが赤色
var InsUnionFindSizeInfo = new UnionFindSizeAndEdgeCntInfo();
for (int I = 1; I <= 2 * mN; I++) {
InsUnionFindSizeInfo.MakeSet(I);
}
for (int I = 1; I <= mN; I++) {
InsUnionFindSizeInfo.Unite(I, I + mN);
}
foreach (string EachStr in InputList.Skip(1)) {
string[] SplitArr = EachStr.Split(' ');
int A = int.Parse(SplitArr[0]);
string B = SplitArr[1];
int C = int.Parse(SplitArr[2]);
string D = SplitArr[3];
int FromNode = A;
int ToNode = C;
if (B == "R") {
FromNode += mN;
}
if (D == "R") {
ToNode += mN;
}
InsUnionFindSizeInfo.Unite(FromNode, ToNode);
}
long Cnt1 = 0;
long Cnt2 = 0;
var AppearRoot = new HashSet<long>();
for (long I = 1; I <= 2 * mN; I++) {
long RootNode = InsUnionFindSizeInfo.FindSet(I);
if (AppearRoot.Add(RootNode) == false) continue;
long Size = InsUnionFindSizeInfo.GetSize(RootNode);
long EdgeCnt = InsUnionFindSizeInfo.GetEdgeCnt(RootNode);
if (Size == EdgeCnt) {
Cnt1++;
}
else {
Cnt2++;
}
}
Console.WriteLine("{0} {1}", Cnt1, Cnt2);
}
}
// UnionFindSizeAndEdgeCntInfoクラス
internal class UnionFindSizeAndEdgeCntInfo
{
private class NodeInfoDef
{
internal long ParentNode;
internal long Rank;
internal long Size; // ノード数
internal long EdgeCnt; // 枝の数
}
private Dictionary<long, NodeInfoDef> mNodeInfoDict =
new Dictionary<long, NodeInfoDef>();
// 要素が1つである木を森に追加
internal void MakeSet(long pNode)
{
NodeInfoDef WillAdd = new NodeInfoDef();
WillAdd.ParentNode = pNode;
WillAdd.Rank = 0;
WillAdd.Size = 1;
WillAdd.EdgeCnt = 0;
mNodeInfoDict[pNode] = WillAdd;
}
// 合併処理
internal void Unite(long pX, long pY)
{
long XNode = FindSet(pX);
long YNode = FindSet(pY);
// 既に同じ木の場合
if (XNode == YNode) {
mNodeInfoDict[XNode].EdgeCnt++;
return;
}
long XRank = mNodeInfoDict[XNode].Rank;
long YRank = mNodeInfoDict[YNode].Rank;
if (XRank > YRank) {
mNodeInfoDict[YNode].ParentNode = XNode;
mNodeInfoDict[XNode].Size += mNodeInfoDict[YNode].Size;
mNodeInfoDict[XNode].EdgeCnt++;
mNodeInfoDict[XNode].EdgeCnt += mNodeInfoDict[YNode].EdgeCnt;
}
else {
mNodeInfoDict[XNode].ParentNode = YNode;
mNodeInfoDict[YNode].Size += mNodeInfoDict[XNode].Size;
mNodeInfoDict[YNode].EdgeCnt++;
mNodeInfoDict[YNode].EdgeCnt += mNodeInfoDict[XNode].EdgeCnt;
if (XRank == YRank) {
mNodeInfoDict[YNode].Rank++;
}
}
}
// ノードを引数として、木の根を取得
internal long FindSet(long pTargetNode)
{
// 根までの経路上のノードのList
var PathNodeList = new List<long>();
long CurrNode = pTargetNode;
while (CurrNode != mNodeInfoDict[CurrNode].ParentNode) {
PathNodeList.Add(CurrNode);
CurrNode = mNodeInfoDict[CurrNode].ParentNode;
}
// 経路圧縮 (親ポインタの付け替え)
foreach (long EachPathNode in PathNodeList) {
mNodeInfoDict[EachPathNode].ParentNode = CurrNode;
}
return CurrNode;
}
// ノードを引数として、木のサイズを取得
internal long GetSize(long pNode)
{
long RootNode = FindSet(pNode);
return mNodeInfoDict[RootNode].Size;
}
// ノードを引数として、木の枝数を取得
internal long GetEdgeCnt(long pNode)
{
long RootNode = FindSet(pNode);
return mNodeInfoDict[RootNode].EdgeCnt;
}
internal void DebugPrint()
{
foreach (var EachPair in mNodeInfoDict.OrderBy(pX => pX.Key)) {
Console.WriteLine("mNodeInfoDict[{0}].ParentNode={1}",
EachPair.Key, EachPair.Value.ParentNode);
}
}
}