Under construction

Still being built. Things may change

Students and Mentors

Interview

Memory limit1024 MB

Summary
For each student, find the highest rating among other students that is at most twice their own rating, or -1 if no such student exists.
Level

Easy3 of 10

Topics
Sorting, Binary search
Solved
No attempts yet

Problem

A group of NN students prepares together for upcoming programming competitions such as Kick Start and Code Jam by Google. To help each other prepare, each student picks a mentor among the other students. A mentor helps their mentee solve problems, learn algorithms, track progress, and support them throughout preparation.

Each student has exactly one mentor among all other students, and one person can be a mentor to several students. Each student ii has a rating RiR_i that approximates how strong they are at programming competitions. A mentor should not be much stronger than their mentee, so student jj can be the mentor of student ii only if Rj≤2×RiR_j \le 2 \times R_i. A mentor may have a rating lower than or equal to their mentee's rating.

Each student wants the strongest possible mentor. For each student, find the highest rating of a mentor they can pick.

Input

The first line contains the number of test cases TT. Each of the TT test cases follows on two lines.

The first line of each test case contains the number of students NN.

The second line contains NN integers R1,R2,…,RNR_1, R_2, \dots, R_N, separated by spaces. RiR_i is the rating of the ii-th student.

Output

For each test case, print one line in the form Case #x: M1 M2 M3 ... MN. Here xx is the test case number starting from 1, and MiM_i is the highest rating of a mentor the ii-th student can have. If the ii-th student has no suitable mentor, print −1-1 for that student.

Limits

  • 1≤T≤1001 \le T \le 100.
  • 1≤Ri≤1061 \le R_i \le 10^6 for all ii.

Examples1

  1. Example 1

    Input
    3
    3
    2000 1500 1900
    5
    1000 600 1000 2300 1800
    2
    2500 1200
    
    Expected output
    Case #1: 1900 2000 2000
    Case #2: 1800 1000 1800 1800 2300
    Case #3: 1200 -1