#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 */
scalar_t__ EOF;
int Find(int, int *, int *);
int /*<<< orphan*/ printf(char *, int, ...);
scalar_t__ scanf(char *, int *);
int main() {
  int n, m, i, j, k, u, c, temp, ar[10010], r[10010], cas, max, maxi, *p, *q;
  while (scanf("%d", &n) != EOF) {
    cas = 0;
    for (m = 1; m <= n; m++) {
      cas++;
      scanf("%d", &c);
      for (i = 1; i <= c; i++) {
        scanf("%d", &ar[i]);
        r[i] = -99999;
      }
      max = -99999;
      r[1] = ar[1];
      p = r;
      q = ar;
      for (i = c; i >= 1; i--) {
        temp = Find(i, q, p);
        if (max < temp) {
          max = temp;
          maxi = i;
        }
      }
      printf("Case %d:\n", cas);
      printf("%d %d\n", max, maxi);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x13920,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb7(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
mov    0x2e8f(%rip),%rcx
cmp    (%rcx),%rax
je     12bc <main+0x18c>
movl   $0x0,-0x13904(%rbp)
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     12b7 <main+0x187>
mov    -0x13904(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x13904(%rbp)
lea    0xe6b(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   1050 <scanf@plt>
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x20(%rbp),%eax
jg     11ec <main+0xbc>
movslq -0x10(%rbp),%rax
lea    -0x9c90(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe36(%rip),%rdi
call   1050 <scanf@plt>
movslq -0x10(%rbp),%rax
movl   $0xfffe7961,-0x13900(%rbp,%rax,4)
61 79 fe ff
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11a5 <main+0x75>
movl   $0xfffe7961,-0x13908(%rbp)
79 fe ff
mov    -0x9c8c(%rbp),%eax
mov    %eax,-0x138fc(%rbp)
lea    -0x13900(%rbp),%rax
mov    %rax,-0x13918(%rbp)
lea    -0x9c90(%rbp),%rax
mov    %rax,-0x13920(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x1,-0x10(%rbp)
jl     127b <main+0x14b>
mov    -0x10(%rbp),%edi
mov    -0x13920(%rbp),%rsi
mov    -0x13918(%rbp),%rdx
call   1040 <Find@plt>
mov    %eax,-0x24(%rbp)
mov    -0x13908(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    1268 <main+0x138>
mov    -0x24(%rbp),%eax
mov    %eax,-0x13908(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x1390c(%rbp)
jmp    126d <main+0x13d>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    1224 <main+0xf4>
mov    -0x13904(%rbp),%esi
lea    0xd7b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x13908(%rbp),%esi
mov    -0x1390c(%rbp),%edx
lea    0xd6b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1173 <main+0x43>
jmp    1142 <main+0x12>
xor    %eax,%eax
add    $0x13920,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x138f8,%rsp
lea    0xeb8(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x2e8f(%rip),%rcx
cmp    (%rcx),%rax
jne    1172 <main+0x42>
xor    %eax,%eax
add    $0x138f8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe87(%rip),%r14
lea    0x9c90(%rsp),%rbx
jmp    11a9 <main+0x79>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x2e44(%rip),%rcx
cmp    (%rcx),%rax
je     115e <main+0x2e>
cmpl   $0x0,0xc(%rsp)
jle    1190 <main+0x60>
xor    %ebp,%ebp
mov    $0x1,%r12d
jmp    120a <main+0xda>
nopw   0x0(%rax,%rax,1)
mov    0x9c94(%rsp),%eax
mov    %eax,0x24(%rsp)
mov    $0xfffe7961,%r13d
lea    0xe2b(%rip),%rdi
mov    0x14(%rsp),%ebp
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe21(%rip),%rdi
mov    %r13d,%esi
mov    %r15d,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x18(%rsp),%rcx
lea    0x1(%rcx),%eax
cmp    0xc(%rsp),%ecx
mov    %eax,%r12d
jge    1190 <main+0x60>
add    $0x1,%ebp
mov    %r14,%rdi
lea    0x10(%rsp),%rsi
call   1050 <scanf@plt>
cmpl   $0x0,0x10(%rsp)
mov    %ebp,0x14(%rsp)
mov    %r12,0x18(%rsp)
jle    11c0 <main+0x90>
mov    %rbx,%r13
lea    0x9c94(%rsp),%rbp
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rbp,%rsi
call   1050 <scanf@plt>
movl   $0xfffe7961,0x24(%rsp,%rbx,4)
ff
movslq 0x10(%rsp),%r12
add    $0x1,%rbx
add    $0x4,%rbp
cmp    %r12,%rbx
jl     1240 <main+0x110>
mov    0x9c94(%rsp),%eax
mov    %eax,0x24(%rsp)
test   %r12d,%r12d
mov    %r13,%rbx
lea    0x20(%rsp),%rbp
mov    $0xfffe7961,%r13d
jle    11d1 <main+0xa1>
nopw   0x0(%rax,%rax,1)
mov    %r12d,%edi
mov    %rbx,%rsi
mov    %rbp,%rdx
call   1040 <Find@plt>
cmp    %eax,%r13d
cmovl  %eax,%r13d
cmovl  %r12d,%r15d
lea    -0x1(%r12),%eax
cmp    $0x1,%r12d
mov    %eax,%r12d
ja     1290 <main+0x160>
jmp    11d1 <main+0xa1>

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@EOF = global i64 0
@.str.1 = [10 x i8] c"Case %d:\0A\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 [10010 x i32]
%11 = alloca [10010 x i32]
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32*
%16 = alloca i32*
store i32 0, i32* %1
br label %17
17: ; preds = %79, %0
%18 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%19 = load i64, i64* @EOF
%20 = icmp ne i64 %18, %19
br i1 %20, label %21, label %80
21: ; preds = %17
store i32 0, i32* %12
store i32 1, i32* %3
br label %22
22: ; preds = %76, %21
%23 = load i32, i32* %3
%24 = load i32, i32* %2
%25 = icmp sle i32 %23, %24
br i1 %25, label %26, label %79
26: ; preds = %22
%27 = load i32, i32* %12
%28 = add nsw i32 %27, 1
store i32 %28, i32* %12
%29 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %8)
store i32 1, i32* %4
br label %30
30: ; preds = %42, %26
%31 = load i32, i32* %4
%32 = load i32, i32* %8
%33 = icmp sle i32 %31, %32
br i1 %33, label %34, label %45
34: ; preds = %30
%35 = load i32, i32* %4
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [10010 x i32], [10010 x i32]* %10, i64 0, i64 %36
%38 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %37)
%39 = load i32, i32* %4
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [10010 x i32], [10010 x i32]* %11, i64 0, i64 %40
store i32 -99999, i32* %41
br label %42
42: ; preds = %34
%43 = load i32, i32* %4
%44 = add nsw i32 %43, 1
store i32 %44, i32* %4
br label %30
45: ; preds = %30
store i32 -99999, i32* %13
%46 = getelementptr inbounds [10010 x i32], [10010 x i32]* %10, i64 0, i64 1
%47 = load i32, i32* %46
%48 = getelementptr inbounds [10010 x i32], [10010 x i32]* %11, i64 0, i64 1
store i32 %47, i32* %48
%49 = getelementptr inbounds [10010 x i32], [10010 x i32]* %11, i64 0, i64 0
store i32* %49, i32** %15
%50 = getelementptr inbounds [10010 x i32], [10010 x i32]* %10, i64 0, i64 0
store i32* %50, i32** %16
%51 = load i32, i32* %8
store i32 %51, i32* %4
br label %52
52: ; preds = %67, %45
%53 = load i32, i32* %4
%54 = icmp sge i32 %53, 1
br i1 %54, label %55, label %70
55: ; preds = %52
%56 = load i32, i32* %4
%57 = load i32*, i32** %16
%58 = load i32*, i32** %15
%59 = call i32 @Find(i32 %56, i32* %57, i32* %58)
store i32 %59, i32* %9
%60 = load i32, i32* %13
%61 = load i32, i32* %9
%62 = icmp slt i32 %60, %61
br i1 %62, label %63, label %66
63: ; preds = %55
%64 = load i32, i32* %9
store i32 %64, i32* %13
%65 = load i32, i32* %4
store i32 %65, i32* %14
br label %66
66: ; preds = %63, %55
br label %67
67: ; preds = %66
%68 = load i32, i32* %4
%69 = add nsw i32 %68, -1
store i32 %69, i32* %4
br label %52
70: ; preds = %52
%71 = load i32, i32* %12
%72 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %71)
%73 = load i32, i32* %13
%74 = load i32, i32* %14
%75 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %73, i32 %74)
br label %76
76: ; preds = %70
%77 = load i32, i32* %3
%78 = add nsw i32 %77, 1
store i32 %78, i32* %3
br label %22
79: ; preds = %22
br label %17
80: ; preds = %17
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@EOF = global i64 0
@.str.1 = [10 x i8] c"Case %d:\0A\00"
@.str.2 = [7 x i8] c"%d %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [10010 x i32]
%4 = alloca [10010 x i32]
%5 = bitcast i32* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = bitcast [10010 x i32]* %3 to i8*
%8 = bitcast [10010 x i32]* %4 to i8*
%9 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%10 = load i64, i64* @EOF
%11 = icmp eq i64 %9, %10
br i1 %11, label %66, label %12
12: ; preds = %0
%13 = getelementptr inbounds [10010 x i32], [10010 x i32]* %3, i64 0, i64 1
%14 = getelementptr inbounds [10010 x i32], [10010 x i32]* %4, i64 0, i64 1
%15 = getelementptr inbounds [10010 x i32], [10010 x i32]* %4, i64 0, i64 0
%16 = getelementptr inbounds [10010 x i32], [10010 x i32]* %3, i64 0, i64 0
br label %22
17: ; preds = %58, %22
%18 = phi i32 [ %23, %22 ], [ %60, %58 ]
%19 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%20 = load i64, i64* @EOF
%21 = icmp eq i64 %19, %20
br i1 %21, label %66, label %22
22: ; preds = %12, %17
%23 = phi i32 [ undef, %12 ], [ %18, %17 ]
%24 = load i32, i32* %1
%25 = icmp slt i32 %24, 1
br i1 %25, label %17, label %26
26: ; preds = %22, %58
%27 = phi i32 [ %63, %58 ], [ 1, %22 ]
%28 = phi i32 [ %60, %58 ], [ %23, %22 ]
%29 = phi i32 [ %30, %58 ], [ 0, %22 ]
%30 = add nuw nsw i32 %29, 1
%31 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%32 = load i32, i32* %2
%33 = icmp slt i32 %32, 1
br i1 %33, label %34, label %36
34: ; preds = %26
%35 = load i32, i32* %13
store i32 %35, i32* %14
br label %58
36: ; preds = %26, %36
%37 = phi i64 [ %41, %36 ], [ 1, %26 ]
%38 = getelementptr inbounds [10010 x i32], [10010 x i32]* %3, i64 0, i64 %37
%39 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %38)
%40 = getelementptr inbounds [10010 x i32], [10010 x i32]* %4, i64 0, i64 %37
store i32 -99999, i32* %40
%41 = add nuw nsw i64 %37, 1
%42 = load i32, i32* %2
%43 = sext i32 %42 to i64
%44 = icmp slt i64 %37, %43
br i1 %44, label %36, label %45
45: ; preds = %36
%46 = load i32, i32* %13
store i32 %46, i32* %14
%47 = icmp sgt i32 %42, 0
br i1 %47, label %48, label %58
48: ; preds = %45, %48
%49 = phi i32 [ %56, %48 ], [ %42, %45 ]
%50 = phi i32 [ %55, %48 ], [ %28, %45 ]
%51 = phi i32 [ %54, %48 ], [ -99999, %45 ]
%52 = call i32 @Find(i32 %49, i32* %16, i32* %15)
%53 = icmp slt i32 %51, %52
%54 = select i1 %53, i32 %52, i32 %51
%55 = select i1 %53, i32 %49, i32 %50
%56 = add nsw i32 %49, -1
%57 = icmp ugt i32 %49, 1
br i1 %57, label %48, label %58
58: ; preds = %48, %34, %45
%59 = phi i32 [ -99999, %45 ], [ -99999, %34 ], [ %54, %48 ]
%60 = phi i32 [ %28, %45 ], [ %28, %34 ], [ %55, %48 ]
%61 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %30)
%62 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %59, i32 %60)
%63 = add nuw nsw i32 %27, 1
%64 = load i32, i32* %1
%65 = icmp slt i32 %27, %64
br i1 %65, label %26, label %17
66: ; preds = %17, %0
ret i32 0
}