#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 *, int, int);
int /*<<< orphan*/ scanf(char *, int *, ...);
int main() {
  int i, n, sum_a, sum_b, a, b, lead, max_lead = 0, winner;
  scanf("%d", &n);
  sum_a = 0;
  sum_b = 0;
  for (i = 0; i < n; i++) {
    scanf("%d %d", &a, &b);
    sum_a += a;
    sum_b += b;
    lead = sum_a - sum_b;
    if (lead > 0) {
      if (lead > max_lead) {
        max_lead = lead;
        winner = 1;
      }
    } else {
      if (-lead > max_lead) {
        max_lead = -lead;
        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,-0x24(%rbp)
lea    0xec6(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11f7 <main+0xd7>
lea    0xe90(%rip),%rdi
lea    -0x18(%rbp),%rsi
lea    -0x1c(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x18(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x1c(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
sub    -0x14(%rbp),%eax
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jle    11c2 <main+0xa2>
mov    -0x20(%rbp),%eax
cmp    -0x24(%rbp),%eax
jle    11bd <main+0x9d>
mov    -0x20(%rbp),%eax
mov    %eax,-0x24(%rbp)
movl   $0x1,-0x28(%rbp)
jmp    11e4 <main+0xc4>
xor    %eax,%eax
sub    -0x20(%rbp),%eax
cmp    -0x24(%rbp),%eax
jle    11df <main+0xbf>
xor    %eax,%eax
sub    -0x20(%rbp),%eax
mov    %eax,-0x24(%rbp)
movl   $0x2,-0x28(%rbp)
jmp    11e4 <main+0xc4>
jmp    11e9 <main+0xc9>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    115d <main+0x3d>
mov    -0x28(%rbp),%esi
mov    -0x24(%rbp),%edx
lea    0xe02(%rip),%rdi
call   1030 <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    0xece(%rip),%rdi
lea    0x14(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0xc(%rsp),%r12
xor    %ebx,%ebx
xor    %r13d,%r13d
xor    %r14d,%r14d
xor    %r15d,%r15d
jmp    117a <main+0x5a>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
neg    %eax
cmp    %eax,%ebx
cmovl  %eax,%ebx
mov    $0x2,%eax
cmovl  %eax,%ebp
add    $0x1,%r13d
cmp    0x14(%rsp),%r13d
jge    11b1 <main+0x91>
lea    0xe7f(%rip),%rdi
lea    0x10(%rsp),%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1040 <scanf@plt>
add    0x10(%rsp),%r15d
add    0xc(%rsp),%r14d
mov    %r15d,%eax
sub    %r14d,%eax
jle    1160 <main+0x40>
cmp    %ebx,%eax
cmovg  %eax,%ebx
mov    $0x1,%eax
cmovg  %eax,%ebp
jmp    116f <main+0x4f>
lea    0xe4e(%rip),%rdi
mov    %ebp,%esi
mov    %ebx,%edx
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 = [6 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
%10 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %9
%11 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
store i32 0, i32* %4
store i32 0, i32* %5
store i32 0, i32* %2
br label %12
12: ; preds = %46, %0
%13 = load i32, i32* %2
%14 = load i32, i32* %3
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %49
16: ; preds = %12
%17 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %6, i32* %7)
%18 = load i32, i32* %6
%19 = load i32, i32* %4
%20 = add nsw i32 %19, %18
store i32 %20, i32* %4
%21 = load i32, i32* %7
%22 = load i32, i32* %5
%23 = add nsw i32 %22, %21
store i32 %23, i32* %5
%24 = load i32, i32* %4
%25 = load i32, i32* %5
%26 = sub nsw i32 %24, %25
store i32 %26, i32* %8
%27 = load i32, i32* %8
%28 = icmp sgt i32 %27, 0
br i1 %28, label %29, label %36
29: ; preds = %16
%30 = load i32, i32* %8
%31 = load i32, i32* %9
%32 = icmp sgt i32 %30, %31
br i1 %32, label %33, label %35
33: ; preds = %29
%34 = load i32, i32* %8
store i32 %34, i32* %9
store i32 1, i32* %10
br label %35
35: ; preds = %33, %29
br label %45
36: ; preds = %16
%37 = load i32, i32* %8
%38 = sub nsw i32 0, %37
%39 = load i32, i32* %9
%40 = icmp sgt i32 %38, %39
br i1 %40, label %41, label %44
41: ; preds = %36
%42 = load i32, i32* %8
%43 = sub nsw i32 0, %42
store i32 %43, i32* %9
store i32 2, i32* %10
br label %44
44: ; preds = %41, %36
br label %45
45: ; preds = %44, %35
br label %46
46: ; preds = %45
%47 = load i32, i32* %2
%48 = add nsw i32 %47, 1
store i32 %48, i32* %2
br label %12
49: ; preds = %12
%50 = load i32, i32* %10
%51 = load i32, i32* %9
%52 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %50, i32 %51)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [6 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 = icmp sgt i32 %8, 0
br label %10
10: ; preds = %0, %32
%11 = phi i32 [ %34, %32 ], [ undef, %0 ]
%12 = phi i32 [ %33, %32 ], [ 0, %0 ]
%13 = phi i32 [ %35, %32 ], [ 0, %0 ]
%14 = phi i32 [ %20, %32 ], [ 0, %0 ]
%15 = phi i32 [ %18, %32 ], [ 0, %0 ]
%16 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %3)
%17 = load i32, i32* %2
%18 = add nsw i32 %17, %15
%19 = load i32, i32* %3
%20 = add nsw i32 %19, %14
%21 = sub nsw i32 %18, %20
%22 = icmp sgt i32 %21, 0
br i1 %22, label %23, label %27
23: ; preds = %10
%24 = icmp sgt i32 %21, %12
%25 = select i1 %24, i32 %21, i32 %12
%26 = select i1 %24, i32 1, i32 %11
br label %32
27: ; preds = %10
%28 = sub nsw i32 0, %21
%29 = icmp slt i32 %12, %28
%30 = select i1 %29, i32 %28, i32 %12
%31 = select i1 %29, i32 2, i32 %11
br label %32
32: ; preds = %27, %23
%33 = phi i32 [ %25, %23 ], [ %30, %27 ]
%34 = phi i32 [ %26, %23 ], [ %31, %27 ]
%35 = add nuw nsw i32 %13, 1
%36 = load i32, i32* %1
%37 = icmp slt i32 %35, %36
br i1 %37, label %10, label %38
38: ; preds = %32
%39 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %34, i32 %33)
ret i32 0
}