This page is still under construction.

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

Reverse Rot

Time limit1sMemory limit256 MB

Summary
Reverse each message, then shift every character forward by N places in the 28-symbol alphabet.
Level

Easy1 of 10

Topics
String, Simulation
Solved
No attempts yet

Problem

Rotating every character of an alphabet by a fixed number of places and rewriting the text is a very simple way to hide it. ROT13, which rotates the letters A to Z by 13 places, works that way, and programs used it to hide data from the late 1990s into the early 2000s.

This problem adds one step to that idea. Reverse the whole string first, then rotate every character forward. For example, reversing ABCD gives DCBA, and rotating that by 1 gives EDCB.

A message consists of capital letters, underscores and periods only. Rotation follows this order.

ABCDEFGHIJKLMNOPQRSTUVWXYZ_.

The underscore comes after Z, and the period comes after the underscore. A forward rotation of 1 turns A into B and B into C, and in the same way Z into _, _ into ., and . into A. A rotation of 3 turns A into D and B into E, and in the same way . into C.

Input

Each line holds an integer NN and a string, separated by one space. NN is the amount of forward rotation, and 1≤N≤271 \le N \le 27. The string is the message to encrypt. Its length is 1 to 40, and it uses capital letters, underscores and periods only. A line holding only the number 0 marks the end of the input.

Output

For each message, print the result of reversing it and then rotating it, one message per line.

Examples2

  1. Example 1

    Input
    1 ABCD
    3 YO_THERE.
    1 .DOT
    14 ROAD
    9 SHIFTING_AND_ROTATING_IS_NOT_ENCRYPTING
    2 STRING_TO_BE_CONVERTED
    1 SNQZDRQDUDQ
    0
    
    Expected output
    EDCB
    CHUHKWBR.
    UPEA
    ROAD
    PWRAYF_LWNHAXWH.RHPWRAJAX_HMWJHPWRAORQ.
    FGVTGXPQEAGDAQVAIPKTVU
    REVERSE_ROT
    
  2. Example 2

    Input
    1 A
    1 Z
    1 _
    1 .
    0
    
    Expected output
    B
    _
    .
    A