eolymp
bolt
Try our new interface for solving problems
Problems

A + B Problem

A + B Problem

Do you know the famous Fibonacci sequence? It is defined by the recurrence \textbf{F_0 = 0}, \textbf{F_1 = 1} and \textbf{F_n = F_\{n-1\} + F_\{n-2\}} for \textbf{n} ≥ \textbf{2}. The Fibonacci numbers have many interesting properties. One of them is that the Fibonacci numbers can be used to represent integers. Every positive integer has a unique representation of the form \textbf{n = F_k1 + F_k2 + … + F_km}, \textbf{k_i} ≥ \textbf{k_\{i-1\} + 2} for \textbf{2} ≤ \textbf{i} ≤ \textbf{m} and \textbf{k_1} ≥ \textbf{2} For example, \textbf{6} can be represented as \textbf{F_2+F_5} and \textbf{12} can be represented as \textbf{F_2+F_4+F_6}. Now you know how to represent positive integers with the Fibonacci numbers, can you add them? Given two Fibonacci formed integers, you should calculate the sum of them. \InputFile The first line contains a single integer \textbf{T}, indicating the number of test cases. Each test case contains two lines; each line contains a single integer m followed by m integers \textbf{k_1}, \textbf{k_2}, …, \textbf{k_m} indicate a Fibonacci formed integer \textbf{F_k1+F_k2+…+F_km}. The input will be always correct. \textbf{1} ≤ \textbf{T} ≤ \textbf{100}, \textbf{1} ≤ \textbf{m} ≤ \textbf{100}, \textbf{2} ≤ \textbf{k_i} ≤ \textbf{1000000}. \OutputFile For each test case, output the case number first, then a single line indicates the sum of the two Fibonacci formed integer. The sum should be Fibonacci formed like the input.
Time limit 1 second
Memory limit 64 MiB
Input example #1
2
1 2
2 2 4
3 2 4 6
2 2 5
Output example #1
Case 1:
1 5
Case 2:
2 5 7