#K3511. Filter Valid Emails

    ID: 25459 Type: Default 1000ms 256MiB

Filter Valid Emails

Filter Valid Emails

You are given a list of email addresses. Your task is to filter out and print only the valid email addresses. An email address is considered valid if it satisfies all of the following conditions:

  • It contains exactly one @ character. In other words, if we denote the count of '@' by \(N_{@}\), then \(N_{@} = 1\).
  • The portion before the @ (the local part) is non-empty and consists only of alphanumeric characters (both uppercase and lowercase) as well as the special characters ., _, +, and -.
  • The portion after the @ (the domain part) is non-empty and must contain at least one . which is not the first or the last character of the domain.
  • The domain part must not contain consecutive dots (i.e. the substring .. is forbidden).
  • The email address must not contain any spaces.

Your program should read the input in stdin and output the valid email addresses to stdout, each on a new line, maintaining the original input order.

inputFormat

The first line contains an integer n denoting the number of email addresses. The following n lines each contain one email address.

outputFormat

Output each valid email address on a new line in the same order as they are given in the input. If no email address is valid, output nothing.

## sample
2
valid.email@example.com
invalid.email@.com
valid.email@example.com

</p>