#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 cases;
  scanf("%d", &cases);
  int i, x, y, max, diff, winner;
  int tot_x, tot_y;
  tot_x = tot_y = 0;
  winner = 1;
  max = -1;
  for (i = 0; i < cases; i++) {
    scanf("%d %d", &x, &y);
    tot_x += x;
    tot_y += y;
    diff = tot_x - tot_y;
    if (diff > 0) {
      if (diff > max) {
        max = diff;
        winner = 1;
      }
    } else {
      diff = -diff;
      if (diff > max) {
        max = diff;
        winner = 2;
      }
    }
  }
  printf("%d %d\n", winner, max);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xecd(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x1,-0x20(%rbp)
movl   $0xffffffff,-0x18(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1202 <main+0xe2>
lea    0xe89(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x14(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x10(%rbp),%eax
add    -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x14(%rbp),%eax
add    -0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x24(%rbp),%eax
sub    -0x28(%rbp),%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jle    11c9 <main+0xa9>
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jle    11c4 <main+0xa4>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x18(%rbp)
movl   $0x1,-0x20(%rbp)
jmp    11ef <main+0xcf>
xor    %eax,%eax
sub    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jle    11ea <main+0xca>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x18(%rbp)
movl   $0x2,-0x20(%rbp)
jmp    11ef <main+0xcf>
jmp    11f4 <main+0xd4>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1164 <main+0x44>
mov    -0x20(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xdf7(%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    0xc(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
cmpl   $0x0,0xc(%rsp)
jle    11c1 <main+0xa1>
mov    $0xffffffff,%ebx
lea    0x10(%rsp),%r12
xor    %r13d,%r13d
xor    %r14d,%r14d
mov    $0x1,%ebp
xor    %r15d,%r15d
jmp    118a <main+0x6a>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
neg    %eax
cmp    %eax,%ebx
cmovl  %eax,%ebx
mov    $0x2,%eax
cmovl  %eax,%ebp
add    $0x1,%r15d
cmp    0xc(%rsp),%r15d
jge    11cb <main+0xab>
lea    0xe6f(%rip),%rdi
lea    0x14(%rsp),%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1040 <scanf@plt>
add    0x14(%rsp),%r14d
add    0x10(%rsp),%r13d
mov    %r14d,%eax
sub    %r13d,%eax
jle    1170 <main+0x50>
cmp    %ebx,%eax
cmovg  %eax,%ebx
mov    $0x1,%eax
cmovg  %eax,%ebp
jmp    117f <main+0x5f>
mov    $0x1,%ebp
mov    $0xffffffff,%ebx
lea    0xe34(%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
%11 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
store i32 0, i32* %10
store i32 0, i32* %9
store i32 1, i32* %8
store i32 -1, i32* %6
store i32 0, i32* %3
br label %12
12: ; preds = %46, %0
%13 = load i32, i32* %3
%14 = load i32, i32* %2
%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* %4, i32* %5)
%18 = load i32, i32* %4
%19 = load i32, i32* %9
%20 = add nsw i32 %19, %18
store i32 %20, i32* %9
%21 = load i32, i32* %5
%22 = load i32, i32* %10
%23 = add nsw i32 %22, %21
store i32 %23, i32* %10
%24 = load i32, i32* %9
%25 = load i32, i32* %10
%26 = sub nsw i32 %24, %25
store i32 %26, i32* %7
%27 = load i32, i32* %7
%28 = icmp sgt i32 %27, 0
br i1 %28, label %29, label %36
29: ; preds = %16
%30 = load i32, i32* %7
%31 = load i32, i32* %6
%32 = icmp sgt i32 %30, %31
br i1 %32, label %33, label %35
33: ; preds = %29
%34 = load i32, i32* %7
store i32 %34, i32* %6
store i32 1, i32* %8
br label %35
35: ; preds = %33, %29
br label %45
36: ; preds = %16
%37 = load i32, i32* %7
%38 = sub nsw i32 0, %37
store i32 %38, i32* %7
%39 = load i32, i32* %7
%40 = load i32, i32* %6
%41 = icmp sgt i32 %39, %40
br i1 %41, label %42, label %44
42: ; preds = %36
%43 = load i32, i32* %7
store i32 %43, i32* %6
store i32 2, i32* %8
br label %44
44: ; preds = %42, %36
br label %45
45: ; preds = %44, %35
br label %46
46: ; preds = %45
%47 = load i32, i32* %3
%48 = add nsw i32 %47, 1
store i32 %48, i32* %3
br label %12
49: ; preds = %12
%50 = load i32, i32* %8
%51 = load i32, i32* %6
%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 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%6 = bitcast i32* %2 to i8*
%7 = bitcast i32* %3 to i8*
%8 = load i32, i32* %1
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %38
10: ; preds = %0, %32
%11 = phi i32 [ %20, %32 ], [ 0, %0 ]
%12 = phi i32 [ %18, %32 ], [ 0, %0 ]
%13 = phi i32 [ %34, %32 ], [ 1, %0 ]
%14 = phi i32 [ %33, %32 ], [ -1, %0 ]
%15 = phi i32 [ %35, %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, %12
%19 = load i32, i32* %3
%20 = add nsw i32 %19, %11
%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, %14
%25 = select i1 %24, i32 %21, i32 %14
%26 = select i1 %24, i32 1, i32 %13
br label %32
27: ; preds = %10
%28 = sub nsw i32 0, %21
%29 = icmp slt i32 %14, %28
%30 = select i1 %29, i32 %28, i32 %14
%31 = select i1 %29, i32 2, i32 %13
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 %15, 1
%36 = load i32, i32* %1
%37 = icmp slt i32 %35, %36
br i1 %37, label %10, label %38
38: ; preds = %32, %0
%39 = phi i32 [ -1, %0 ], [ %33, %32 ]
%40 = phi i32 [ 1, %0 ], [ %34, %32 ]
%41 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %40, i32 %39)
ret i32 0
}