MAIN12C - Email ID

Everyone loves Swampy. Swampy the Alligator lives under the city and yearns for a more human like existence. One day Swampy thought to learn the intricacies of the internet. He went to a book store in SwampVille immediately and bought a book on "Basic Internet". After reading the book Swampy decided to try on some exercises. The exercise demanded Swampy to report all valid email-id's in a given free-form text string. Check output section for exact specification. Swampy lacks the intelligence of humans and therefore needs you to help him in this job. The chapter defined email-id's as a string consisting of two parts. From left to right, these are username and site-address. The username is non-empty string of minimum length 5 build from characters {a-z A-Z 0-9 . _} (excluding the brackets). The username cannot start from '.' or '_' The site-address is build of a prefix which is non-empty string build from characters {a-z A-Z 0-9} (excluding the brackets) followed by one of the following suffixes {".com", ".org", "edu", ".co.in"}. There is no space character in the email-id. The entire email-id is "username@site-address".

Input

First line of the input contains an integer T, the number of test cases. Then T test cases follow. Each test case consists of String S on a single line. S is made up of characters {a-z A-Z 0-9 ~!@#$%^&*()<>?,.} (excluding the brackets) and space character too.

Output

For each test case, print Case #X: K, where X is the test case number starting from 1, K is the number of email-id's found in S, and then K lines with email-id's found in S.

Example

Input:
2
svm11@gmail.com
svm11@gmail.com svm12@gmail.co.in

Output:
Case #1: 1
svm11@gmail.com
Case #2: 2
svm11@gmail.com
svm12@gmail.co.in

Constraints: T <= 100 |S| <= 10000


Added by:Nikunj Jain
Date:2012-03-15
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:Vaibhav Mittal

hide comments
2012-04-02 16:49:04 Mitch Schwartz
@Jared: Thanks for some insight. There are more interpretations than I first thought of. Here is some clarification:

1. We must print the IDs in the same order as given in input.
2. We must not remove duplicates.
3. The character '_' CAN appear in S.
4. It should be ".edu".
5. The IDs must be non-overlapping.
6. An ID must be included as soon as it is seen, working from left to right.
7. An ID can be surrounded by non-whitespace characters. (That is, we should NOT divide S into tokens according to whitespace at the beginning, then check each token whether it is a valid ID.)
2012-04-02 16:12:57 Jared Deckard
AC!
@Aryom, 1 address.

Last edit: 2012-04-02 16:13:35
2012-03-28 10:01:19 Mitch Schwartz
This problem seems easy, maybe too easy for classical. There are some unclear/strange things about the problem description, which may account for why nobody has gotten AC yet:

1. Must we print the IDs in some special order? Three likely answers are (a) preserve order as given in input, (b) sorted lexicographically, or (c) it doesn't matter (special judge).
2. Do we care about duplicate IDs? (If there are duplicates, must we remove them and only count and enumerate distinct IDs?)
3. We are given that '_' can be part of valid email IDs, but that '_' cannot appear in S.
4. Presumably "edu" is a typo and should be ".edu".

Please clarify.
2012-03-28 09:55:44 napster
pls specify wht my prog has to output,all valid ids or all ids
2012-03-25 10:46:59 Pranay
why does it give "Could not create JAVA Virtual machine" on submission with JAVA solution?
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.