#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
double INFINITY;
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, int *, ...);
int main() {
  int n;
  scanf("%d", &n);
  while (n--) {
    int k;
    scanf("%d", &k);
    double max = -INFINITY;
    int max_i = 0;
    for (int i = 1; i <= k; i++) {
      int a, b, c;
      scanf("%d %d %d", &a, &b, &c);
      double der = (double)b / (a << 1);
      double val = -a * der * der + b * der + c;
      if (val > max) {
        max = val;
        max_i = i;
      }
    }
    printf("%d\n", max_i);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xed0(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
cmp    $0x0,%eax
je     1254 <main+0x134>
lea    0xeaa(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    0x2e7a(%rip),%rax
movsd  (%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x1,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     1240 <main+0x120>
lea    0xe51(%rip),%rdi
lea    -0x24(%rbp),%rsi
lea    -0x28(%rbp),%rdx
lea    -0x2c(%rbp),%rcx
mov    $0x0,%al
call   1040 <scanf@plt>
cvtsi2sdl -0x28(%rbp),%xmm0
mov    -0x24(%rbp),%eax
shl    $0x1,%eax
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
xor    %eax,%eax
sub    -0x24(%rbp),%eax
cvtsi2sd %eax,%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm2
cvtsi2sdl -0x28(%rbp),%xmm1
mulsd  -0x38(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsi2sdl -0x2c(%rbp),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    122d <main+0x10d>
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    1232 <main+0x112>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    119c <main+0x7c>
mov    -0x1c(%rbp),%esi
lea    0xdbf(%rip),%rdi
call   1030 <printf@plt>
jmp    1141 <main+0x21>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
lea    0xee1(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
subl   $0x1,0x10(%rsp)
jae    1159 <main+0x39>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xeb0(%rip),%r13
lea    0x1c(%rsp),%rbx
lea    0x18(%rsp),%rbp
lea    0x14(%rsp),%r14
jmp    1196 <main+0x76>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0xe92(%rip),%rdi
mov    %r15d,%esi
call   1030 <printf@plt>
subl   $0x1,0x10(%rsp)
jb     1148 <main+0x28>
lea    0xe79(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
cmpl   $0x0,0xc(%rsp)
mov    $0x0,%r15d
jle    1180 <main+0x60>
mov    0x2e2b(%rip),%rax
movsd  (%rax),%xmm3
xorps  0xe38(%rip),%xmm3
xor    %r12d,%r12d
xor    %r15d,%r15d
xchg   %ax,%ax
movaps %xmm3,0x20(%rsp)
add    $0x1,%r12d
mov    %r13,%rdi
mov    %rbx,%rsi
mov    %rbp,%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x1c(%rsp),%eax
xorps  %xmm0,%xmm0
cvtsi2sdl 0x18(%rsp),%xmm0
lea    (%rax,%rax,1),%ecx
xorps  %xmm1,%xmm1
cvtsi2sd %ecx,%xmm1
movapd %xmm0,%xmm2
divsd  %xmm1,%xmm2
neg    %eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
mulsd  %xmm2,%xmm1
mulsd  %xmm2,%xmm0
xorps  %xmm3,%xmm3
cvtsi2sdl 0x14(%rsp),%xmm3
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
addsd  %xmm1,%xmm3
movapd 0x20(%rsp),%xmm0
ucomisd %xmm0,%xmm3
cmova  %r12d,%r15d
maxsd  %xmm0,%xmm3
cmp    0xc(%rsp),%r12d
jl     11d0 <main+0xb0>
jmp    1180 <main+0x60>

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@INFINITY = global double 0.000000e+00
@.str.1 = [9 x i8] c"%d %d %d\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca double
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca double
%11 = alloca double
store i32 0, i32* %1
%12 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
br label %13
13: ; preds = %57, %0
%14 = load i32, i32* %2
%15 = add nsw i32 %14, -1
store i32 %15, i32* %2
%16 = icmp ne i32 %14, 0
br i1 %16, label %17, label %60
17: ; preds = %13
%18 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%19 = load double, double* @INFINITY
%20 = fneg double %19
store double %20, double* %4
store i32 0, i32* %5
store i32 1, i32* %6
br label %21
21: ; preds = %54, %17
%22 = load i32, i32* %6
%23 = load i32, i32* %3
%24 = icmp sle i32 %22, %23
br i1 %24, label %25, label %57
25: ; preds = %21
%26 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32* %7, i32* %8, i32* %9)
%27 = load i32, i32* %8
%28 = sitofp i32 %27 to double
%29 = load i32, i32* %7
%30 = shl i32 %29, 1
%31 = sitofp i32 %30 to double
%32 = fdiv double %28, %31
store double %32, double* %10
%33 = load i32, i32* %7
%34 = sub nsw i32 0, %33
%35 = sitofp i32 %34 to double
%36 = load double, double* %10
%37 = fmul double %35, %36
%38 = load double, double* %10
%39 = load i32, i32* %8
%40 = sitofp i32 %39 to double
%41 = load double, double* %10
%42 = fmul double %40, %41
%43 = call double @llvm.fmuladd.f64(double %37, double %38, double %42)
%44 = load i32, i32* %9
%45 = sitofp i32 %44 to double
%46 = fadd double %43, %45
store double %46, double* %11
%47 = load double, double* %11
%48 = load double, double* %4
%49 = fcmp ogt double %47, %48
br i1 %49, label %50, label %53
50: ; preds = %25
%51 = load double, double* %11
store double %51, double* %4
%52 = load i32, i32* %6
store i32 %52, i32* %5
br label %53
53: ; preds = %50, %25
br label %54
54: ; preds = %53
%55 = load i32, i32* %6
%56 = add nsw i32 %55, 1
store i32 %56, i32* %6
br label %21
57: ; preds = %21
%58 = load i32, i32* %5
%59 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %58)
br label %13
60: ; preds = %13
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@INFINITY = global double 0.000000e+00
@.str.1 = [9 x i8] c"%d %d %d\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = bitcast i32* %1 to i8*
%7 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%8 = load i32, i32* %1
%9 = add nsw i32 %8, -1
store i32 %9, i32* %1
%10 = icmp eq i32 %8, 0
br i1 %10, label %54, label %11
11: ; preds = %0
%12 = bitcast i32* %2 to i8*
%13 = bitcast i32* %3 to i8*
%14 = bitcast i32* %4 to i8*
%15 = bitcast i32* %5 to i8*
br label %16
16: ; preds = %11, %23
%17 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%18 = load i32, i32* %2
%19 = icmp slt i32 %18, 1
br i1 %19, label %23, label %20
20: ; preds = %16
%21 = load double, double* @INFINITY
%22 = fneg double %21
br label %29
23: ; preds = %29, %16
%24 = phi i32 [ 0, %16 ], [ %49, %29 ]
%25 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %24)
%26 = load i32, i32* %1
%27 = add nsw i32 %26, -1
store i32 %27, i32* %1
%28 = icmp eq i32 %26, 0
br i1 %28, label %54, label %16
29: ; preds = %20, %29
%30 = phi double [ %50, %29 ], [ %22, %20 ]
%31 = phi i32 [ %49, %29 ], [ 0, %20 ]
%32 = phi i32 [ %51, %29 ], [ 1, %20 ]
%33 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32* %3, i32* %4, i32* %5)
%34 = load i32, i32* %4
%35 = sitofp i32 %34 to double
%36 = load i32, i32* %3
%37 = shl i32 %36, 1
%38 = sitofp i32 %37 to double
%39 = fdiv double %35, %38
%40 = sub nsw i32 0, %36
%41 = sitofp i32 %40 to double
%42 = fmul double %39, %41
%43 = fmul double %39, %35
%44 = call double @llvm.fmuladd.f64(double %42, double %39, double %43)
%45 = load i32, i32* %5
%46 = sitofp i32 %45 to double
%47 = fadd double %44, %46
%48 = fcmp ogt double %47, %30
%49 = select i1 %48, i32 %32, i32 %31
%50 = select i1 %48, double %47, double %30
%51 = add nuw nsw i32 %32, 1
%52 = load i32, i32* %2
%53 = icmp slt i32 %32, %52
br i1 %53, label %29, label %23
54: ; preds = %23, %0
ret i32 0
}