Under construction

Still being built. Things may change

Alternative Encryption

Time limit2sMemory limit1024 MB

Summary
Given strings of lowercase letters, encrypt or decrypt each one so that the output keeps its length, and each letter differs from the original at the same position.
Level

Medium4 of 10

Topics
String, Math, Implementation
Solved
No attempts yet

Problem

TU Delft has decided to implement a system of secure communication, called New Well-Encrypted Remote Communication, to fight the theft of intellectual property by rival universities. All internal communication will be encrypted before it is sent over the network and decrypted on arrival. The infrastructure is already set up, and TU Delft has asked you to design the encryption.

You must design an algorithm that both encrypts and decrypts text made of only English lowercase letters. You do not need to explain how it works, and TU Delft wants it kept secret to improve security. The algorithm must meet these criteria:

  • No matter what the text is, encrypting it and then decrypting the result yields the original text.
  • The encrypted text consists of only English lowercase letters and has the same number of letters as the original text.
  • For all ii, the iith letter of the encrypted text differs from the iith letter of the original text.

The word nwercjury may not be encrypted as irritating, because the lengths differ. It also may not be encrypted as imbecilic, because the fifth letter is c in both. An acceptable encryption is fantastic, which has an n and a c like the original, but in different positions.

Your program runs twice for each test case. In the first run, it receives strings to encrypt. In the second run, it receives the encrypted strings and must decrypt them to recover the originals.

A testing tool is provided to help you develop your solution.

Input

The input consists of:

  • One line with either encrypt or decrypt, indicating the action your program has to perform.
  • One line with an integer nn (1≤n≤10001 \le n \le 1000), the number of strings.
  • nn lines, each with a string ss (1≤∣s∣≤1001 \le |s| \le 100), the text to encrypt or decrypt. All input strings consist of only English lowercase letters (a-z).

Output

For each string, output its encryption or decryption, as required.

Examples2

  1. Example 1

    Input
    encrypt
    3
    plaintext
    nwerc
    correct
    
    Expected output
    encrypted
    delft
    balloon
    
  2. Example 2

    Input
    decrypt
    3
    encrypted
    delft
    balloon
    
    Expected output
    plaintext
    nwerc
    correct