#abc244h. [abc244_h]Linear Maximization

[abc244_h]Linear Maximization

Problem Statement

There is a set SS of points on a two-dimensional plane. SS is initially empty.

For each i=1,2,dots,Qi = 1, 2, \\dots, Q in this order, process the following query.

  • You are given integers Xi,Yi,AiX_i, Y_i, A_i, and BiB_i. Add point (Xi,Yi)(X_i, Y_i) to SS, and then find $\\displaystyle \\max_{(x,y) \\in S}\\left\\{A_ix + B_iy\\right\\}$.

Constraints

  • All values in input are integers.
  • 1Q2times1051≤Q≤2 \\times 10^5
  • Xi,Yi,Ai,Bi109|X_i|, |Y_i|, |A_i|, |B_i| ≤10^9
  • If iji ≠ j, then (Xi,Yi)(Xj,Yj)(X_i, Y_i) ≠ (X_j, Y_j).

Input

Input is given from Standard Input in the following format:

QQ X1X_1 Y1Y_1 A1A_1 B1B_1 X2X_2 Y2Y_2 A2A_2 B2B_2 vdots\\vdots XQX_Q YQY_Q AQA_Q BQB_Q

Output

Print QQ lines. The ii-th line should contain the answer for the ii-th query.


Sample Input 1

4
1 0 -1 -1
0 1 2 0
-1 0 1 1
0 -1 1 -2

Sample Output 1

-1
2
1
2
  • When i=1i = 1: add point (1,0)(1, 0) to SS, then it will become S=(1,0)S = \\{(1, 0)\\}. For (x,y)=(1,0)(x, y) = (1, 0), we have \-xy=1\-x - y = -1, which is the maximum.
  • When i=2i = 2: add point (0,1)(0, 1) to SS, then it will become S=(0,1),(1,0)S = \\{(0, 1), (1, 0)\\}. For (x,y)=(1,0)(x, y) = (1, 0), we have 2x=22x = 2, which is the maximum.
  • When i=3i = 3: add point (1,0)(-1, 0) to SS, then it will become S=(1,0),(0,1),(1,0)S = \\{(-1, 0), (0, 1), (1, 0)\\}. For (x,y)=(1,0)(x, y) = (1, 0) or (x,y)=(0,1)(x, y) = (0, 1), we have x+y=1x + y = 1, which is the maximum.
  • When i=4i = 4: add point (0,1)(0, -1) to SS, then it will become S=(1,0),(0,1),(0,1),(1,0)S = \\{(-1, 0), (0, -1), (0, 1), (1, 0)\\}. For (x,y)=(0,1)(x, y) = (0, -1), we have x2y=2x - 2y = 2, which is the maximum.

Sample Input 2

9
-1 4 -8 -2
9 -9 -7 7
4 1 6 7
-4 -1 -4 -5
-9 3 -2 -6
-1 0 -8 5
-8 -5 0 0
8 3 0 -4
2 -5 2 5

Sample Output 2

0
35
31
21
36
87
0
36
31