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("6");
WillReturn.Add("2 1");
WillReturn.Add("2 2");
WillReturn.Add("3 2");
WillReturn.Add("5 3");
WillReturn.Add("2 2");
WillReturn.Add("3 3");
//2 3 0
//0 4 1
//4 1 0
//5 0 0
//0 4 1
//3 2 0
}
else if (InputPattern == "Input2") {
WillReturn.Add("2");
WillReturn.Add("1999 3");
WillReturn.Add("2000 1");
//0 1 0
//1 0 0
}
else if (InputPattern == "Input3") {
WillReturn.Add("8");
WillReturn.Add("3200 2");
WillReturn.Add("2800 3");
WillReturn.Add("2800 2");
WillReturn.Add("2700 1");
WillReturn.Add("2800 2");
WillReturn.Add("3200 1");
WillReturn.Add("2700 1");
WillReturn.Add("3200 3");
//6 1 0
//2 5 0
//3 3 1
//0 6 1
//3 3 1
//6 1 0
//0 6 1
//6 1 0
}
else {
string wkStr;
while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
}
return WillReturn;
}
struct ResultInfoDef
{
internal int Cnt;
internal int Win;
internal int Draw;
internal int Lose;
}
struct SplitInputDef
{
internal int Rate;
internal int Te;
}
static void Main()
{
List<string> InputList = GetInputList();
int N = int.Parse(InputList[0]);
int[] wkArr = { };
Action<string> SplitAct = pStr =>
wkArr = pStr.Split(' ').Select(X => int.Parse(X)).ToArray();
const int UB = 100000;
ResultInfoDef[,] ResultInfoArr = new ResultInfoDef[UB + 1, 4];
var SplitInputList = new List<SplitInputDef>(N);
foreach (string EachStr in InputList.Skip(1)) {
SplitAct(EachStr);
SplitInputList.Add(new SplitInputDef() { Rate = wkArr[0], Te = wkArr[1] });
ResultInfoArr[wkArr[0], wkArr[1]].Cnt++;
}
int PrevRateSum = 0;
for (int I = 0; I <= UB; I++) {
int CntG = ResultInfoArr[I, 1].Cnt;
int CntT = ResultInfoArr[I, 2].Cnt;
int CntP = ResultInfoArr[I, 3].Cnt;
if (CntG == 0 && CntT == 0 && CntP == 0) continue;
//グーの場合
ResultInfoArr[I, 1].Win = PrevRateSum + CntT;
ResultInfoArr[I, 1].Draw = CntG - 1;
ResultInfoArr[I, 1].Lose = N - PrevRateSum - CntT - CntG;
//チョキの場合
ResultInfoArr[I, 2].Win = PrevRateSum + CntP;
ResultInfoArr[I, 2].Draw = CntT - 1;
ResultInfoArr[I, 2].Lose = N - PrevRateSum - CntP - CntT;
//パーの場合
ResultInfoArr[I, 3].Win = PrevRateSum + CntG;
ResultInfoArr[I, 3].Draw = CntP - 1;
ResultInfoArr[I, 3].Lose = N - PrevRateSum - CntG - CntP;
PrevRateSum += CntG + CntT + CntP;
}
SplitInputList.ForEach(X =>
Console.WriteLine("{0} {1} {2}",
ResultInfoArr[X.Rate, X.Te].Win,
ResultInfoArr[X.Rate, X.Te].Lose,
ResultInfoArr[X.Rate, X.Te].Draw));
}
}