Under construction

Still being built. Things may change

Defining Moment

Interview

Time limit1sMemory limit128 MB

Summary
For each word, strip at most one valid prefix and one valid suffix, then substitute the matching English meaning, expanding the suffix after the prefix.
Level

Easy3 of 10

Topics
String, Implementation, Simulation, Hash map
Solved
No attempts yet

Problem

As a homework assignment, you must write a program that gives the meanings of many different words. Instead of storing a definition for every word, you keep definitions for only a handful of root words and recognize common prefixes and suffixes. Your program recognizes at most one prefix and one suffix per word, so it can handle many forms of each root while keeping the number of memorized definitions small.

In this problem you implement the prefix/suffix processing part of the program. In the tables below, <word> stands for the root, and each meaning is the exact English phrase your program must print.

The valid prefixes and their meanings are:

PrefixMeaning
anti<word>against <word>
post<word>after <word>
pre<word>before <word>
re<word><word> again
un<word>not <word>

The valid suffixes and their meanings are:

SuffixMeaning
<word>erone who <word>s
<word>ingto actively <word>
<word>izechange into <word>
<word>smultiple instances of <word>
<word>tionthe process of <word>ing

A suffix is bound more tightly to its root than a prefix, so the suffix is expanded last, after the prefix. For example, the word unvaporize expands step by step:

unvaporize
not vaporize
not change into vapor

The resulting definitions are not always grammatically perfect, but that is good enough for a single homework grade.

Input

The first line contains a single integer nn, the number of words to define. Each of the next nn lines contains one word.

For every word, expand at most one prefix and at most one suffix. Each word is guaranteed to leave a non-empty root after its prefix and/or suffix are removed. Each word consists of at most 100 printable characters.

Output

For each input word, print its expanded form on its own line, obtained by replacing the recognized prefix and/or suffix with the corresponding meaning. If a word has neither a recognized prefix nor a recognized suffix, print it unchanged.

Examples2

  1. Example 1

    Input
    6
    vaporize
    prewar
    recooking
    root
    repopularize
    uninforming
    
    Expected output
    change into vapor
    before war
    to actively cook again
    root
    change into popular again
    not to actively inform
    
  2. Example 2

    Input
    5
    antihero
    postgame
    preview
    redo
    unhappy
    
    Expected output
    against hero
    after game
    before view
    do again
    not happy