Problem hidden
This problem was hidden by Editorial Board member probably because it has incorrect language version or invalid test data, or description of the problem is not clear.

EIUATTEND3 - EIU Attendance

You are given an attendance list of EIU (multiple classes). Suppose that each class has some students attending all the class’s lessons, and every student joinned at least one lessons of overy class that they registered.

Your task is to write a program to print out attendance list of each class.

Input

-          The first line contains two integers N – all class sizes, M – all attendance list sizes (1 £ N, M £ 105).

-          Each line in the next N lines represents 2 integers: student ID (sID) and class ID (cID) (1 £ sID, cID £ 109).

-          Each line in the next M lines represents 3 integers: class’s start time (in milliseconds format), student ID and class ID followed by a boolean isCheckin (0 - absence or 1 - present) . All integers don’t exceed 1018.

Output

The required sorted list. The output should be starting with class ID1 followed by its attendance list, class ID2, its attendance list, … Each line in the attendance list contains student ID, the number of their absent days and the number of their attendant day. The list should be sorted in ascending order of class ID, student ID.

Sample

Input

Output

4 8

001 0001

002 0001

001 0002

003 0002

1656894600000 001 0001 1

1657153800000 001 0001 1

1657153800000 002 0001 1

1656894600000 001 0002 1

1656894600000 003 0002 1

1657153800000 003 0002 1

1657153800000 001 0002 0

1657758600000 003 0002 1

1657758600000 002 0002 1

0001

001 0 2

002 1 1

0002

001 2 1

003 0 3


Added by:Ha Minh Ngoc
Date:2022-08-29
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: GOSU
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.