This page is still under construction.

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

Reverse Word Order

Time limit5sMemory limit512 MB

Summary
Given N lines of space-separated words, print each line's words in reverse order prefixed with the case number.
Level

Easy2 of 10

Topics
String, Implementation
Solved
No attempts yet

Problem

You are given lists of words separated by spaces, one list per line. Print the words of each line in reverse order.

A line holds ww English words and LL letters in total. Each line contains only letters and spaces, and exactly one space separates two neighboring words.

Input

The first line contains NN, the number of cases.

Each of the next NN lines is one case and holds words separated by spaces. No line starts or ends with a space.

  • 1≤N≤1001 \le N \le 100
  • 1≤L≤251 \le L \le 25

Output

Print one line per case. For case number xx, print Case #x: first, then the words of that line in reverse order, separated by one space.

Examples3

  1. Example 1

    Input
    3
    this is a test
    foobar
    all your base
    
    Expected output
    Case #1: test a is this
    Case #2: foobar
    Case #3: base your all
    
  2. Example 2

    Input
    1
    a
    
    Expected output
    Case #1: a
    
  3. Example 3

    Input
    5
    alpha beta
    one
    x y z
    keep the order reversed
    ab cd ef gh ij kl
    
    Expected output
    Case #1: beta alpha
    Case #2: one
    Case #3: z y x
    Case #4: reversed order the keep
    Case #5: kl ij gh ef cd ab