This page is still under construction.

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

Formatting Text

Interview

Time limit2sMemory limit1024 MB

Summary
Read whitespace-separated tokens until END, printing each normal token followed by a space and a newline for each N token.
Level

Easy2 of 10

Topics
String, Implementation, Simulation, Brute force
Solved
No attempts yet

Problem

Computers are useful tools for storing, editing, and presenting textual information. When presenting text, one of the most important factors is where to place newlines. In this problem, you should write a program that re-formats text according to a simple set of rules and special markers in the source text.

Input

The input is a sequence of tokens separated by whitespace. Each separator is a single space or newline. All non-whitespace tokens are considered normal except for two special tokens: "N" and "END". The "N" token indicates that a newline should be inserted into the text, and the "END" token indicates the end of input.

Output

Print out each normal token followed by a space. For each occurrence of the special token "N", print a newline.

Examples1

  1. Example 1

    Input
    A
    man provided
    with paper, N pencil, N and
    rubber, N and
    subject to strict
    discipline, N is in
    effect a
    universal machine. N N A. M.
    Turing N END
    
    Expected output
    A man provided with paper,
    pencil,
    and rubber,
    and subject to strict discipline,
    is in effect a universal machine.
    
    A. M. Turing