Under construction

Still being built. Things may change

What Was My Rank??

Time limit1sMemory limit1024 MB

Summary
Given students' scores and some remembered grade orderings, decide for each query whether one student's final grade is higher, lower, equal, or undetermined.
Level

Medium6 of 10

Topics
Graph, BFS, Math
Solved
No attempts yet

Problem

The long second semester is almost over. Only the grade review period is left before the end of the term.

Students in the course "Algorithm Design and Analysis" know their assignment score pp, midterm score qq, and final exam score rr. Each student's final grade is computed as follows, using three positive integers AA, BB, and CC that give the weight of each score. Ap+Bq+CrAp + Bq + Cr

This semester, to encourage everyone to do their best on every exam and assignment, the weights AA, BB, and CC will not be published. So it matters that students write down the final grade shown during the grade review period.

Excited about the upcoming break, the students did not check their grades properly and forgot their own final grades. Later, when they became curious, they tried to check again, but it was hopeless.

Luckily, some students remember a classmate whose final grade was higher than their own. Use this information to estimate your own final grade. Write a program that answers questions about which of two students has the higher final grade.

Input

The first line contains the number of students NN, the number of remembered comparisons MM, and the number of queries QQ. (2≤N≤2 0002 \le N \le 2\,000, 1≤M,Q≤2 0001 \le M, Q \le 2\,000)

Each of the next NN lines contains the integers pp, qq, and rr for one student. (0≤p,q,r≤10 0000 \le p, q, r \le 10\,000)

Each of the next MM lines contains integers ii and jj, meaning that student ii had a higher final grade than student jj. (1≤i,j≤N1 \le i,j \le N, i≠ji \neq j)

Each of the next QQ lines contains integers ii and jj, asking which of student ii and student jj has the higher final grade. (1≤i,j≤N1 \le i,j \le N, i≠ji \neq j)

The input is always valid.

Output

Print QQ lines. For each query with ii and jj, print > if student ii has a higher final grade than student jj, < if student ii has a lower final grade, = if they are equal, and ? if the result cannot be determined.

Examples1

  1. Example 1

    Input
    5 3 4
    2 1 4
    1 2 4
    1 1 5
    2 2 0
    1 1 5
    1 3
    2 5
    5 4
    1 4
    3 2
    1 2
    3 5
    
    Expected output
    >
    <
    ?
    =