#K71877. Wildcard Pattern Matching

    ID: 33629 Type: Default 1000ms 256MiB

Wildcard Pattern Matching

Wildcard Pattern Matching

Wildcard Pattern Matching

Given two strings, s and p, determine if the pattern p matches the entire string s. In the pattern, the character ? matches any single character, and * matches any sequence of characters (including the empty sequence).

Your task is to output YES if the pattern p matches the entire string s, and NO otherwise. Note that the matching must cover the entire string s and cannot be partial.

Input Format: The input consists of two lines. The first line contains the string s and the second line contains the pattern p.

Output Format: Output a single line: YES or NO, based on whether the pattern matches the string.

inputFormat

The input is provided via stdin and consists of two lines:

  1. The first line contains the string s.
  2. The second line contains the pattern p, which may include the wildcards ? and *.

outputFormat

The output should be printed to stdout as a single line containing either YES or NO. YES indicates that the pattern p matches the entire string s, and NO indicates otherwise.

## sample
aa

a
NO