#K90737. Password Validation Challenge

    ID: 37819 Type: Default 1000ms 256MiB

Password Validation Challenge

Password Validation Challenge

Given a password and its expected length, determine whether the password is valid according to certain criteria. A valid password must meet the following conditions:

  • It must have exactly \( n \) characters.
  • It must contain at least one uppercase letter.
  • It must contain at least one lowercase letter.
  • It must contain at least one digit.
  • It must contain at least one special character from the set \( \{!, @, #, $, %, ^, &, *, (, )\} \).
  • It must not contain any whitespace characters.

You are also required to validate multiple passwords in one run. Implement the solution such that it reads input from stdin and outputs the results to stdout.

inputFormat

The first line of input contains an integer \( t \), representing the number of test cases. Each test case consists of two lines:

  • The first line contains an integer \( n \) representing the required length of the password.
  • The second line contains the password string.

outputFormat

For each test case, output either "Valid" or "Invalid" on a new line, depending on whether the password meets the criteria.

## sample
2
12
Password123!
8
passw0rd
Valid

Invalid

</p>