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.

EIUGRDSA - Excercise grades

Mr X ask his students to submit their exerices to a grading system. Students can submit unlimited times until the deadline for each problem. However, for each problem, student will received the highest score among all submissions. 

Given students submissions and the list of courses, help X to calculate grades for each student.

Ông X yêu cầu sinh viên của mình nộp bài kiểm tra của họ cho một hệ thống chấm điểm. Học sinh có thể gửi không giới hạn thời gian cho đến thời hạn cho mỗi vấn đề. Tuy nhiên, đối với mỗi vấn đề, sinh viên sẽ nhận được điểm cao nhất trong số tất cả các bài nộp.
Cho sinh viên nộp bài và danh sách các khóa học, giúp X tính điểm cho từng sinh viên.

 

Input

The first line contains three integers n, p, m, which are the number of students, the number of problems and the number of submissions(n ≤ 105, p ≤ 100, m ≤ 2*105).

The second line contains n integers representing the student ids

The third line is p integers, which are the exercise codes.

In the next m lines, each line consists of 3 numbers: ni, pi and si, which are student id, exercise code, and scores which show the results of each submission.

All numbers are in signed 32 bit integer ranges

Output

Consists of n lines, each containing a student ID and the average grade .

The results should be in order of increasing student ids and the average grade is rounded down to the unit.

Example

Input:
2 2 3
1 2
11 12
1 11 80
1 12 90
2 12 100
Output:
1 85
2 50

Added by:Ha Minh Ngoc
Date:2017-03-15
Time limit:1s-1.5s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:CSHARP C++ 4.3.2 CPP CPP14 CPP14-CLANG FSHARP GO JAVA JS-MONKEY NODEJS PHP PYTHON PYPY PYPY3 PYTHON3 RUBY SQLITE SWIFT VB.NET
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.