#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 argc, char const *argv[]) {
  int iterations = 0;
  scanf("%d", &iterations);
  int max = 0;
  int num = 0;
  int size = 0;
  for (int i = 0; i < iterations; ++i) {
    max = 0;
    scanf("%d", &size);
    int count[10001] = {0};
    for (int j = 0; j < size; ++j) {
      scanf("%d", &num);
      count[num] += 1;
      if (count[num] > max) {
        max = count[num];
      }
    }
    for (int k = 0; k < 10001; ++k) {
      if (count[k] == max) {
        printf("%d %d\n", k, max);
        break;
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x9c80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xea9(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1050 <scanf@plt>
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    12a2 <main+0x172>
movl   $0x0,-0x18(%rbp)
lea    0xe6a(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   1050 <scanf@plt>
lea    -0x9c70(%rbp),%rdi
xor    %esi,%esi
mov    $0x9c44,%edx
call   1040 <memset@plt>
movl   $0x0,-0x9c74(%rbp)
mov    -0x9c74(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    122b <main+0xfb>
lea    0xe2e(%rip),%rdi
lea    -0x1c(%rbp),%rsi
call   1050 <scanf@plt>
movslq -0x1c(%rbp),%rax
mov    -0x9c70(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x9c70(%rbp,%rax,4)
movslq -0x1c(%rbp),%rax
mov    -0x9c70(%rbp,%rax,4),%eax
cmp    -0x18(%rbp),%eax
jle    1212 <main+0xe2>
movslq -0x1c(%rbp),%rax
mov    -0x9c70(%rbp,%rax,4),%eax
mov    %eax,-0x18(%rbp)
jmp    1217 <main+0xe7>
mov    -0x9c74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x9c74(%rbp)
jmp    11bc <main+0x8c>
movl   $0x0,-0x9c78(%rbp)
cmpl   $0x2711,-0x9c78(%rbp)
jge    128f <main+0x15f>
movslq -0x9c78(%rbp),%rax
mov    -0x9c70(%rbp,%rax,4),%eax
cmp    -0x18(%rbp),%eax
jne    1276 <main+0x146>
mov    -0x9c78(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xd97(%rip),%rdi
call   1030 <printf@plt>
jmp    128f <main+0x15f>
jmp    127b <main+0x14b>
mov    -0x9c78(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x9c78(%rbp)
jmp    1235 <main+0x105>
jmp    1294 <main+0x164>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    117c <main+0x4c>
xor    %eax,%eax
add    $0x9c80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x9c58,%rsp
movl   $0x0,0x8(%rsp)
lea    0xeb0(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1050 <scanf@plt>
movl   $0x0,0xc(%rsp)
movl   $0x0,0x4(%rsp)
cmpl   $0x0,0x8(%rsp)
jle    1272 <main+0x142>
xor    %ebp,%ebp
lea    0xe82(%rip),%rbx
lea    0x10(%rsp),%r15
lea    0xc(%rsp),%r12
jmp    11ad <main+0x7d>
nopw   0x0(%rax,%rax,1)
add    $0xfffffffffffffffd,%rsi
lea    0xe68(%rip),%rdi
call   1030 <printf@plt>
add    $0x1,%ebp
cmp    0x8(%rsp),%ebp
jge    1272 <main+0x142>
mov    %rbx,%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    $0x9c44,%edx
mov    %r15,%rdi
xor    %esi,%esi
call   1040 <memset@plt>
cmpl   $0x0,0x4(%rsp)
mov    $0x0,%edx
jle    1210 <main+0xe0>
xor    %r13d,%r13d
xor    %r14d,%r14d
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
movslq 0xc(%rsp),%rax
mov    0x10(%rsp,%rax,4),%edx
add    $0x1,%edx
mov    %edx,0x10(%rsp,%rax,4)
cmp    %r14d,%edx
cmovle %r14d,%edx
add    $0x1,%r13d
mov    %edx,%r14d
cmp    0x4(%rsp),%r13d
jl     11e0 <main+0xb0>
mov    $0x3,%esi
cmp    %edx,0x4(%rsp,%rsi,4)
je     1190 <main+0x60>
nop
cmp    $0x2713,%rsi
je     11a0 <main+0x70>
cmp    %edx,0x8(%rsp,%rsi,4)
je     1260 <main+0x130>
cmp    %edx,0xc(%rsp,%rsi,4)
je     1269 <main+0x139>
cmp    %edx,0x10(%rsp,%rsi,4)
je     1194 <main+0x64>
add    $0x4,%rsi
cmp    %edx,0x4(%rsp,%rsi,4)
jne    1220 <main+0xf0>
jmp    1190 <main+0x60>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0xfffffffffffffffe,%rsi
jmp    1194 <main+0x64>
add    $0xffffffffffffffff,%rsi
jmp    1194 <main+0x64>
xor    %eax,%eax
add    $0x9c58,%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 = [7 x i8] c"%d %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca [10001 x i32]
%12 = alloca i32
%13 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %6)
store i32 0, i32* %7
store i32 0, i32* %8
store i32 0, i32* %9
store i32 0, i32* %10
br label %15
15: ; preds = %68, %2
%16 = load i32, i32* %10
%17 = load i32, i32* %6
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %71
19: ; preds = %15
store i32 0, i32* %7
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %9)
%21 = bitcast [10001 x i32]* %11 to i8*
store i32 0, i32* %12
br label %22
22: ; preds = %45, %19
%23 = load i32, i32* %12
%24 = load i32, i32* %9
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %48
26: ; preds = %22
%27 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %8)
%28 = load i32, i32* %8
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [10001 x i32], [10001 x i32]* %11, i64 0, i64 %29
%31 = load i32, i32* %30
%32 = add nsw i32 %31, 1
store i32 %32, i32* %30
%33 = load i32, i32* %8
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [10001 x i32], [10001 x i32]* %11, i64 0, i64 %34
%36 = load i32, i32* %35
%37 = load i32, i32* %7
%38 = icmp sgt i32 %36, %37
br i1 %38, label %39, label %44
39: ; preds = %26
%40 = load i32, i32* %8
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [10001 x i32], [10001 x i32]* %11, i64 0, i64 %41
%43 = load i32, i32* %42
store i32 %43, i32* %7
br label %44
44: ; preds = %39, %26
br label %45
45: ; preds = %44
%46 = load i32, i32* %12
%47 = add nsw i32 %46, 1
store i32 %47, i32* %12
br label %22
48: ; preds = %22
store i32 0, i32* %13
br label %49
49: ; preds = %64, %48
%50 = load i32, i32* %13
%51 = icmp slt i32 %50, 10001
br i1 %51, label %52, label %67
52: ; preds = %49
%53 = load i32, i32* %13
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds [10001 x i32], [10001 x i32]* %11, i64 0, i64 %54
%56 = load i32, i32* %55
%57 = load i32, i32* %7
%58 = icmp eq i32 %56, %57
br i1 %58, label %59, label %63
59: ; preds = %52
%60 = load i32, i32* %13
%61 = load i32, i32* %7
%62 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %60, i32 %61)
br label %67
63: ; preds = %52
br label %64
64: ; preds = %63
%65 = load i32, i32* %13
%66 = add nsw i32 %65, 1
store i32 %66, i32* %13
br label %49
67: ; preds = %59, %49
br label %68
68: ; preds = %67
%69 = load i32, i32* %10
%70 = add nsw i32 %69, 1
store i32 %70, i32* %10
br label %15
71: ; preds = %15
ret i32 0
}

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