PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#BS0000133. Chọn đường thẳng để chụp ảnh (Place for a Selfie)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Chọn đường thẳng để chụp ảnh (Place for a Selfie)

Place for a Selfie

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

There are nn lines y=kixy=k_i x through the origin and mm upward-opening parabolas y=ajx2+bjx+cjy=a_jx^2+b_jx+c_j, with aj>0a_j>0. For each parabola, find any of the given lines with no common point with that parabola, neither crossing nor tangent. A line may be used for multiple parabolas. If several coefficients work, output any of them; otherwise report impossibility.

Input

The first line contains n,mn,m. Each of the next nn lines contains a line coefficient kik_i. Each of the next mm lines contains three integers aj,bj,cja_j,b_j,c_j. Lines and parabolas may be repeated.

Output

For each parabola, print YES and on the next line one coefficient kk from the given lines if a valid line exists; otherwise print NO. Upper/lower case is accepted for these words. A special checker validates any correct choice.

Subtasks

  • Subtask 1 (20 points): 1≤n≤121\le n\le 12; 1≤m≤121\le m\le 12; $|k_i|\le10^8;\ 1\le a_j\le10^8;\ |b_j|,|c_j|\le10^8$, 1≤i≤n1\le i\le n, 1≤j≤m1\le j\le m.
  • Subtask 2 (30 points): 1≤n≤20001\le n\le 2000; 1≤m≤20001\le m\le 2000; $|k_i|\le10^8;\ 1\le a_j\le10^8;\ |b_j|,|c_j|\le10^8$, 1≤i≤n1\le i\le n, 1≤j≤m1\le j\le m.
  • Subtask 3 (50 points): 1≤n≤1000001\le n\le 100000; 1≤m≤1000001\le m\le 100000; $|k_i|\le10^8;\ 1\le a_j\le10^8;\ |b_j|,|c_j|\le10^8$, 1≤i≤n1\le i\le n, 1≤j≤m1\le j\le m.

Examples

Input

2 3
1
4
1 2 1
2 5 1
1 0 0

Output

YES
1
YES
4
NO

Explanation

For (a,b,c)=(1,2,1)(a,b,c)=(1,2,1), line k=1k=1 yields discriminant (2−1)2−4(1)(1)=−3<0(2-1)^2-4(1)(1)=-3<0, so it never meets the parabola. For (2,5,1)(2,5,1), choosing k=4k=4 gives (5−4)2−4(2)(1)=−7<0(5-4)^2-4(2)(1)=-7<0. For (1,0,0)(1,0,0), every line passes through the origin, which is on the parabola, so no line works. Output YES 1, YES 4, and NO on separate lines.