#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() {
  int n, w, l, s, t, a, b;
  l = s = t = 0;
  scanf("%d", &n);
  while (n--) {
    scanf("%d%d", &a, &b);
    s += a;
    t += b;
    if (abs(s - t) > l) {
      l = abs(s - t);
      if (s > t)
        w = 1;
      else
        w = 2;
    }
  }
  printf("%d %d", w, l);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xead(%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     11ed <main+0xbd>
lea    0xe7f(%rip),%rdi
lea    -0x1c(%rbp),%rsi
lea    -0x20(%rbp),%rdx
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0x1c(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x20(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%edi
sub    -0x18(%rbp),%edi
call   1030 <abs@plt>
cmp    -0x10(%rbp),%eax
jle    11e8 <main+0xb8>
mov    -0x14(%rbp),%edi
sub    -0x18(%rbp),%edi
call   1030 <abs@plt>
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jle    11dc <main+0xac>
movl   $0x1,-0xc(%rbp)
jmp    11e3 <main+0xb3>
movl   $0x2,-0xc(%rbp)
jmp    11e8 <main+0xb8>
jmp    1166 <main+0x36>
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xe0b(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%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    0xed3(%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    %ebx,%ebx
xor    %ebp,%ebp
xor    %edx,%edx
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),%ebp
add    0x10(%rsp),%ebx
xor    %eax,%eax
mov    %ebp,%ecx
sub    %ebx,%ecx
setg   %al
mov    %ecx,%edx
neg    %edx
cmovs  %ecx,%edx
mov    $0x2,%ecx
sub    %eax,%ecx
cmp    %r14d,%edx
cmovg  %ecx,%r13d
cmovle %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 = [6 x i8] c"%d %d\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
store i32 0, i32* %1
store i32 0, i32* %6
store i32 0, i32* %5
store i32 0, i32* %4
%9 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
br label %10
10: ; preds = %39, %0
%11 = load i32, i32* %2
%12 = add nsw i32 %11, -1
store i32 %12, i32* %2
%13 = icmp ne i32 %11, 0
br i1 %13, label %14, label %40
14: ; preds = %10
%15 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %7, i32* %8)
%16 = load i32, i32* %7
%17 = load i32, i32* %5
%18 = add nsw i32 %17, %16
store i32 %18, i32* %5
%19 = load i32, i32* %8
%20 = load i32, i32* %6
%21 = add nsw i32 %20, %19
store i32 %21, i32* %6
%22 = load i32, i32* %5
%23 = load i32, i32* %6
%24 = sub nsw i32 %22, %23
%25 = call i32 @abs(i32 %24)
%26 = load i32, i32* %4
%27 = icmp sgt i32 %25, %26
br i1 %27, label %28, label %39
28: ; preds = %14
%29 = load i32, i32* %5
%30 = load i32, i32* %6
%31 = sub nsw i32 %29, %30
%32 = call i32 @abs(i32 %31)
store i32 %32, i32* %4
%33 = load i32, i32* %5
%34 = load i32, i32* %6
%35 = icmp sgt i32 %33, %34
br i1 %35, label %36, label %37
36: ; preds = %28
store i32 1, i32* %3
br label %38
37: ; preds = %28
store i32 2, i32* %3
br label %38
38: ; preds = %37, %36
br label %39
39: ; preds = %38, %14
br label %10
40: ; preds = %10
%41 = load i32, i32* %3
%42 = load i32, i32* %4
%43 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %41, i32 %42)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [5 x i8] c"%d%d\00"
@.str.2 = [6 x i8] c"%d %d\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 [ %20, %11 ], [ 0, %0 ]
%13 = phi i32 [ %18, %11 ], [ 0, %0 ]
%14 = phi i32 [ %27, %11 ], [ 0, %0 ]
%15 = phi i32 [ %26, %11 ], [ undef, %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, %13
%19 = load i32, i32* %3
%20 = add nsw i32 %19, %12
%21 = sub nsw i32 %18, %20
%22 = call i32 @llvm.abs.i32(i32 %21, i1 true)
%23 = icmp sgt i32 %22, %14
%24 = icmp sgt i32 %18, %20
%25 = select i1 %24, i32 1, i32 2
%26 = select i1 %23, i32 %25, i32 %15
%27 = select i1 %23, i32 %22, i32 %14
%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 ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %26, i32 %27)
ret i32 0
}