#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 abs(int);
int /*<<< orphan*/ printf(char *, int, int);
int /*<<< orphan*/ scanf(char *, int *, ...);
int main(void) {
  int n, p1_score, p2_score, p1_total = 0, p2_total = 0, lead, winner,
                             max_lead = 0;
  scanf("%d", &n);
  while (n--) {
    scanf("%d%d", &p1_score, &p2_score);
    p1_total += p1_score;
    p2_total += p2_score;
    lead = abs(p1_total - p2_total);
    if (max_lead < lead) {
      max_lead = lead;
      if (p1_total > p2_total) {
        winner = 1;
      } else {
        winner = 2;
      }
    }
  }
  printf("%d %d\n", winner, max_lead);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x24(%rbp)
lea    0xea7(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
cmp    $0x0,%eax
je     11eb <main+0xbb>
lea    0xe7f(%rip),%rdi
lea    -0xc(%rbp),%rsi
lea    -0x10(%rbp),%rdx
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0xc(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%edi
sub    -0x18(%rbp),%edi
call   1030 <abs@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11e6 <main+0xb6>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jle    11da <main+0xaa>
movl   $0x1,-0x20(%rbp)
jmp    11e1 <main+0xb1>
movl   $0x2,-0x20(%rbp)
jmp    11e6 <main+0xb6>
jmp    1166 <main+0x36>
mov    -0x20(%rbp),%esi
mov    -0x24(%rbp),%edx
lea    0xe0d(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xecd(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
addl   $0xffffffff,0xc(%rsp)
lea    0x14(%rsp),%r15
lea    0x10(%rsp),%r12
xor    %edx,%edx
xor    %ebx,%ebx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
mov    %edx,%r14d
lea    0xe96(%rip),%rdi
mov    %r15,%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1040 <scanf@plt>
add    0x14(%rsp),%ebx
add    0x10(%rsp),%ebp
xor    %eax,%eax
mov    %ebx,%ecx
sub    %ebp,%ecx
setg   %al
mov    %ecx,%edx
neg    %edx
cmovs  %ecx,%edx
mov    $0x2,%ecx
sub    %eax,%ecx
cmp    %edx,%r14d
cmovl  %ecx,%r13d
cmovge %r14d,%edx
subl   $0x1,0xc(%rsp)
jae    1160 <main+0x40>
lea    0xe56(%rip),%rdi
mov    %r13d,%esi
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 = [3 x i8] c"%d\00"
@.str.1 = [5 x i8] c"%d%d\00"
@.str.2 = [7 x i8] c"%d %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %5
store i32 0, i32* %6
store i32 0, i32* %9
%10 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
br label %11
11: ; preds = %38, %0
%12 = load i32, i32* %2
%13 = add nsw i32 %12, -1
store i32 %13, i32* %2
%14 = icmp ne i32 %12, 0
br i1 %14, label %15, label %39
15: ; preds = %11
%16 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %3, i32* %4)
%17 = load i32, i32* %3
%18 = load i32, i32* %5
%19 = add nsw i32 %18, %17
store i32 %19, i32* %5
%20 = load i32, i32* %4
%21 = load i32, i32* %6
%22 = add nsw i32 %21, %20
store i32 %22, i32* %6
%23 = load i32, i32* %5
%24 = load i32, i32* %6
%25 = sub nsw i32 %23, %24
%26 = call i32 @abs(i32 %25)
store i32 %26, i32* %7
%27 = load i32, i32* %9
%28 = load i32, i32* %7
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %38
30: ; preds = %15
%31 = load i32, i32* %7
store i32 %31, i32* %9
%32 = load i32, i32* %5
%33 = load i32, i32* %6
%34 = icmp sgt i32 %32, %33
br i1 %34, label %35, label %36
35: ; preds = %30
store i32 1, i32* %8
br label %37
36: ; preds = %30
store i32 2, i32* %8
br label %37
37: ; preds = %36, %35
br label %38
38: ; preds = %37, %15
br label %11
39: ; preds = %11
%40 = load i32, i32* %8
%41 = load i32, i32* %9
%42 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %40, i32 %41)
ret i32 0
}

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