#!/usr/bin/env python

import sys

PYID = ""
CATE = 0
WEIGHT = 0.0000
Ocate = 0
Oweight = 0.0000
wrong = 0
equal = 0
for line in sys.stdin
    if len(line) >5:
        (pyid, cate, weight) = line.strip().split()
        cate = int(cate)
        weight = float(weight)
        if pyid == PYID:
            if cate == 10110 or cate == 10111:
                if Ocate != 0:
                    if cate != Ocate:
                        if weight >Oweight:
                            weight = weight - Oweight
                            Ocate = 0
                            print "%s\t%s\t%s" % (pyid, cate, weight)
                        if weight == Oweight:
                            weight = 0.000  
                            Ocate = 0
                            equal = 0
                        else:
                            cate = Ocate
                            weight = Oweight - weight
                            Ocate = 0
                            print "%s\t%s\t%s" % (pyid, cate, weight)
                    else:
                        wrong += 1
                        Ocate = 0
                else:
                    Ocate = cate
                    Oweight =weight
            else:
                CATE = cate
                WEIGHT = weight
                print "%s\t%s\t%s" % (pyid, cate, weight)
        else:
            while(Ocate):
                print "%s\t%s\t%s" % (PYID, Ocate, Oweight)
                Ocate = 0
                Oweight = 0.000
            PYID = pyid
            CATE = cate
            WEIGHT = weight
            print "%s\t%s\t%s" % (pyid, cate, weight)

f = open("wrong.txt","w")
f.write(str(wrong))
f.write(str(equal))
f.close()
