Restoring a Scrambled Email

Interview

Time limit1sMemory limit128 MB

Summary
Given a scrambled string formed by replacing '@' with 'at' and optionally inserting 'nospam' once, output all distinct valid email addresses that could produce it.
Level

Medium5 of 10

Topics
String, Brute force, Implementation
Solved
No attempts yet

Problem

Spam messages are common. When publishing an email address, one way to make automated collectors miss it is to write the address in a scrambled form.

For this problem, a valid email address satisfies all of these conditions:

  1. It consists only of lowercase English letters (a-z), periods (.), and exactly one @.
  2. The characters immediately to the left and right of @ must both be lowercase letters.
  3. The first and last characters of the address must not be periods.

An address is scrambled as follows:

  1. Replace the @ character with the string at.
  2. Then insert the string nospam at any position exactly once, or do not insert it at all. The beginning and the end are also valid insertion positions.

Given a scrambled string, find every distinct valid email address that could have produced it.

Input

The input contains one line: the scrambled address, whose length is at most 100 characters.

Output

Print every distinct valid email address that could produce the given scrambled string, one per line. The addresses may be printed in any order.

Examples3

  1. Example 1

    Input
    natva
    
    Expected output
    n@va
    
  2. Example 2

    Input
    a.batc.dnospam
    
    Expected output
    a.b@c.dnospam
    a.b@c.d
    
  3. Example 3

    Input
    nospammamaattatahr
    
    Expected output
    mamaatt@ahr
    nospammamaatt@ahr
    mama@tatahr
    nospammama@tatahr