This page is still under construction.

Parts of this page are still being built. What you see may change.

Cipher

Time limit1sMemory limit128 MB

Summary
Given total character volume, word count, and rank, reconstruct the I-th message in lexicographic order or report corruption.
Level

Medium7 of 10

Topics
Dynamic programming, Combinatorics, String
Solved
No attempts yet

Problem

A spy exchanges messages with a very efficient cipher. However long a message is, three numbers carry it.

The Department of National Security worked out the rules.

  1. A message uses only lowercase English letters and the space character. Every character has an integer called its character volume. A space has volume 11, a has volume 22, b has volume 33, and so on up to z, which has volume 2727. The volume VV of a message is the sum of the volumes of the characters in it.
  2. A message consists of WW words. A word is a consecutive run of lowercase letters, a message has no leading or trailing space, and neighbouring words are separated by exactly one space.
  3. For a given VV and WW, let SS be the lexicographically sorted list of every message whose volume is VV and which consists of exactly WW words. A one-based index II can point at one message in SS.

So when the spy wants to send a message MM, he computes the volume VV and the word count WW of MM, finds the index II of MM in the matching list SS, and sends only the three numbers VV, WW, and II.

You are given VV, WW, and II. Decrypt the spy's message, or report that no such message exists.

In the lexicographic comparison the space character comes before every lowercase letter.

Input

The first line contains the number of test cases TT. (1≤T≤2001 \le T \le 200)

Each of the next TT lines contains three integers separated by spaces: the volume of the message VV, the number of words WW, and the index of the message II. (1≤V≤751 \le V \le 75, 1≤W≤201 \le W \le 20, 1≤I≤10181 \le I \le 10^{18})

Output

For each test case, print one line that starts with Case #x: and then the decrypted message. Here xx is the test case number starting from 11. If no message matches the given VV, WW, and II, print Corrupted! in place of the message.

Hint

Sorting every message of volume 77 that has 22 words gives five of them: a aa, a c, aa a, b b, c a. Index 33 therefore points at aa a.

Volume 22 with 11 word allows only a. The list holds a single message, so a request for index 22 means something went wrong.

Examples2

  1. Example 1

    Input
    3
    7 2 3
    2 1 2
    50 2 39098532022
    
    Expected output
    Case #1: aa a
    Case #2: Corrupted!
    Case #3: big bang
    
  2. Example 2

    Input
    5
    7 2 1
    7 2 5
    7 2 6
    2 1 1
    1 1 1
    
    Expected output
    Case #1: a aa
    Case #2: c a
    Case #3: Corrupted!
    Case #4: a
    Case #5: Corrupted!