Under construction

Still being built. Things may change

Send me the money

Interview

Time limit1sMemory limit512 MB

Summary
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 NN 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 NN 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 NN letters Seokgyu remembers and MM sticky notes. Decide for each note whether it can be the password.

Input

The first line contains the number of remembered letters NN (1≤N≤1001 \le N \le 100) and the number of sticky notes MM (1≤M≤10001 \le M \le 1000).

The second line contains a string SS of length NN made of uppercase letters.

Each of the next MM 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 MM lines. For each sticky note, in input order, print true if it can be the password and false otherwise.

Examples2

  1. Example 1

    Input
    4 5
    PPAP
    PPAPP
    PPPPA
    APPPP
    PPPAP
    PAPAP
    
    Expected output
    true
    false
    false
    true
    true
    
  2. Example 2

    Input
    3 2
    CTP
    P
    CHALLENGETHEPROGRAMING
    
    Expected output
    false
    true