#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 */
int /*<<< orphan*/ printf(char *, long, long);
int /*<<< orphan*/ scanf(char *, long *, ...);
int main() {
  long rounds = 0, winner = 0, maxLead = 0, i = 0, total1 = 0, total2 = 0,
       data1 = 0, data2 = 0;
  scanf("%ld", &rounds);
  for (i = 0; i < rounds; i++) {
    scanf("%ld %ld", &data1, &data2);
    total1 += data1;
    total2 += data2;
    if (total1 - total2 > maxLead) {
      winner = 1;
      maxLead = total1 - total2;
    } else if (total2 - total1 > maxLead) {
      winner = 2;
      maxLead = total2 - total1;
    }
  }
  printf("%ld %ld\n", winner, maxLead);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
movq   $0x0,-0x48(%rbp)
lea    0xe8e(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x10(%rbp),%rax
jge    1231 <main+0x111>
lea    0xe62(%rip),%rdi
lea    -0x40(%rbp),%rsi
lea    -0x48(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x40(%rbp),%rax
add    -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x48(%rbp),%rax
add    -0x38(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rax
sub    -0x38(%rbp),%rax
cmp    -0x20(%rbp),%rax
jle    11f0 <main+0xd0>
movq   $0x1,-0x18(%rbp)
mov    -0x30(%rbp),%rax
sub    -0x38(%rbp),%rax
mov    %rax,-0x20(%rbp)
jmp    121b <main+0xfb>
mov    -0x38(%rbp),%rax
sub    -0x30(%rbp),%rax
cmp    -0x20(%rbp),%rax
jle    1216 <main+0xf6>
movq   $0x2,-0x18(%rbp)
mov    -0x38(%rbp),%rax
sub    -0x30(%rbp),%rax
mov    %rax,-0x20(%rbp)
jmp    121b <main+0xfb>
jmp    1220 <main+0x100>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1189 <main+0x69>
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
lea    0xdc8(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movq   $0x0,(%rsp)
movq   $0x0,0x10(%rsp)
movq   $0x0,0x8(%rsp)
lea    0xeb5(%rip),%rdi
xor    %ebx,%ebx
mov    %rsp,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
cmpq   $0x0,(%rsp)
jle    11d8 <main+0xb8>
mov    $0x1,%ebp
xor    %r14d,%r14d
xor    %r15d,%r15d
xor    %r12d,%r12d
xor    %r13d,%r13d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
lea    0xe79(%rip),%rdi
lea    0x10(%rsp),%rsi
lea    0x8(%rsp),%rdx
xor    %eax,%eax
call   1040 <scanf@plt>
add    0x10(%rsp),%r15
add    0x8(%rsp),%r14
mov    %r15,%rax
sub    %r14,%rax
mov    %r14,%rdx
sub    %r15,%rdx
cmp    %r13,%rdx
mov    $0x2,%ecx
cmovg  %rcx,%rbx
cmovle %r13,%rdx
cmp    %r13,%rax
cmovg  %rbp,%rbx
cmovg  %rax,%rdx
add    $0x1,%r12
mov    %rdx,%r13
cmp    (%rsp),%r12
jl     1180 <main+0x60>
jmp    11da <main+0xba>
xor    %edx,%edx
lea    0xe27(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%ld\00"
@.str.1 = [8 x i8] c"%ld %ld\00"
@.str.2 = [9 x i8] c"%ld %ld\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
store i32 0, i32* %1
store i64 0, i64* %2
store i64 0, i64* %3
store i64 0, i64* %4
store i64 0, i64* %5
store i64 0, i64* %6
store i64 0, i64* %7
store i64 0, i64* %8
store i64 0, i64* %9
%10 = call i32 (i8*, i64*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %2)
store i64 0, i64* %5
br label %11
11: ; preds = %44, %0
%12 = load i64, i64* %5
%13 = load i64, i64* %2
%14 = icmp slt i64 %12, %13
br i1 %14, label %15, label %47
15: ; preds = %11
%16 = call i32 (i8*, i64*, ...) @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i64* %8, i64* %9)
%17 = load i64, i64* %8
%18 = load i64, i64* %6
%19 = add nsw i64 %18, %17
store i64 %19, i64* %6
%20 = load i64, i64* %9
%21 = load i64, i64* %7
%22 = add nsw i64 %21, %20
store i64 %22, i64* %7
%23 = load i64, i64* %6
%24 = load i64, i64* %7
%25 = sub nsw i64 %23, %24
%26 = load i64, i64* %4
%27 = icmp sgt i64 %25, %26
br i1 %27, label %28, label %32
28: ; preds = %15
store i64 1, i64* %3
%29 = load i64, i64* %6
%30 = load i64, i64* %7
%31 = sub nsw i64 %29, %30
store i64 %31, i64* %4
br label %43
32: ; preds = %15
%33 = load i64, i64* %7
%34 = load i64, i64* %6
%35 = sub nsw i64 %33, %34
%36 = load i64, i64* %4
%37 = icmp sgt i64 %35, %36
br i1 %37, label %38, label %42
38: ; preds = %32
store i64 2, i64* %3
%39 = load i64, i64* %7
%40 = load i64, i64* %6
%41 = sub nsw i64 %39, %40
store i64 %41, i64* %4
br label %42
42: ; preds = %38, %32
br label %43
43: ; preds = %42, %28
br label %44
44: ; preds = %43
%45 = load i64, i64* %5
%46 = add nsw i64 %45, 1
store i64 %46, i64* %5
br label %11
47: ; preds = %11
%48 = load i64, i64* %3
%49 = load i64, i64* %4
%50 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i64 %48, i64 %49)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%ld\00"
@.str.1 = [8 x i8] c"%ld %ld\00"
@.str.2 = [9 x i8] c"%ld %ld\0A\00"
define i32 @main() {
%1 = alloca i64
%2 = alloca i64
%3 = alloca i64
%4 = bitcast i64* %1 to i8*
store i64 0, i64* %1
%5 = bitcast i64* %2 to i8*
store i64 0, i64* %2
%6 = bitcast i64* %3 to i8*
store i64 0, i64* %3
%7 = call i32 (i8*, i64*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %1)
%8 = load i64, i64* %1
%9 = icmp sgt i64 %8, 0
br i1 %9, label %10, label %32
10: ; preds = %0, %10
%11 = phi i64 [ %20, %10 ], [ 0, %0 ]
%12 = phi i64 [ %18, %10 ], [ 0, %0 ]
%13 = phi i64 [ %29, %10 ], [ 0, %0 ]
%14 = phi i64 [ %28, %10 ], [ 0, %0 ]
%15 = phi i64 [ %27, %10 ], [ 0, %0 ]
%16 = call i32 (i8*, i64*, ...) @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i64* %2, i64* %3)
%17 = load i64, i64* %2
%18 = add nsw i64 %17, %12
%19 = load i64, i64* %3
%20 = add nsw i64 %19, %11
%21 = sub nsw i64 %18, %20
%22 = icmp sgt i64 %21, %14
%23 = sub nsw i64 %20, %18
%24 = icmp sgt i64 %23, %14
%25 = select i1 %24, i64 2, i64 %15
%26 = select i1 %24, i64 %23, i64 %14
%27 = select i1 %22, i64 1, i64 %25
%28 = select i1 %22, i64 %21, i64 %26
%29 = add nuw nsw i64 %13, 1
%30 = load i64, i64* %1
%31 = icmp slt i64 %29, %30
br i1 %31, label %10, label %32
32: ; preds = %10, %0
%33 = phi i64 [ 0, %0 ], [ %27, %10 ]
%34 = phi i64 [ 0, %0 ], [ %28, %10 ]
%35 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i64 %33, i64 %34)
ret i32 0
}