PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#GD0000050. Ghép đôi theo độ tuổi (A Match Making Problem)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Ghép đôi theo độ tuổi (A Match Making Problem)

A Match Making Problem

Source: UVa

Version: Phuoc Hung OJ Extended

Problem Statement

There are BB bachelors and SS spinsters. Starting with the oldest bachelor, match each to the closest-aged available spinster until one side is exhausted. Print the number of unmatched bachelors and, if positive, the youngest unmatched bachelor age.

Input

Line 1: B,SB,S. The next BB lines give bachelor ages; the following SS lines give spinster ages.

Output

Print Case 1: X when no bachelors remain, or Case 1: X Y otherwise, where XX is the remaining count and YY the youngest age.

Subtasks

  • Subtask 1 (20 points): 1≤B,S≤41\le B,S\le 4; every age is in [2,60][2,60].
  • Subtask 2 (30 points): 1≤B,S≤1001\le B,S\le 100; every age is in [2,60][2,60].
  • Subtask 3 (50 points): 1≤B,S≤99991\le B,S\le 9999; every age is in [2,60][2,60].

Examples

Input

4 2
5
5
10
15
20
18

Output

Case 1: 2 5

Explanation

There are four bachelors and two spinsters, leaving exactly two bachelors. The two oldest bachelors (15,10) are matched first; the remaining ages are 5 and 5, so the answer is Case 1: 2 5.