This page is still under construction.

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

Password check

Interview

Time limit2sMemory limit512 MB

Summary
For each of N passwords, report valid if it has a lowercase letter, uppercase letter, digit, symbol, and length at least 12, else invalid.
Level

Easy2 of 10

Topics
String, Implementation
Solved
No attempts yet

Problem

Dublin City University wants to stop students and staff from using weak passwords. The security department asked you to write a program that checks whether a password meets every quality requirement set by the password guidelines council.

The requirements are as follows. A password is strong enough when it has all of these properties:

  • At least one lowercase letter.
  • At least one uppercase letter.
  • At least one digit.
  • At least one symbol from the set +_)(*&^%$#@!./,;{}.
  • Length at least 12.

For example, Aa1_ meets the first four requirements but is shorter than 12 characters. Aa1234567890_ meets every requirement.

Input

One input holds a batch of passwords to process.

The first line contains an integer NN, the number of passwords to process.

Each password is given on two lines. The first line contains an integer SS, the size of the password. The next line contains a sequence of SS characters, the password to check.

A password contains only the letters a to z (lowercase and uppercase), the digits 0 to 9, and the symbols +_)(*&^%$#@!./,;{}.

The size of a password is at most 30, and one input contains at most 100 passwords.

Output

For each password, write a line with valid if the password meets the quality requirements, or invalid otherwise. Keep the order in which the passwords were given.

Examples2

  1. Example 1

    Input
    2
    4
    Aa1_
    13
    Aa1234567890_
    
    Expected output
    invalid
    valid
    
  2. Example 2

    Input
    5
    18
    UtQ.iNlLgT;{f,.GR!
    29
    yr)Z,pHQ+No,ZfP_z12D2l1*MSTfk
    23
    .p7hV/Es^aahW%B.1JJouO;
    9
    c7V!*$1lW
    26
    a^pBAAxCohQlBv7qDpVeOB%Min
    
    Expected output
    invalid
    valid
    valid
    invalid
    valid