#K37757. Email Address Validation

    ID: 26047 Type: Default 1000ms 256MiB

Email Address Validation

Email Address Validation

This problem asks you to validate email addresses based on a specific set of rules. An email address is considered Valid if and only if it meets all the following conditions:

  • It contains exactly one '@' symbol.
  • The local part (before the '@') is non-empty, does not start or end with a dot '.', does not contain consecutive dots, and consists only of alphanumeric characters and dots.
  • The domain part (after the '@') is non-empty, does not start or end with a dot '.', does not contain consecutive dots, and contains at least one dot.
  • When the domain is split by dots, the last part (top-level domain) must consist solely of letters and its length must be between 2 and 6 (inclusive). All preceding parts must be non-empty and consist solely of alphanumeric characters.

You are also provided with a list of email addresses. For each email, print "Valid" if it meets the criteria above, or "Invalid" otherwise.

Note: All input is read from standard input (stdin) and all results should be written to standard output (stdout).

inputFormat

The first line of input contains a single integer n indicating the number of email addresses. The following n lines each contain one email address to validate.

Example Input:
3
john.doe@example.com
jane.doe@exam_ple.co
foo.bar@domain..com

outputFormat

For each of the n email addresses, output a single line with either Valid or Invalid based on the validation rules described above.

Example Output:
Valid
Invalid
Invalid
## sample
3
john.doe@example.com
jane.doe@exam_ple.co
foo.bar@domain..com
Valid

Invalid Invalid

</p>