Send me the money
InterviewTime limit1sMemory limit512 MB
Given a pattern string S, decide for each of M notes whether S is a subsequence of the note.
- Level
Easy3 of 10
- Topics
- String, Two pointers, Greedy, Implementation
- Solved
- No attempts yet
Problem
Seokgyu wants to send money to Hyeongdong, who is visiting the kingdom of CTP, with an overseas remittance service. He forgot the password for the service, so the transfer is stuck.
Seokgyu writes his passwords on sticky notes. The password is made of uppercase letters only, and Seokgyu remembers of its letters exactly, in the order they appear.
The trouble is that he has several sticky notes and does not know which one holds the password. If the string written on a note contains all remembered letters in that order, the note can be the one with the password. In other words, the remembered string is a subsequence of the string on the note.
For example, if Seokgyu remembers ABB, a note reading BBAB cannot be the password, while a note reading HAEBBC can.

You are given the letters Seokgyu remembers and sticky notes. Decide for each note whether it can be the password.
Input
The first line contains the number of remembered letters () and the number of sticky notes ().
The second line contains a string of length made of uppercase letters.
Each of the next lines contains the string on one sticky note. Every such string is made of uppercase letters and is at most 1000 characters long.
Output
Print lines. For each sticky note, in input order, print true if it can be the password and false otherwise.