#K91822. Valid Hexadecimal Number Checker

    ID: 38061 Type: Default 1000ms 256MiB

Valid Hexadecimal Number Checker

Valid Hexadecimal Number Checker

You are required to determine if a given string is a valid hexadecimal number. A valid hexadecimal number must satisfy the following conditions:

  • It may have leading and trailing spaces, which must be ignored.
  • It can optionally begin with the prefix 0x or 0X.
  • After the optional prefix, it must contain at least one character.
  • All characters (after trimming and removing the optional prefix) must be digits (0-9) or letters from a-f (case-insensitive).

For example:

  • 0x1A3 is valid.
  • 1A3F is valid.
  • 0xGHI is invalid because it contains non-hexadecimal letters.
  • An empty string or a string with only spaces is invalid.

You need to write a program that reads an input string from stdin and prints True if it is a valid hexadecimal number, or False otherwise.

inputFormat

The input consists of a single line containing a string s. This string may include leading or trailing spaces.

outputFormat

Output a single line with either True or False, indicating whether the input string is a valid hexadecimal number according to the rules above.

## sample
0x1A3
True