- 버블 정렬 느낌의 코드
import sys
input = sys.stdin.readline
P = int(input())
for _ in range(P):
height = list(map(int, input().strip().split()))
tot = 0
for i in range(1, len(height)-1):
for j in range(i+1, len(height)):
if height[i] > height[j]:
height[i], height[j] = height[j], height[i]
tot += 1
print(height[0], tot)