import java.util.*;
import java.math.*;

// **** D. Three Religions ****
/*
22 14
afbcfibaaadecefacidcaa
+ 3 a
+ 2 c
+ 2 a
+ 1 a
+ 3 b
- 1
- 2
+ 2 b
+ 2 c
+ 1 b
+ 1 c
+ 3 a
- 1
- 3
+ 1 b
*/
//*  , cb, ab   (0,1,2)   => [],c,ab

public class D {
	static char [] in = new char [1000000];
	static class AL extends ArrayList<Integer>{ public AL(int a){super(a);}};
	static int [][] pos;
	static int [][] lookup;
	static int [] ptr;
	public static void main (String [] arg) throws Throwable {
		int n = nextInt();
		int q = nextInt();
		char [] word = next().toCharArray();
		lookup = new int [word.length+1][26];
		Arrays.fill(lookup[word.length], Integer.MAX_VALUE);
		for (int i = word.length-1; i>=0; --i) {
			int tmp = word[i] - 'a';
			for (int j = 0; j<26; ++j) lookup[i][j] = lookup[i+1][j];
			lookup[i][tmp] = i;
		}
		AL[] R = new AL[3];
		for (int i = 0; i<3; ++i) R[i] = new AL(q);
		StringBuilder ans = new StringBuilder(q*4);
		boolean can = true;

		int [] pr = new int [3];
		int [][][] dp = new int [251][251][251];
		dp[0][0][0] = -1;
		for (int iii = 0; iii<q; ++iii) {
			String s = next();
			int r = nextInt()-1;
			if (s.charAt(0) == '-') {
				pr[r]--;
				R[r].remove(R[r].size()-1);
			} else {
				String c = next();
				R[r].add( c.charAt(0) - 'a');
				pr[r]++;
				int x0 = pr[r];
				int x1 = (r+1)%3;
				int x2 = (r+2)%3;
				int MIN = Integer.MAX_VALUE;
				for (int i = 0; i <= pr[x1]; ++i) {
					for (int j = 0; j <= pr[x2]; ++j) {
						int tmp1 = (r == 0) ? dp[x0-1][i][j] : (r == 1) ? dp[j][x0-1][i] : dp[i][j][x0-1];
						int tmp2 = (i == 0) ? Integer.MAX_VALUE : (r == 0) ? dp[x0][i-1][j] : (r == 1) ? dp[j][x0][i-1] : dp[i-1][j][x0];
						int tmp3 = (j == 0) ? Integer.MAX_VALUE : (r == 0) ? dp[x0][i][j-1] : (r == 1) ? dp[j-1][x0][i] : dp[i][j-1][x0];
						//System.err.println("tmp " + tmp1 + " , " + tmp2 + " , " + tmp3);

						int R0 = rSearch(tmp1, R[r].get(x0-1), r);
						int R1 = (i == 0) ? Integer.MAX_VALUE : rSearch(tmp2, R[x1].get(i-1), x1);
						int R2 = (j == 0) ? Integer.MAX_VALUE : rSearch(tmp3, R[x2].get(j-1), x2);
						if (r == 0) {
							dp[x0][i][j] = Math.min(R0, Math.min(R1,R2));
							//System.err.println(dp[x0][i][j] + " for " + x0 + " , " + i + " , " + j);
						}
						if (r == 1) {
							dp[j][x0][i] = Math.min(R0, Math.min(R1,R2));
							/*
							System.err.println(dp[j][x0][i] + " for " + j + " , " + x0 + " , " + i);
							if (iii == 77) {
								for (int i1 = 0; i1<=2; i1++)
									for (int i2 = 0; i2<=2; i2++)
										for (int i3 = 0; i3<=2; i3++)
											System.out.println(i1 + " , " + i2 + " , " + i3 + " :: " + dp[i1][i2][i3]);
							}
							// */
						}
						if (r == 2) {
							dp[i][j][x0] = Math.min(R0, Math.min(R1,R2));
							/*
							if (iii == 4) System.err.println("Setting " + i + " , " + j + " " + x0);
							if (iii == 4) System.err.println(R[0]);
							if (iii == 4) System.err.println(R[1]);
							if (iii == 4) System.err.println(R[2]);
							dp[i][j][x0] = Math.min(R0, Math.min(R1,R2));
							if (iii == 4) {
								for (int i1 = 0; i1<=2; i1++)
									for (int i2 = 0; i2<=2; i2++)
										for (int i3 = 0; i3<=2; i3++)
											System.out.println(i1 + " , " + i2 + " , " + i3 + " :: " + dp[i1][i2][i3]);
							}
							*/
						}
					}
				}
				//System.err.println("VALUE after step " + iii + " is " + dp[pr[0]][pr[1]][pr[2]]);
			}
			can = (dp[pr[0]][pr[1]][pr[2]] != Integer.MAX_VALUE);
			if (ans.length() != 0) ans = ans.append("\n");
			ans = ans.append(can ? "YES" : "NO");
		}
		System.out.println(ans);
	}
	public static int rSearch(int last_pos , int c , int debug) {
		if (last_pos == Integer.MAX_VALUE) return Integer.MAX_VALUE;
		//if (ptr[c] == 0) return Integer.MAX_VALUE;
		/*
		int j = Arrays.binarySearch(pos[c], 0, ptr[c], last_pos+1);
		if (j < 0) {
			j = -j - 1;
		}
		if (j >= ptr[c]) return Integer.MAX_VALUE;
		//System.err.println("Searching " + ((char)('a'+c)) + " after " + last_pos + " for religion " + debug +" and ans is " + pos[c][j]);
		return pos[c][j];
		*/
		return lookup[last_pos+1][c];
	}

	/************** FAST IO CODE FOLLOWS *****************/
	public static long nextLong() throws Throwable {
		long i = System.in.read();boolean neg = false;while (i < 45) i = System.in.read();if (i == 45) {neg=true;i=48;}i = i - 48;
		int j = System.in.read();while (j > 32) {i*=10;i+=j-48;j = System.in.read();}return (neg) ? -i : i;
	}
	public static int nextInt() throws Throwable {return (int)nextLong();}
	public static String next() throws Throwable {
		int i = 0; while (i < 40 && i != -1) i = System.in.read(); int cptr = 0; while (i >= 40) { in[cptr++] = (char)i; i = System.in.read();}
		return new String(in, 0,cptr);
	}
	/**** LIBRARIES ****/
	public static long gcdL(long a, long b) {while (b != 0) {long tmp = b;b = (a % b);a = tmp;}return a;}
	public static int gcd(int a, int b) {while (b != 0) {int tmp = b;b = (a % b);a = tmp;}return a;}
	public static int[] sieve(int LIM) {
		int i,count = 0;
		boolean [] b = new boolean [LIM];
		for (i = 2;i<LIM; ++i) if (!b[i]) {count++; for (int j = i<<1; j<LIM; j+=i) b[j] = true;}
		int [] primes = new int[count];
		for (i = 2,count=0;i<LIM;++i) if (!b[i]) primes[count++] = i;
		return primes;
	}
	public static int[] numPrimeFactors(int LIM) {
		int i,count = 0;
		int [] b = new int [LIM];
		for (i = 2;i<LIM; ++i) if (b[i] == 0) {count++; for (int j = i; j<LIM; j+=i) b[j]++;}
		return b;
	}
}
/*
				//int i = pr[0];
				//int j = pr[1];
				//int k = pr[2];
				int x0 = pr[r] - 1;
				int x1 = (r+1)%3;
				int x2 = (r+2)%3;
				int MIN = Integer.MAX_VALUE;

				for (int i = 0; i < Math.max(1,pr[x1]); ++i) {
					for (int j = 0; j < Math.max(1, pr[x2]); ++j) {
						int tmp = (r == 0) ? dp[x0][i][j] : (r == 1) ? dp[j][x0][i] : dp[i][j][x0];
						int rval = rSearch(tmp,
					}
				}
				*/
/* Full Problem Text:

During the archaeological research in the Middle East you found the traces of three ancient religions: First religion, Second religion and Third religion.
You compiled the information on the evolution of each of these beliefs, and you now wonder if the followers of each religion could coexist in peace.
The Word of Universe is a long word containing the lowercase English characters only.
At each moment of time, each of the religion beliefs could be described by a word consisting of lowercase English characters.
The three religions can coexist in peace if their descriptions form disjoint subsequences of the Word of Universe.
More formally, one can paint some of the characters of the Word of Universe in three colors: 1, 2, 3, so that each character is painted in at most one color, and the description of the i-th religion can be constructed from the Word of Universe by removing all characters that aren't painted in color i.
The religions however evolve.
In the beginning, each religion description is empty.
Every once in a while, either a character is appended to the end of the description of a single religion, or the last character is dropped from the description.
After each change, determine if the religions could coexist in peace.

 */


import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeSet;
import java.util.stream.Collectors;

public class Main {

	static class Task {

		int NN = 200005;
		int MOD = 1000000007;
		int INF = 2000000000;
		long INFINITY = 2000000000000000000L;

		int [][]P;
		int [][][]dp = new int[251][251][251];
		char [] s1 = new char[251];
		char [] s2 = new char[251];
		char [] s3 = new char[251];

		public void solve(InputReader in, PrintWriter out) {
			int n = in.nextInt();
			int q = in.nextInt();
			String str = in.next();
			P = new int[26][1 + n];
			for(int i=0;i<26;++i) {
				for(int j=0;j<=n;++j)
					P[i][j] = n;
			}
			for(int i=n-1;i>=0;--i) {
				int ch = str.charAt(i)-'a';
				for(int j=0;j<26;++j) {
						P[j][i] = P[j][i + 1];
				}
				P[ch][i] = i;
			}
			dp[0][0][0] = -1;
			int len1 = 0, len2 =0, len3 = 0;
			while(q-->0) {
				String type = in.next();
				if(type.charAt(0) == '+') {
					int index = in.nextInt();
					char ch = in.next().charAt(0);
					if(index == 1) {
						s1[len1++] = ch;
					} else if(index == 2) {
						s2[len2++] = ch;
					} else {
						s3[len3++]= ch;
					}
					for(int i=index==1?len1:0;i<=len1;++i) {
						for(int j=index==2?len2:0;j<=len2;++j) {
							for(int k=index==3?len3:0;k<=len3;++k) {
								if(i+j+k==0) {
									dp[i][j][k] = -1;
									continue;
								}
								dp[i][j][k] = n;
								//dp[i-1][j][k]
								if(i > 0) {
									if(dp[i-1][j][k] == -1) {
										dp[i][j][k] = Math.min(dp[i][j][k],
												P[s1[i-1]-'a'][0]);
									}
									else if(dp[i-1][j][k] == n) {
										dp[i][j][k] = Math.min(dp[i][j][k],
												n);
									}
									else {
										dp[i][j][k] = Math.min(dp[i][j][k],
												P[s1[i-1]-'a'][dp[i-1][j][k] + 1]);
									}
								}
								//dp[i][j-1][k]
								if(j > 0) {
									if(dp[i][j-1][k] == -1) {
										dp[i][j][k] = Math.min(dp[i][j][k],
												P[s2[j-1]-'a'][0]);
									}
									else if(dp[i][j-1][k] == n) {
										dp[i][j][k] = Math.min(dp[i][j][k],
												n);
									}
									else {
										dp[i][j][k] = Math.min(dp[i][j][k],
												P[s2[j-1]-'a'][dp[i][j-1][k] + 1]);
									}
								}
								//dp[i][j][k-1]
								if(k > 0) {
									if(dp[i][j][k-1] == -1) {
										dp[i][j][k] = Math.min(dp[i][j][k],
												P[s3[k-1]-'a'][0]);
									}
									else if(dp[i][j][k-1] == n) {
										dp[i][j][k] = Math.min(dp[i][j][k],
												n);
									}
									else {
										dp[i][j][k] = Math.min(dp[i][j][k],
												P[s3[k-1]-'a'][dp[i][j][k-1] + 1]);
									}
								}
							}
						}
					}
				} else {
					int index = in.nextInt();
					if(index == 1) {
						--len1;
					} else if(index == 2) {
						--len2;
					} else {
						--len3;
					}
				}
				if(dp[len1][len2][len3] < n) {
					out.println("YES");
				} else {
					out.println("NO");
				}
			}
		}

	}

	static void prepareIO(boolean isFileIO) {
		//long t1 = System.currentTimeMillis();
		Task solver = new Task();
		// Standard IO
		if(!isFileIO) {
			InputStream inputStream = System.in;
	        OutputStream outputStream = System.out;
	        InputReader in = new InputReader(inputStream);
	        PrintWriter out = new PrintWriter(outputStream);
	        solver.solve(in, out);
	        //out.println("time(s): " + (1.0*(System.currentTimeMillis()-t1))/1000.0);
	        out.close();
		}
        // File IO
		else {
			String IPfilePath = System.getProperty("user.home") + "/Downloads/ip.in";
	        String OPfilePath = System.getProperty("user.home") + "/Downloads/op.out";
	        InputReader fin = new InputReader(IPfilePath);
	        PrintWriter fout = null;
	        try {
				fout = new PrintWriter(new File(OPfilePath));
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
	        solver.solve(fin, fout);
	        //fout.println("time(s): " + (1.0*(System.currentTimeMillis()-t1))/1000.0);
	        fout.close();
		}
	}

	public static void main(String[] args) {
        prepareIO(false);
	}

	static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public InputReader(String filePath) {
        	File file = new File(filePath);
            try {
				reader = new BufferedReader(new FileReader(file));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
            tokenizer = null;
        }

        public String nextLine() {
        	String str = "";
        	try {
				str = reader.readLine();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
        	return str;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
        	return Double.parseDouble(next());
        }

    }

}


/**
 * @author derrick20
 */
import java.io.*;
import java.util.*;

public class ThreeReligions implements Runnable {
    public static void main(String[] args) throws Exception {
        new Thread(null, new ThreeReligions(), ": )", 1 << 28).start();
    }

    public void run() {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

//        generate();
        int N = sc.nextInt();
        int Q = sc.nextInt();
        String str = sc.next();
        int len = str.length();
//        long start = System.currentTimeMillis();
        char[] s = "_".concat(str).toCharArray();
        int[][] next = new int[26][len + 1];
        for (int ch = 0; ch < 26; ch++) {
            next[ch][len] = oo;
        }
        for (int pos = len - 1; pos >= 0; pos--) {
            for (int ch = 0; ch < 26; ch++) {
                if (s[pos + 1] - 'a' == ch) {
                    next[ch][pos] = pos + 1;
                } else {
                    next[ch][pos] = next[ch][pos + 1];
                }
            }
        }
        int[][][] dp = new int[251][251][251];
        for (int i = 0; i <= 250; i++) {
            for (int j = 0; j <= 250; j++) {
                Arrays.fill(dp[i][j], oo);
            }
        }
        dp[0][0][0] = 0;
        int[] sizes = new int[3];
        ArrayList<Character>[] patterns = new ArrayList[3];
        Arrays.setAll(patterns, i -> new ArrayList<>());
        for (int i = 0; i < 3; i++) {
            patterns[i].add('_');
        }
        while (Q-->0) {
            String type = sc.next();
            int which = sc.nextInt() - 1;
            if (type.equals("+")) {
                sizes[which]++;
                char c = sc.next().charAt(0);
                patterns[which].add(c);
                int[] lo = new int[3];
                int[] hi = new int[3];
                for (int l = 0; l < 3; l++) {
                    hi[l] = sizes[l];
                }
                lo[which] = sizes[which];// woopsies, commented while testing XD
                for (int i = lo[0]; i <= hi[0]; i++) {
                    for (int j = lo[1]; j <= hi[1]; j++) {
                        for (int k = lo[2]; k <= hi[2]; k++) {
                            if (i != 0 || j != 0 || k != 0) {
                                dp[i][j][k] = oo; // CURRENTLY, WE DON'T KNOW WHETHER IT'S POSSIBLE!!!
                            }
                            if (i > 0) {
                                int lastPos = dp[i - 1][j][k];
                                if (lastPos != oo) {
                                    int ch = patterns[0].get(i) - 'a';
                                    dp[i][j][k] = Math.min(dp[i][j][k], next[ch][lastPos]);
                                }
                            }
                            if (j > 0) {
                                int lastPos = dp[i][j - 1][k];
                                if (lastPos != oo) {
                                    int ch = patterns[1].get(j) - 'a';
                                    dp[i][j][k] = Math.min(dp[i][j][k], next[ch][lastPos]);
                                }
                            }
                            if (k > 0) {
                                int lastPos = dp[i][j][k - 1];
                                if (lastPos != oo) {
                                    int ch = patterns[2].get(k) - 'a';
                                    dp[i][j][k] = Math.min(dp[i][j][k], next[ch][lastPos]);
                                }
                            }
                        }
                    }
                }
            } else {
                sizes[which]--;
                // this might be it?
                patterns[which].remove(patterns[which].size() - 1);
            }
//            System.out.println(Arrays.toString(patterns));
//            for (int i = 0; i <= sizes[0]; i++) {
//                System.out.println("i = " + i);
//                for (int j = 0; j <= sizes[1]; j++) {
//                    for (int k = 0; k <= sizes[2]; k++) {
//                        System.out.print(dp[i][j][k] + " " );
//                    }
//                    System.out.println();
//                }
//            }
//            System.out.println(Arrays.toString(sizes));
//            System.out.println(Arrays.toString(patterns));
            out.println(dp[sizes[0]][sizes[1]][sizes[2]] != oo ? "YES" : "NO");
        }
        out.close();
//        System.out.println((System.currentTimeMillis() - start) / 1000.0);
    }

    static int oo = (int) 1e6;

    static void generate() {
        int N = 10000;
        int Q = 1000;
        String s = "";
        String gen = "abcdefghijklmnopqrstuvwxyz";
        for (int i = 0; i < N; i++) {
            int p = new Random().nextInt(26);
            s = s.concat("" + gen.charAt(p));
        }
        System.out.println(N + " " + Q);
        System.out.println(s);
        int[] added = new int[3];
        for (int i = 0; i < Q; i++) {
            int which = 1 + new Random().nextInt(3);
            if (Math.random() < 0.5 || added[which - 1] <= 0) {
                int p = new Random().nextInt(26);
                System.out.println("+ " + which + " " + gen.charAt(p));
                added[which - 1]++;
            } else {
                added[which - 1]--;
                System.out.println("- " + which);
            }
        }
    }
    static class FastScanner {
        private int BS = 1 << 16;
        private char NC = (char) 0;
        private byte[] buf = new byte[BS];
        private int bId = 0, size = 0;
        private char c = NC;
        private double cnt = 1;
        private BufferedInputStream in;

        public FastScanner() {
            in = new BufferedInputStream(System.in, BS);
        }

        public FastScanner(String s) {
            try {
                in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
            } catch (Exception e) {
                in = new BufferedInputStream(System.in, BS);
            }
        }

        private char getChar() {
            while (bId == size) {
                try {
                    size = in.read(buf);
                } catch (Exception e) {
                    return NC;
                }
                if (size == -1) return NC;
                bId = 0;
            }
            return (char) buf[bId++];
        }

        public int nextInt() {
            return (int) nextLong();
        }

        public int[] nextInts(int N) {
            int[] res = new int[N];
            for (int i = 0; i < N; i++) {
                res[i] = (int) nextLong();
            }
            return res;
        }

        public long[] nextLongs(int N) {
            long[] res = new long[N];
            for (int i = 0; i < N; i++) {
                res[i] = nextLong();
            }
            return res;
        }

        public long nextLong() {
            cnt = 1;
            boolean neg = false;
            if (c == NC) c = getChar();
            for (; (c < '0' || c > '9'); c = getChar()) {
                if (c == '-') neg = true;
            }
            long res = 0;
            for (; c >= '0' && c <= '9'; c = getChar()) {
                res = (res << 3) + (res << 1) + c - '0';
                cnt *= 10;
            }
            return neg ? -res : res;
        }

        public double nextDouble() {
            double cur = nextLong();
            return c != '.' ? cur : cur + nextLong() / cnt;
        }

        public double[] nextDoubles(int N) {
            double[] res = new double[N];
            for (int i = 0; i < N; i++) {
                res[i] = nextDouble();
            }
            return res;
        }

        public String next() {
            StringBuilder res = new StringBuilder();
            while (c <= 32) c = getChar();
            while (c > 32) {
                res.append(c);
                c = getChar();
            }
            return res.toString();
        }

        public String nextLine() {
            StringBuilder res = new StringBuilder();
            while (c <= 32) c = getChar();
            while (c != '\n') {
                res.append(c);
                c = getChar();
            }
            return res.toString();
        }

        public boolean hasNext() {
            if (c > 32) return true;
            while (true) {
                c = getChar();
                if (c == NC) return false;
                else if (c > 32) return true;
            }
        }
    }

    static void ASSERT(boolean assertion, String message) {
        if (!assertion) throw new AssertionError(message);
    }

    static void ASSERT(boolean assertion) {
        if (!assertion) throw new AssertionError();
    }
}


/**
 * @author derrick20
 */
import java.io.*;
import java.util.*;

public class ThreeReligions implements Runnable {
    public static void main(String[] args) throws Exception {
        new Thread(null, new ThreeReligions(), ": )", 1 << 28).start();
    }

    public void run() {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

//        generate();
        int N = sc.nextInt();
        int Q = sc.nextInt();
        String str = sc.next();
        int len = str.length();
//        long start = System.currentTimeMillis();
        char[] s = "_".concat(str).toCharArray();
        int[][] next = new int[26][len + 1];
        for (int ch = 0; ch < 26; ch++) {
            next[ch][len] = oo;
        }
        for (int pos = len - 1; pos >= 0; pos--) {
            for (int ch = 0; ch < 26; ch++) {
                if (s[pos + 1] - 'a' == ch) {
                    next[ch][pos] = pos + 1;
                } else {
                    next[ch][pos] = next[ch][pos + 1];
                }
            }
        }
        int[][][] dp = new int[251][251][251];
        for (int i = 0; i <= 250; i++) {
            for (int j = 0; j <= 250; j++) {
                Arrays.fill(dp[i][j], oo);
            }
        }
        dp[0][0][0] = 0;
        int[] sizes = new int[3];
        ArrayList<Character>[] patterns = new ArrayList[3];
        Arrays.setAll(patterns, i -> new ArrayList<>());
        for (int i = 0; i < 3; i++) {
            patterns[i].add('_');
        }
        while (Q-->0) {
            String type = sc.next();
            int which = sc.nextInt() - 1;
            if (type.charAt(0) == '+') {
                sizes[which]++;
                char c = sc.next().charAt(0);
                patterns[which].add(c);
                int[] lo = new int[3];
                int[] hi = new int[3];
                for (int l = 0; l < 3; l++) {
                    hi[l] = sizes[l];
                }
                lo[which] = sizes[which];// woopsies, commented while testing XD
                int work = 1;
                for (int i = 0; i < 3; i++) {
                    work *= (hi[i] - lo[i] + 1);
                }
                ASSERT(work <= 251 * 251); // :/
                for (int i = lo[0]; i <= hi[0]; i++) {
                    for (int j = lo[1]; j <= hi[1]; j++) {
                        for (int k = lo[2]; k <= hi[2]; k++) {
                            if (i != 0 || j != 0 || k != 0) {
                                dp[i][j][k] = oo; // CURRENTLY, WE DON'T KNOW WHETHER IT'S POSSIBLE!!!
                            }
                            if (i > 0) {
                                int lastPos = dp[i - 1][j][k];
                                if (lastPos != oo) {
                                    int ch = patterns[0].get(i) - 'a';
                                    dp[i][j][k] = Math.min(dp[i][j][k], next[ch][lastPos]);
                                }
                            }
                            if (j > 0) {
                                int lastPos = dp[i][j - 1][k];
                                if (lastPos != oo) {
                                    int ch = patterns[1].get(j) - 'a';
                                    dp[i][j][k] = Math.min(dp[i][j][k], next[ch][lastPos]);
                                }
                            }
                            if (k > 0) {
                                int lastPos = dp[i][j][k - 1];
                                if (lastPos != oo) {
                                    int ch = patterns[2].get(k) - 'a';
                                    dp[i][j][k] = Math.min(dp[i][j][k], next[ch][lastPos]);
                                }
                            }
                        }
                    }
                }
            } else {
                sizes[which]--;
                // this might be it?
                patterns[which].remove(patterns[which].size() - 1);
            }
//            System.out.println(Arrays.toString(patterns));
//            for (int i = 0; i <= sizes[0]; i++) {
//                System.out.println("i = " + i);
//                for (int j = 0; j <= sizes[1]; j++) {
//                    for (int k = 0; k <= sizes[2]; k++) {
//                        System.out.print(dp[i][j][k] + " " );
//                    }
//                    System.out.println();
//                }
//            }
//            System.out.println(Arrays.toString(sizes));
//            System.out.println(Arrays.toString(patterns));
            out.println(dp[sizes[0]][sizes[1]][sizes[2]] != oo ? "YES" : "NO");
        }
        out.close();
//        System.out.println((System.currentTimeMillis() - start) / 1000.0);
    }

    static int oo = (int) 1e6;

    static void generate() {
        int N = 10000;
        int Q = 1000;
        String s = "";
        String gen = "abcdefghijklmnopqrstuvwxyz";
        for (int i = 0; i < N; i++) {
            int p = new Random().nextInt(26);
            s = s.concat("" + gen.charAt(p));
        }
        System.out.println(N + " " + Q);
        System.out.println(s);
        int[] added = new int[3];
        for (int i = 0; i < Q; i++) {
            int which = 1 + new Random().nextInt(3);
            if (Math.random() < 0.5 || added[which - 1] <= 0) {
                int p = new Random().nextInt(26);
                System.out.println("+ " + which + " " + gen.charAt(p));
                added[which - 1]++;
            } else {
                added[which - 1]--;
                System.out.println("- " + which);
            }
        }
    }
    static class FastScanner {
        private int BS = 1 << 16;
        private char NC = (char) 0;
        private byte[] buf = new byte[BS];
        private int bId = 0, size = 0;
        private char c = NC;
        private double cnt = 1;
        private BufferedInputStream in;

        public FastScanner() {
            in = new BufferedInputStream(System.in, BS);
        }

        public FastScanner(String s) {
            try {
                in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
            } catch (Exception e) {
                in = new BufferedInputStream(System.in, BS);
            }
        }

        private char getChar() {
            while (bId == size) {
                try {
                    size = in.read(buf);
                } catch (Exception e) {
                    return NC;
                }
                if (size == -1) return NC;
                bId = 0;
            }
            return (char) buf[bId++];
        }

        public int nextInt() {
            return (int) nextLong();
        }

        public int[] nextInts(int N) {
            int[] res = new int[N];
            for (int i = 0; i < N; i++) {
                res[i] = (int) nextLong();
            }
            return res;
        }

        public long[] nextLongs(int N) {
            long[] res = new long[N];
            for (int i = 0; i < N; i++) {
                res[i] = nextLong();
            }
            return res;
        }

        public long nextLong() {
            cnt = 1;
            boolean neg = false;
            if (c == NC) c = getChar();
            for (; (c < '0' || c > '9'); c = getChar()) {
                if (c == '-') neg = true;
            }
            long res = 0;
            for (; c >= '0' && c <= '9'; c = getChar()) {
                res = (res << 3) + (res << 1) + c - '0';
                cnt *= 10;
            }
            return neg ? -res : res;
        }

        public double nextDouble() {
            double cur = nextLong();
            return c != '.' ? cur : cur + nextLong() / cnt;
        }

        public double[] nextDoubles(int N) {
            double[] res = new double[N];
            for (int i = 0; i < N; i++) {
                res[i] = nextDouble();
            }
            return res;
        }

        public String next() {
            StringBuilder res = new StringBuilder();
            while (c <= 32) c = getChar();
            while (c > 32) {
                res.append(c);
                c = getChar();
            }
            return res.toString();
        }

        public String nextLine() {
            StringBuilder res = new StringBuilder();
            while (c <= 32) c = getChar();
            while (c != '\n') {
                res.append(c);
                c = getChar();
            }
            return res.toString();
        }

        public boolean hasNext() {
            if (c > 32) return true;
            while (true) {
                c = getChar();
                if (c == NC) return false;
                else if (c > 32) return true;
            }
        }
    }

    static void ASSERT(boolean assertion, String message) {
        if (!assertion) throw new AssertionError(message);
    }

    static void ASSERT(boolean assertion) {
        if (!assertion) throw new AssertionError();
    }
}


/**
 * @author derrick20
 */
import java.io.*;
import java.util.*;

public class ThreeReligions implements Runnable {
    public static void main(String[] args) throws Exception {
        new Thread(null, new ThreeReligions(), ": )", 1 << 28).start();
    }

    public void run() {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

//        generate();
        int N = sc.nextInt();
        int Q = sc.nextInt();
        String str = sc.next();
        int len = str.length();
//        long start = System.currentTimeMillis();
        char[] s = "_".concat(str).toCharArray();
        int[][] next = new int[26][len + 1];
        for (int ch = 0; ch < 26; ch++) {
            next[ch][len] = oo;
        }
        for (int pos = len - 1; pos >= 0; pos--) {
            for (int ch = 0; ch < 26; ch++) {
                if (s[pos + 1] - 'a' == ch) {
                    next[ch][pos] = pos + 1;
                } else {
                    next[ch][pos] = next[ch][pos + 1];
                }
            }
        }
        int[][][] dp = new int[251][251][251];
        for (int i = 0; i <= 250; i++) {
            for (int j = 0; j <= 250; j++) {
                Arrays.fill(dp[i][j], oo);
            }
        }
        dp[0][0][0] = 0;
        int[] sizes = new int[3];
        ArrayList<Character>[] patterns = new ArrayList[3];
        Arrays.setAll(patterns, i -> new ArrayList<>());
        for (int i = 0; i < 3; i++) {
            patterns[i].add('_');
        }
        while (Q-->0) {
            String type = sc.next();
            int which = sc.nextInt() - 1;
            if (type.charAt(0) == '+') {
                sizes[which]++;
                char c = sc.next().charAt(0);
                patterns[which].add(c);
                int[] lo = new int[3];
                int[] hi = new int[3];
                for (int l = 0; l < 3; l++) {
                    hi[l] = sizes[l];
                }
                lo[which] = sizes[which];// woopsies, commented while testing XD
                for (int i = lo[0]; i <= hi[0]; i++) {
                    for (int j = lo[1]; j <= hi[1]; j++) {
                        for (int k = lo[2]; k <= hi[2]; k++) {
                            if (i != 0 || j != 0 || k != 0) {
                                dp[i][j][k] = oo; // CURRENTLY, WE DON'T KNOW WHETHER IT'S POSSIBLE!!!
                            }
                            if (i > 0) {
                                int lastPos = dp[i - 1][j][k];
                                if (lastPos != oo) {
                                    int ch = patterns[0].get(i) - 'a';
                                    dp[i][j][k] = Math.min(dp[i][j][k], next[ch][lastPos]);
                                }
                            }
                            if (j > 0) {
                                int lastPos = dp[i][j - 1][k];
                                if (lastPos != oo) {
                                    int ch = patterns[1].get(j) - 'a';
                                    dp[i][j][k] = Math.min(dp[i][j][k], next[ch][lastPos]);
                                }
                            }
                            if (k > 0) {
                                int lastPos = dp[i][j][k - 1];
                                if (lastPos != oo) {
                                    int ch = patterns[2].get(k) - 'a';
                                    dp[i][j][k] = Math.min(dp[i][j][k], next[ch][lastPos]);
                                }
                            }
                        }
                    }
                }
            } else {
                sizes[which]--;
                // this might be it?
                patterns[which].remove(patterns[which].size() - 1);
            }
//            System.out.println(Arrays.toString(patterns));
//            for (int i = 0; i <= sizes[0]; i++) {
//                System.out.println("i = " + i);
//                for (int j = 0; j <= sizes[1]; j++) {
//                    for (int k = 0; k <= sizes[2]; k++) {
//                        System.out.print(dp[i][j][k] + " " );
//                    }
//                    System.out.println();
//                }
//            }
//            System.out.println(Arrays.toString(sizes));
//            System.out.println(Arrays.toString(patterns));
            out.println(dp[sizes[0]][sizes[1]][sizes[2]] != oo ? "YES" : "NO");
        }
        out.close();
//        System.out.println((System.currentTimeMillis() - start) / 1000.0);
    }

    static int oo = (int) 1e6;

    static void generate() {
        int N = 10000;
        int Q = 1000;
        String s = "";
        String gen = "abcdefghijklmnopqrstuvwxyz";
        for (int i = 0; i < N; i++) {
            int p = new Random().nextInt(26);
            s = s.concat("" + gen.charAt(p));
        }
        System.out.println(N + " " + Q);
        System.out.println(s);
        int[] added = new int[3];
        for (int i = 0; i < Q; i++) {
            int which = 1 + new Random().nextInt(3);
            if (Math.random() < 0.5 || added[which - 1] <= 0) {
                int p = new Random().nextInt(26);
                System.out.println("+ " + which + " " + gen.charAt(p));
                added[which - 1]++;
            } else {
                added[which - 1]--;
                System.out.println("- " + which);
            }
        }
    }
    static class FastScanner {
        private int BS = 1 << 16;
        private char NC = (char) 0;
        private byte[] buf = new byte[BS];
        private int bId = 0, size = 0;
        private char c = NC;
        private double cnt = 1;
        private BufferedInputStream in;

        public FastScanner() {
            in = new BufferedInputStream(System.in, BS);
        }

        public FastScanner(String s) {
            try {
                in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
            } catch (Exception e) {
                in = new BufferedInputStream(System.in, BS);
            }
        }

        private char getChar() {
            while (bId == size) {
                try {
                    size = in.read(buf);
                } catch (Exception e) {
                    return NC;
                }
                if (size == -1) return NC;
                bId = 0;
            }
            return (char) buf[bId++];
        }

        public int nextInt() {
            return (int) nextLong();
        }

        public int[] nextInts(int N) {
            int[] res = new int[N];
            for (int i = 0; i < N; i++) {
                res[i] = (int) nextLong();
            }
            return res;
        }

        public long[] nextLongs(int N) {
            long[] res = new long[N];
            for (int i = 0; i < N; i++) {
                res[i] = nextLong();
            }
            return res;
        }

        public long nextLong() {
            cnt = 1;
            boolean neg = false;
            if (c == NC) c = getChar();
            for (; (c < '0' || c > '9'); c = getChar()) {
                if (c == '-') neg = true;
            }
            long res = 0;
            for (; c >= '0' && c <= '9'; c = getChar()) {
                res = (res << 3) + (res << 1) + c - '0';
                cnt *= 10;
            }
            return neg ? -res : res;
        }

        public double nextDouble() {
            double cur = nextLong();
            return c != '.' ? cur : cur + nextLong() / cnt;
        }

        public double[] nextDoubles(int N) {
            double[] res = new double[N];
            for (int i = 0; i < N; i++) {
                res[i] = nextDouble();
            }
            return res;
        }

        public String next() {
            StringBuilder res = new StringBuilder();
            while (c <= 32) c = getChar();
            while (c > 32) {
                res.append(c);
                c = getChar();
            }
            return res.toString();
        }

        public String nextLine() {
            StringBuilder res = new StringBuilder();
            while (c <= 32) c = getChar();
            while (c != '\n') {
                res.append(c);
                c = getChar();
            }
            return res.toString();
        }

        public boolean hasNext() {
            if (c > 32) return true;
            while (true) {
                c = getChar();
                if (c == NC) return false;
                else if (c > 32) return true;
            }
        }
    }

    static void ASSERT(boolean assertion, String message) {
        if (!assertion) throw new AssertionError(message);
    }

    static void ASSERT(boolean assertion) {
        if (!assertion) throw new AssertionError();
    }
}


/**
 * @author derrick20
 */
import java.io.*;
import java.util.*;

public class ThreeReligions implements Runnable {
    public static void main(String[] args) throws Exception {
        new Thread(null, new ThreeReligions(), ": )", 1 << 28).start();
    }

    public void run() {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

//        generate();
        int N = sc.nextInt();
        int Q = sc.nextInt();
        String str = sc.next();
        int len = str.length();
//        long start = System.currentTimeMillis();
        char[] s = ("_" + str).toCharArray();
        int[][] next = new int[26][len + 1];
        for (int ch = 0; ch < 26; ch++) {
            next[ch][len] = oo;
        }
        for (int pos = len - 1; pos >= 0; pos--) {
            for (int ch = 0; ch < 26; ch++) {
                if (s[pos + 1] - 'a' == ch) {
                    next[ch][pos] = pos + 1;
                } else {
                    next[ch][pos] = next[ch][pos + 1];
                }
            }
        }
        int[][][] dp = new int[251][251][251];
        for (int i = 0; i <= 250; i++) {
            for (int j = 0; j <= 250; j++) {
                Arrays.fill(dp[i][j], oo);
            }
        }
        dp[0][0][0] = 0;
        int[] sizes = new int[3];
        ArrayList<Character>[] patterns = new ArrayList[3];
        Arrays.setAll(patterns, i -> new ArrayList<>());
        for (int i = 0; i < 3; i++) {
            patterns[i].add('_');
        }
        while (Q-->0) {
            String type = sc.next();
            int which = sc.nextInt() - 1;
            if (type.charAt(0) == '+') {
                sizes[which]++;
                char c = sc.next().charAt(0);
                patterns[which].add(c);
                int[] lo = new int[3];
                int[] hi = new int[3];
                for (int l = 0; l < 3; l++) {
                    hi[l] = sizes[l];
                }
                lo[which] = sizes[which];// woopsies, commented while testing XD
                for (int i = lo[0]; i <= hi[0]; i++) {
                    for (int j = lo[1]; j <= hi[1]; j++) {
                        for (int k = lo[2]; k <= hi[2]; k++) {
                            if (i != 0 || j != 0 || k != 0) {
                                dp[i][j][k] = oo; // CURRENTLY, WE DON'T KNOW WHETHER IT'S POSSIBLE!!!
                            }
                            if (i > 0) {
                                int lastPos = dp[i - 1][j][k];
                                if (lastPos != oo) {
                                    int ch = patterns[0].get(i) - 'a';
                                    dp[i][j][k] = Math.min(dp[i][j][k], next[ch][lastPos]);
                                }
                            }
                            if (j > 0) {
                                int lastPos = dp[i][j - 1][k];
                                if (lastPos != oo) {
                                    int ch = patterns[1].get(j) - 'a';
                                    dp[i][j][k] = Math.min(dp[i][j][k], next[ch][lastPos]);
                                }
                            }
                            if (k > 0) {
                                int lastPos = dp[i][j][k - 1];
                                if (lastPos != oo) {
                                    int ch = patterns[2].get(k) - 'a';
                                    dp[i][j][k] = Math.min(dp[i][j][k], next[ch][lastPos]);
                                }
                            }
                        }
                    }
                }
            } else {
                sizes[which]--;
                // this might be it?
                patterns[which].remove(patterns[which].size() - 1);
            }
//            System.out.println(Arrays.toString(patterns));
//            for (int i = 0; i <= sizes[0]; i++) {
//                System.out.println("i = " + i);
//                for (int j = 0; j <= sizes[1]; j++) {
//                    for (int k = 0; k <= sizes[2]; k++) {
//                        System.out.print(dp[i][j][k] + " " );
//                    }
//                    System.out.println();
//                }
//            }
//            System.out.println(Arrays.toString(sizes));
//            System.out.println(Arrays.toString(patterns));
            out.println(dp[sizes[0]][sizes[1]][sizes[2]] != oo ? "YES" : "NO");
        }
        out.close();
//        System.out.println((System.currentTimeMillis() - start) / 1000.0);
    }

    static int oo = (int) 1e6;

    static void generate() {
        int N = 10000;
        int Q = 1000;
        String s = "";
        String gen = "abcdefghijklmnopqrstuvwxyz";
        for (int i = 0; i < N; i++) {
            int p = new Random().nextInt(26);
            s = s.concat("" + gen.charAt(p));
        }
        System.out.println(N + " " + Q);
        System.out.println(s);
        int[] added = new int[3];
        for (int i = 0; i < Q; i++) {
            int which = 1 + new Random().nextInt(3);
            if (Math.random() < 0.5 || added[which - 1] <= 0) {
                int p = new Random().nextInt(26);
                System.out.println("+ " + which + " " + gen.charAt(p));
                added[which - 1]++;
            } else {
                added[which - 1]--;
                System.out.println("- " + which);
            }
        }
    }
    static class FastScanner {
        private int BS = 1 << 16;
        private char NC = (char) 0;
        private byte[] buf = new byte[BS];
        private int bId = 0, size = 0;
        private char c = NC;
        private double cnt = 1;
        private BufferedInputStream in;

        public FastScanner() {
            in = new BufferedInputStream(System.in, BS);
        }

        public FastScanner(String s) {
            try {
                in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
            } catch (Exception e) {
                in = new BufferedInputStream(System.in, BS);
            }
        }

        private char getChar() {
            while (bId == size) {
                try {
                    size = in.read(buf);
                } catch (Exception e) {
                    return NC;
                }
                if (size == -1) return NC;
                bId = 0;
            }
            return (char) buf[bId++];
        }

        public int nextInt() {
            return (int) nextLong();
        }

        public int[] nextInts(int N) {
            int[] res = new int[N];
            for (int i = 0; i < N; i++) {
                res[i] = (int) nextLong();
            }
            return res;
        }

        public long[] nextLongs(int N) {
            long[] res = new long[N];
            for (int i = 0; i < N; i++) {
                res[i] = nextLong();
            }
            return res;
        }

        public long nextLong() {
            cnt = 1;
            boolean neg = false;
            if (c == NC) c = getChar();
            for (; (c < '0' || c > '9'); c = getChar()) {
                if (c == '-') neg = true;
            }
            long res = 0;
            for (; c >= '0' && c <= '9'; c = getChar()) {
                res = (res << 3) + (res << 1) + c - '0';
                cnt *= 10;
            }
            return neg ? -res : res;
        }

        public double nextDouble() {
            double cur = nextLong();
            return c != '.' ? cur : cur + nextLong() / cnt;
        }

        public double[] nextDoubles(int N) {
            double[] res = new double[N];
            for (int i = 0; i < N; i++) {
                res[i] = nextDouble();
            }
            return res;
        }

        public String next() {
            StringBuilder res = new StringBuilder();
            while (c <= 32) c = getChar();
            while (c > 32) {
                res.append(c);
                c = getChar();
            }
            return res.toString();
        }

        public String nextLine() {
            StringBuilder res = new StringBuilder();
            while (c <= 32) c = getChar();
            while (c != '\n') {
                res.append(c);
                c = getChar();
            }
            return res.toString();
        }

        public boolean hasNext() {
            if (c > 32) return true;
            while (true) {
                c = getChar();
                if (c == NC) return false;
                else if (c > 32) return true;
            }
        }
    }

    static void ASSERT(boolean assertion, String message) {
        if (!assertion) throw new AssertionError(message);
    }

    static void ASSERT(boolean assertion) {
        if (!assertion) throw new AssertionError();
    }
}


/**
 * @author derrick20
 */
import java.io.*;
import java.util.*;

public class ThreeReligions implements Runnable {
    public static void main(String[] args) throws Exception {
        new Thread(null, new ThreeReligions(), ": )", 1 << 28).start();
    }

    public void run() {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

//        generate();
        int N = sc.nextInt();
        int Q = sc.nextInt();
        String str = sc.next();
        int len = str.length();
//        long start = System.currentTimeMillis();
        char[] s = "_".concat(str).toCharArray();
        oo = len + 1;
        int[][] next = new int[26][len + 1];
        for (int ch = 0; ch < 26; ch++) {
            next[ch][len] = oo;
        }
        for (int pos = len - 1; pos >= 0; pos--) {
            for (int ch = 0; ch < 26; ch++) {
                if (s[pos + 1] - 'a' == ch) {
                    next[ch][pos] = pos + 1;
                } else {
                    next[ch][pos] = next[ch][pos + 1];
                }
            }
        }
        int[][][] dp = new int[251][251][251];
        for (int i = 0; i <= 250; i++) {
            for (int j = 0; j <= 250; j++) {
                Arrays.fill(dp[i][j], oo);
            }
        }
        dp[0][0][0] = 0;
        int[] sizes = new int[3];
        ArrayList<Character>[] patterns = new ArrayList[3];
        Arrays.setAll(patterns, i -> new ArrayList<>());
        for (int i = 0; i < 3; i++) {
            patterns[i].add('_');
        }
        while (Q-->0) {
            String type = sc.next();
            int which = sc.nextInt() - 1;
            if (type.charAt(0) == '+') {
                sizes[which]++;
                char c = sc.next().charAt(0);
                patterns[which].add(c);
                int[] lo = new int[3];
                int[] hi = new int[3];
                for (int l = 0; l < 3; l++) {
                    hi[l] = sizes[l];
                }
                lo[which] = sizes[which];// woopsies, commented while testing XD
                for (int i = lo[0]; i <= hi[0]; i++) {
                    for (int j = lo[1]; j <= hi[1]; j++) {
                        for (int k = lo[2]; k <= hi[2]; k++) {
                            if (i != 0 || j != 0 || k != 0) {
                                dp[i][j][k] = oo; // CURRENTLY, WE DON'T KNOW WHETHER IT'S POSSIBLE!!!
                            }
                            if (i > 0) {
                                int lastPos = dp[i - 1][j][k];
                                if (lastPos != oo) {
                                    int ch = patterns[0].get(i) - 'a';
                                    dp[i][j][k] = Math.min(dp[i][j][k], next[ch][lastPos]);
                                }
                            }
                            if (j > 0) {
                                int lastPos = dp[i][j - 1][k];
                                if (lastPos != oo) {
                                    int ch = patterns[1].get(j) - 'a';
                                    dp[i][j][k] = Math.min(dp[i][j][k], next[ch][lastPos]);
                                }
                            }
                            if (k > 0) {
                                int lastPos = dp[i][j][k - 1];
                                if (lastPos != oo) {
                                    int ch = patterns[2].get(k) - 'a';
                                    dp[i][j][k] = Math.min(dp[i][j][k], next[ch][lastPos]);
                                }
                            }
                        }
                    }
                }
            } else {
                sizes[which]--;
                // this might be it?
                patterns[which].remove(patterns[which].size() - 1);
            }
//            System.out.println(Arrays.toString(patterns));
//            for (int i = 0; i <= sizes[0]; i++) {
//                System.out.println("i = " + i);
//                for (int j = 0; j <= sizes[1]; j++) {
//                    for (int k = 0; k <= sizes[2]; k++) {
//                        System.out.print(dp[i][j][k] + " " );
//                    }
//                    System.out.println();
//                }
//            }
//            System.out.println(Arrays.toString(sizes));
//            System.out.println(Arrays.toString(patterns));
            out.println(dp[sizes[0]][sizes[1]][sizes[2]] != oo ? "YES" : "NO");
        }
        out.close();
//        System.out.println((System.currentTimeMillis() - start) / 1000.0);
    }

    static int oo;// = (int) 1e6;

    static void generate() {
        int N = 10000;
        int Q = 1000;
        String s = "";
        String gen = "abcdefghijklmnopqrstuvwxyz";
        for (int i = 0; i < N; i++) {
            int p = new Random().nextInt(26);
            s = s.concat("" + gen.charAt(p));
        }
        System.out.println(N + " " + Q);
        System.out.println(s);
        int[] added = new int[3];
        for (int i = 0; i < Q; i++) {
            int which = 1 + new Random().nextInt(3);
            if (Math.random() < 0.5 || added[which - 1] <= 0) {
                int p = new Random().nextInt(26);
                System.out.println("+ " + which + " " + gen.charAt(p));
                added[which - 1]++;
            } else {
                added[which - 1]--;
                System.out.println("- " + which);
            }
        }
    }
    static class FastScanner {
        private int BS = 1 << 16;
        private char NC = (char) 0;
        private byte[] buf = new byte[BS];
        private int bId = 0, size = 0;
        private char c = NC;
        private double cnt = 1;
        private BufferedInputStream in;

        public FastScanner() {
            in = new BufferedInputStream(System.in, BS);
        }

        public FastScanner(String s) {
            try {
                in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
            } catch (Exception e) {
                in = new BufferedInputStream(System.in, BS);
            }
        }

        private char getChar() {
            while (bId == size) {
                try {
                    size = in.read(buf);
                } catch (Exception e) {
                    return NC;
                }
                if (size == -1) return NC;
                bId = 0;
            }
            return (char) buf[bId++];
        }

        public int nextInt() {
            return (int) nextLong();
        }

        public int[] nextInts(int N) {
            int[] res = new int[N];
            for (int i = 0; i < N; i++) {
                res[i] = (int) nextLong();
            }
            return res;
        }

        public long[] nextLongs(int N) {
            long[] res = new long[N];
            for (int i = 0; i < N; i++) {
                res[i] = nextLong();
            }
            return res;
        }

        public long nextLong() {
            cnt = 1;
            boolean neg = false;
            if (c == NC) c = getChar();
            for (; (c < '0' || c > '9'); c = getChar()) {
                if (c == '-') neg = true;
            }
            long res = 0;
            for (; c >= '0' && c <= '9'; c = getChar()) {
                res = (res << 3) + (res << 1) + c - '0';
                cnt *= 10;
            }
            return neg ? -res : res;
        }

        public double nextDouble() {
            double cur = nextLong();
            return c != '.' ? cur : cur + nextLong() / cnt;
        }

        public double[] nextDoubles(int N) {
            double[] res = new double[N];
            for (int i = 0; i < N; i++) {
                res[i] = nextDouble();
            }
            return res;
        }

        public String next() {
            StringBuilder res = new StringBuilder();
            while (c <= 32) c = getChar();
            while (c > 32) {
                res.append(c);
                c = getChar();
            }
            return res.toString();
        }

        public String nextLine() {
            StringBuilder res = new StringBuilder();
            while (c <= 32) c = getChar();
            while (c != '\n') {
                res.append(c);
                c = getChar();
            }
            return res.toString();
        }

        public boolean hasNext() {
            if (c > 32) return true;
            while (true) {
                c = getChar();
                if (c == NC) return false;
                else if (c > 32) return true;
            }
        }
    }

    static void ASSERT(boolean assertion, String message) {
        if (!assertion) throw new AssertionError(message);
    }

    static void ASSERT(boolean assertion) {
        if (!assertion) throw new AssertionError();
    }
}


/**
 * @author derrick20
 */
import java.io.*;
import java.util.*;

public class ThreeReligions implements Runnable {
    public static void main(String[] args) throws Exception {
        new Thread(null, new ThreeReligions(), ": )", 1 << 28).start();
    }

    public void run() {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

//        generate();
        int N = sc.nextInt();
        int Q = sc.nextInt();
        String str = sc.next();
        int len = str.length();
        char[] s = "_".concat(str).toCharArray();
        int[][] next = new int[26][len + 1];
        for (int ch = 0; ch < 26; ch++) {
            next[ch][len] = oo;
        }
        for (int pos = len - 1; pos >= 0; pos--) {
            for (int ch = 0; ch < 26; ch++) {
                if (s[pos + 1] - 'a' == ch) {
                    next[ch][pos] = pos + 1;
                } else {
                    next[ch][pos] = next[ch][pos + 1];
                }
            }
        }
        int[][][] dp = new int[251][251][251];
        for (int i = 0; i <= 250; i++) {
            for (int j = 0; j <= 250; j++) {
                Arrays.fill(dp[i][j], oo);
            }
        }
        dp[0][0][0] = 0;
        int[] sizes = new int[3];
        ArrayList<Character>[] patterns = new ArrayList[3];
        Arrays.setAll(patterns, i -> new ArrayList<>());
        for (int i = 0; i < 3; i++) {
            patterns[i].add('_');
        }
        while (Q-->0) {
            String type = sc.next();
            int which = sc.nextInt() - 1;
            if (type.equals("+")) {
                sizes[which]++;
                char c = sc.next().charAt(0);
                patterns[which].add(c);
                int[] lo = new int[3];
                int[] hi = new int[3];
                for (int l = 0; l < 3; l++) {
                    hi[l] = sizes[l];
                }
                lo[which] = sizes[which];
                for (int i = lo[0]; i <= hi[0]; i++) {
                    for (int j = lo[1]; j <= hi[1]; j++) {
                        for (int k = lo[2]; k <= hi[2]; k++) {
                            if (i > 0) {
                                int lastPos = dp[i - 1][j][k];
                                if (lastPos != oo) {
                                    int ch = patterns[0].get(i) - 'a';
                                    dp[i][j][k] = Math.min(dp[i][j][k], next[ch][lastPos]);
                                }
                            }
                            if (j > 0) {
                                int lastPos = dp[i][j - 1][k];
                                if (lastPos != oo) {
                                    int ch = patterns[1].get(j) - 'a';
                                    dp[i][j][k] = Math.min(dp[i][j][k], next[ch][lastPos]);
                                }
                            }
                            if (k > 0) {
                                int lastPos = dp[i][j][k - 1];
                                if (lastPos != oo) {
                                    int ch = patterns[2].get(k) - 'a';
                                    dp[i][j][k] = Math.min(dp[i][j][k], next[ch][lastPos]);
                                }
                            }
                        }
                    }
                }
            } else {
                sizes[which]--;
                // this might be it?
                patterns[which].remove(patterns[which].size() - 1);
            }
//            System.out.println(Arrays.toString(patterns));
//            for (int i = 0; i <= sizes[0]; i++) {
//                System.out.println("i = " + i);
//                for (int j = 0; j <= sizes[1]; j++) {
//                    for (int k = 0; k <= sizes[2]; k++) {
//                        System.out.print(dp[i][j][k] + " " );
//                    }
//                    System.out.println();
//                }
//            }
//            System.out.println(Arrays.toString(sizes));
//            System.out.println(Arrays.toString(patterns));
            out.println(dp[sizes[0]][sizes[1]][sizes[2]] != oo ? "YES" : "NO");
        }
        out.close();
    }

    static int oo = (int) 1e6;

    static void generate() {
        int N = 100;
        int Q = 120;
        String s = "";
        String gen = "abcdefghijklmnopqrstuvwxyz";
        for (int i = 0; i < N; i++) {
            int p = new Random().nextInt(26);
            s = s.concat("" + gen.charAt(p));
        }
        System.out.println(N + " " + Q);
        System.out.println(s);
        int[] added = new int[3];
        for (int i = 0; i < Q; i++) {
            int which = 1 + new Random().nextInt(3);
            if (Math.random() < 0.5 || added[which - 1] <= 0) {
                int p = new Random().nextInt(26);
                System.out.println("+ " + which + " " + gen.charAt(p));
                added[which - 1]++;
            } else {
                added[which - 1]--;
                System.out.println("- " + which);
            }
        }
    }
    static class FastScanner {
        private int BS = 1 << 16;
        private char NC = (char) 0;
        private byte[] buf = new byte[BS];
        private int bId = 0, size = 0;
        private char c = NC;
        private double cnt = 1;
        private BufferedInputStream in;

        public FastScanner() {
            in = new BufferedInputStream(System.in, BS);
        }

        public FastScanner(String s) {
            try {
                in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
            } catch (Exception e) {
                in = new BufferedInputStream(System.in, BS);
            }
        }

        private char getChar() {
            while (bId == size) {
                try {
                    size = in.read(buf);
                } catch (Exception e) {
                    return NC;
                }
                if (size == -1) return NC;
                bId = 0;
            }
            return (char) buf[bId++];
        }

        public int nextInt() {
            return (int) nextLong();
        }

        public int[] nextInts(int N) {
            int[] res = new int[N];
            for (int i = 0; i < N; i++) {
                res[i] = (int) nextLong();
            }
            return res;
        }

        public long[] nextLongs(int N) {
            long[] res = new long[N];
            for (int i = 0; i < N; i++) {
                res[i] = nextLong();
            }
            return res;
        }

        public long nextLong() {
            cnt = 1;
            boolean neg = false;
            if (c == NC) c = getChar();
            for (; (c < '0' || c > '9'); c = getChar()) {
                if (c == '-') neg = true;
            }
            long res = 0;
            for (; c >= '0' && c <= '9'; c = getChar()) {
                res = (res << 3) + (res << 1) + c - '0';
                cnt *= 10;
            }
            return neg ? -res : res;
        }

        public double nextDouble() {
            double cur = nextLong();
            return c != '.' ? cur : cur + nextLong() / cnt;
        }

        public double[] nextDoubles(int N) {
            double[] res = new double[N];
            for (int i = 0; i < N; i++) {
                res[i] = nextDouble();
            }
            return res;
        }

        public String next() {
            StringBuilder res = new StringBuilder();
            while (c <= 32) c = getChar();
            while (c > 32) {
                res.append(c);
                c = getChar();
            }
            return res.toString();
        }

        public String nextLine() {
            StringBuilder res = new StringBuilder();
            while (c <= 32) c = getChar();
            while (c != '\n') {
                res.append(c);
                c = getChar();
            }
            return res.toString();
        }

        public boolean hasNext() {
            if (c > 32) return true;
            while (true) {
                c = getChar();
                if (c == NC) return false;
                else if (c > 32) return true;
            }
        }
    }

    static void ASSERT(boolean assertion, String message) {
        if (!assertion) throw new AssertionError(message);
    }

    static void ASSERT(boolean assertion) {
        if (!assertion) throw new AssertionError();
    }
}


/**
 * @author derrick20
 */
import java.io.*;
import java.util.*;

public class ThreeReligions implements Runnable {
    public static void main(String[] args) throws Exception {
        new Thread(null, new ThreeReligions(), ": )", 1 << 28).start();
    }

    public void run() {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

//        generate();
        int N = sc.nextInt();
        int Q = sc.nextInt();
        String str = sc.next();
        int len = str.length();
//        long start = System.currentTimeMillis();
        char[] s = "_".concat(str).toCharArray();
        int[][] next = new int[26][len + 1];
        for (int ch = 0; ch < 26; ch++) {
            next[ch][len] = oo;
        }
        for (int pos = len - 1; pos >= 0; pos--) {
            for (int ch = 0; ch < 26; ch++) {
                if (s[pos + 1] - 'a' == ch) {
                    next[ch][pos] = pos + 1;
                } else {
                    next[ch][pos] = next[ch][pos + 1];
                }
            }
        }
        int[][][] dp = new int[251][251][251];
        for (int i = 0; i <= 250; i++) {
            for (int j = 0; j <= 250; j++) {
                Arrays.fill(dp[i][j], oo);
            }
        }
        dp[0][0][0] = 0;
        int[] sizes = new int[3];
        ArrayList<Character>[] patterns = new ArrayList[3];
        Arrays.setAll(patterns, i -> new ArrayList<>());
        for (int i = 0; i < 3; i++) {
            patterns[i].add('_');
        }
        while (Q-->0) {
            String type = sc.next();
            int which = sc.nextInt() - 1;
            if (type.charAt(0) == '+') {
                sizes[which]++;
                char c = sc.next().charAt(0);
                patterns[which].add(c);
                int[] lo = new int[3];
                int[] hi = new int[3];
                for (int l = 0; l < 3; l++) {
                    hi[l] = sizes[l];
                }
                int work = 1;
                for (int i = 0; i < 3; i++) {
                    work *= (hi[i] - lo[i] + 1);
                }
                ASSERT(work <= 251 * 251); // :/
//                lo[which] = sizes[which];
                for (int i = lo[0]; i <= hi[0]; i++) {
                    for (int j = lo[1]; j <= hi[1]; j++) {
                        for (int k = lo[2]; k <= hi[2]; k++) {
                            if (i != 0 || j != 0 || k != 0) {
                                dp[i][j][k] = oo; // CURRENTLY, WE DON'T KNOW WHETHER IT'S POSSIBLE!!!
                            }
                            if (i > 0) {
                                int lastPos = dp[i - 1][j][k];
                                if (lastPos != oo) {
                                    int ch = patterns[0].get(i) - 'a';
                                    dp[i][j][k] = Math.min(dp[i][j][k], next[ch][lastPos]);
                                }
                            }
                            if (j > 0) {
                                int lastPos = dp[i][j - 1][k];
                                if (lastPos != oo) {
                                    int ch = patterns[1].get(j) - 'a';
                                    dp[i][j][k] = Math.min(dp[i][j][k], next[ch][lastPos]);
                                }
                            }
                            if (k > 0) {
                                int lastPos = dp[i][j][k - 1];
                                if (lastPos != oo) {
                                    int ch = patterns[2].get(k) - 'a';
                                    dp[i][j][k] = Math.min(dp[i][j][k], next[ch][lastPos]);
                                }
                            }
                        }
                    }
                }
            } else {
                sizes[which]--;
                // this might be it?
                patterns[which].remove(patterns[which].size() - 1);
            }
//            System.out.println(Arrays.toString(patterns));
//            for (int i = 0; i <= sizes[0]; i++) {
//                System.out.println("i = " + i);
//                for (int j = 0; j <= sizes[1]; j++) {
//                    for (int k = 0; k <= sizes[2]; k++) {
//                        System.out.print(dp[i][j][k] + " " );
//                    }
//                    System.out.println();
//                }
//            }
//            System.out.println(Arrays.toString(sizes));
//            System.out.println(Arrays.toString(patterns));
            out.println(dp[sizes[0]][sizes[1]][sizes[2]] != oo ? "YES" : "NO");
        }
        out.close();
//        System.out.println((System.currentTimeMillis() - start) / 1000.0);
    }

    static int oo = (int) 1e6;

    static void generate() {
        int N = 10000;
        int Q = 1000;
        String s = "";
        String gen = "abcdefghijklmnopqrstuvwxyz";
        for (int i = 0; i < N; i++) {
            int p = new Random().nextInt(26);
            s = s.concat("" + gen.charAt(p));
        }
        System.out.println(N + " " + Q);
        System.out.println(s);
        int[] added = new int[3];
        for (int i = 0; i < Q; i++) {
            int which = 1 + new Random().nextInt(3);
            if (Math.random() < 0.5 || added[which - 1] <= 0) {
                int p = new Random().nextInt(26);
                System.out.println("+ " + which + " " + gen.charAt(p));
                added[which - 1]++;
            } else {
                added[which - 1]--;
                System.out.println("- " + which);
            }
        }
    }
    static class FastScanner {
        private int BS = 1 << 16;
        private char NC = (char) 0;
        private byte[] buf = new byte[BS];
        private int bId = 0, size = 0;
        private char c = NC;
        private double cnt = 1;
        private BufferedInputStream in;

        public FastScanner() {
            in = new BufferedInputStream(System.in, BS);
        }

        public FastScanner(String s) {
            try {
                in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
            } catch (Exception e) {
                in = new BufferedInputStream(System.in, BS);
            }
        }

        private char getChar() {
            while (bId == size) {
                try {
                    size = in.read(buf);
                } catch (Exception e) {
                    return NC;
                }
                if (size == -1) return NC;
                bId = 0;
            }
            return (char) buf[bId++];
        }

        public int nextInt() {
            return (int) nextLong();
        }

        public int[] nextInts(int N) {
            int[] res = new int[N];
            for (int i = 0; i < N; i++) {
                res[i] = (int) nextLong();
            }
            return res;
        }

        public long[] nextLongs(int N) {
            long[] res = new long[N];
            for (int i = 0; i < N; i++) {
                res[i] = nextLong();
            }
            return res;
        }

        public long nextLong() {
            cnt = 1;
            boolean neg = false;
            if (c == NC) c = getChar();
            for (; (c < '0' || c > '9'); c = getChar()) {
                if (c == '-') neg = true;
            }
            long res = 0;
            for (; c >= '0' && c <= '9'; c = getChar()) {
                res = (res << 3) + (res << 1) + c - '0';
                cnt *= 10;
            }
            return neg ? -res : res;
        }

        public double nextDouble() {
            double cur = nextLong();
            return c != '.' ? cur : cur + nextLong() / cnt;
        }

        public double[] nextDoubles(int N) {
            double[] res = new double[N];
            for (int i = 0; i < N; i++) {
                res[i] = nextDouble();
            }
            return res;
        }

        public String next() {
            StringBuilder res = new StringBuilder();
            while (c <= 32) c = getChar();
            while (c > 32) {
                res.append(c);
                c = getChar();
            }
            return res.toString();
        }

        public String nextLine() {
            StringBuilder res = new StringBuilder();
            while (c <= 32) c = getChar();
            while (c != '\n') {
                res.append(c);
                c = getChar();
            }
            return res.toString();
        }

        public boolean hasNext() {
            if (c > 32) return true;
            while (true) {
                c = getChar();
                if (c == NC) return false;
                else if (c > 32) return true;
            }
        }
    }

    static void ASSERT(boolean assertion, String message) {
        if (!assertion) throw new AssertionError(message);
    }

    static void ASSERT(boolean assertion) {
        if (!assertion) throw new AssertionError();
    }
}


/**
 * @author derrick20
 */
import java.io.*;
import java.util.*;

public class ThreeReligions implements Runnable {
    public static void main(String[] args) throws Exception {
        new Thread(null, new ThreeReligions(), ": )", 1 << 28).start();
    }

    public void run() {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

//        generate();
        int N = sc.nextInt();
        int Q = sc.nextInt();
        String str = sc.next();
        int len = str.length();
        char[] s = "_".concat(str).toCharArray();
        int[][] next = new int[26][len + 1];
        for (int ch = 0; ch < 26; ch++) {
            next[ch][len] = oo;
        }
        for (int pos = len - 1; pos >= 0; pos--) {
            for (int ch = 0; ch < 26; ch++) {
                if (s[pos + 1] - 'a' == ch) {
                    next[ch][pos] = pos + 1;
                } else {
                    next[ch][pos] = next[ch][pos + 1];
                }
            }
        }
        int[][][] dp = new int[251][251][251];
        for (int i = 0; i <= 250; i++) {
            for (int j = 0; j <= 250; j++) {
                Arrays.fill(dp[i][j], oo);
            }
        }
        dp[0][0][0] = 0;
        int[] sizes = new int[3];
        ArrayList<Character>[] patterns = new ArrayList[3];
        Arrays.setAll(patterns, i -> new ArrayList<>());
        for (int i = 0; i < 3; i++) {
            patterns[i].add('_');
        }
        while (Q-->0) {
            String type = sc.next();
            int which = sc.nextInt() - 1;
            if (type.equals("+")) {
                sizes[which]++;
                char c = sc.next().charAt(0);
                patterns[which].add(c);
                int[] lo = new int[3];
                int[] hi = new int[3];
                for (int l = 0; l < 3; l++) {
                    hi[l] = sizes[l];
                }
//                lo[which] = sizes[which];
                for (int i = lo[0]; i <= hi[0]; i++) {
                    for (int j = lo[1]; j <= hi[1]; j++) {
                        for (int k = lo[2]; k <= hi[2]; k++) {
                            if (i != 0 || j != 0 || k != 0) {
                                dp[i][j][k] = oo; // CURRENTLY, WE DON'T KNOW WHETHER IT'S POSSIBLE!!!
                            }
                            if (i > 0) {
                                int lastPos = dp[i - 1][j][k];
                                if (lastPos != oo) {
                                    int ch = patterns[0].get(i) - 'a';
                                    dp[i][j][k] = Math.min(dp[i][j][k], next[ch][lastPos]);
                                }
                            }
                            if (j > 0) {
                                int lastPos = dp[i][j - 1][k];
                                if (lastPos != oo) {
                                    int ch = patterns[1].get(j) - 'a';
                                    dp[i][j][k] = Math.min(dp[i][j][k], next[ch][lastPos]);
                                }
                            }
                            if (k > 0) {
                                int lastPos = dp[i][j][k - 1];
                                if (lastPos != oo) {
                                    int ch = patterns[2].get(k) - 'a';
                                    dp[i][j][k] = Math.min(dp[i][j][k], next[ch][lastPos]);
                                }
                            }
                        }
                    }
                }
            } else {
                sizes[which]--;
                // this might be it?
                patterns[which].remove(patterns[which].size() - 1);
            }
//            System.out.println(Arrays.toString(patterns));
//            for (int i = 0; i <= sizes[0]; i++) {
//                System.out.println("i = " + i);
//                for (int j = 0; j <= sizes[1]; j++) {
//                    for (int k = 0; k <= sizes[2]; k++) {
//                        System.out.print(dp[i][j][k] + " " );
//                    }
//                    System.out.println();
//                }
//            }
//            System.out.println(Arrays.toString(sizes));
//            System.out.println(Arrays.toString(patterns));
            out.println(dp[sizes[0]][sizes[1]][sizes[2]] != oo ? "YES" : "NO");
        }
        out.close();
    }

    static int oo = (int) 1e6;

    static void generate() {
        int N = 100;
        int Q = 120;
        String s = "";
        String gen = "abcdefghijklmnopqrstuvwxyz";
        for (int i = 0; i < N; i++) {
            int p = new Random().nextInt(26);
            s = s.concat("" + gen.charAt(p));
        }
        System.out.println(N + " " + Q);
        System.out.println(s);
        int[] added = new int[3];
        for (int i = 0; i < Q; i++) {
            int which = 1 + new Random().nextInt(3);
            if (Math.random() < 0.5 || added[which - 1] <= 0) {
                int p = new Random().nextInt(26);
                System.out.println("+ " + which + " " + gen.charAt(p));
                added[which - 1]++;
            } else {
                added[which - 1]--;
                System.out.println("- " + which);
            }
        }
    }
    static class FastScanner {
        private int BS = 1 << 16;
        private char NC = (char) 0;
        private byte[] buf = new byte[BS];
        private int bId = 0, size = 0;
        private char c = NC;
        private double cnt = 1;
        private BufferedInputStream in;

        public FastScanner() {
            in = new BufferedInputStream(System.in, BS);
        }

        public FastScanner(String s) {
            try {
                in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
            } catch (Exception e) {
                in = new BufferedInputStream(System.in, BS);
            }
        }

        private char getChar() {
            while (bId == size) {
                try {
                    size = in.read(buf);
                } catch (Exception e) {
                    return NC;
                }
                if (size == -1) return NC;
                bId = 0;
            }
            return (char) buf[bId++];
        }

        public int nextInt() {
            return (int) nextLong();
        }

        public int[] nextInts(int N) {
            int[] res = new int[N];
            for (int i = 0; i < N; i++) {
                res[i] = (int) nextLong();
            }
            return res;
        }

        public long[] nextLongs(int N) {
            long[] res = new long[N];
            for (int i = 0; i < N; i++) {
                res[i] = nextLong();
            }
            return res;
        }

        public long nextLong() {
            cnt = 1;
            boolean neg = false;
            if (c == NC) c = getChar();
            for (; (c < '0' || c > '9'); c = getChar()) {
                if (c == '-') neg = true;
            }
            long res = 0;
            for (; c >= '0' && c <= '9'; c = getChar()) {
                res = (res << 3) + (res << 1) + c - '0';
                cnt *= 10;
            }
            return neg ? -res : res;
        }

        public double nextDouble() {
            double cur = nextLong();
            return c != '.' ? cur : cur + nextLong() / cnt;
        }

        public double[] nextDoubles(int N) {
            double[] res = new double[N];
            for (int i = 0; i < N; i++) {
                res[i] = nextDouble();
            }
            return res;
        }

        public String next() {
            StringBuilder res = new StringBuilder();
            while (c <= 32) c = getChar();
            while (c > 32) {
                res.append(c);
                c = getChar();
            }
            return res.toString();
        }

        public String nextLine() {
            StringBuilder res = new StringBuilder();
            while (c <= 32) c = getChar();
            while (c != '\n') {
                res.append(c);
                c = getChar();
            }
            return res.toString();
        }

        public boolean hasNext() {
            if (c > 32) return true;
            while (true) {
                c = getChar();
                if (c == NC) return false;
                else if (c > 32) return true;
            }
        }
    }

    static void ASSERT(boolean assertion, String message) {
        if (!assertion) throw new AssertionError(message);
    }

    static void ASSERT(boolean assertion) {
        if (!assertion) throw new AssertionError();
    }
}


from sys import stdin, stdout
s = stdin.readline()
n = len(s)
left = 0
right = n-1
vs = [0 for i in range(n)]
for i in range(n):
	if(s[i] == 'l'):
		vs[right] = i
		right -= 1
	else:
		vs[left] = i
		left += 1
for ele in vs:
	stdout.write("{}\n".format(ele+1))


from sys import stdin, stdout
s = input().strip()
n = len(s)
left = 0
right = n-1
vs = [0]*n
for i in range(n):
	if(s[i] == 'l'):
		vs[right] = str(i+1)
		right -= 1
	else:
		vs[left] = str(i+1)
		left += 1
for ele in vs:
	print(ele)


from sys import stdin, stdout
s = stdin.readline().strip()
n = len(s)
left = 0
right = n-1
vs = [0 for i in xrange(n)]
for i in xrange(n):
	if(s[i] == 'l'):
		vs[right] = i
		right -= 1
	else:
		vs[left] = i
		left += 1
for ele in vs:
	stdout.write("{}\n".format(ele+1))


a = input()
n = len(a)
sr=[]
sl=[]
for i in range(n):
    if a[i]=='r':
        sr.append(i+1)
    else:
        sl.append(i+1)
print(*(sr+sl[::-1]))


from decimal import *
getcontext().prec=15
s={}
start=0;end=1
n=1
s[Decimal(start+end)/Decimal(2)]=1
for i in input()[:-1]:
    n+=1
    if i=='l':
        start=start
        end=Decimal(start+end)/Decimal(2)
        s[Decimal(start+end)/Decimal(2)]=n

    else:
        start=Decimal(start+end)/Decimal(2)/2
        end=end
        s[Decimal(start+end)/Decimal(2)]=n
for i in sorted(s):
    print(s[i])


from decimal import *
getcontext().prec=100
s={}
start=0;end=1
n=1
s[Decimal(start+end)/Decimal(2)]=1
for i in input()[:-1]:
    n+=1
    if i=='l':
        start=start
        end=Decimal(start+end)/Decimal(2)
        s[Decimal(start+end)/Decimal(2)]=n

    else:
        start=Decimal(start+end)/Decimal(2)
        end=end
        s[Decimal(start+end)/Decimal(2)]=n
for i in sorted(s):
    print(s[i])


from decimal import *
getcontext().prec=int(10e6)
s={}
start=0;end=1
n=1
s[Decimal(start+end)/Decimal(2)]=1
for i in input()[:-1]:
    n+=1
    if i=='l':
        start=start
        end=Decimal(start+end)/Decimal(2)
        s[Decimal(start+end)/Decimal(2)]=n

    else:
        start=Decimal(start+end)/Decimal(2)
        end=end
        s[Decimal(start+end)/Decimal(2)]=n
for i in sorted(s):
    print(s[i])


from decimal import *
getcontext().prec=10
s={}
start=0;end=1
n=1
s[Decimal(start+end)/Decimal(2)]=1
for i in input()[:-1]:
    n+=1
    if i=='l':
        start=start
        end=Decimal(start+end)/Decimal(2)
        s[Decimal(start+end)/Decimal(2)]=n

    else:
        start=Decimal(start+end)/Decimal(2)
        end=end
        s[Decimal(start+end)/Decimal(2)]=n
for i in sorted(s):
    print(s[i])


s={}
start=0;end=1
n=1
s[(start+end)/2]=1
for i in input()[:-1]:
    n+=1
    if i=='l':
        start=start
        end=(start+end)/2
        s[(start+end)/2]=n

    else:
        start=(start+end)/2
        end=end
        s[(start+end)/2]=n
for i in sorted(s):
    print(s[i])


a = input()
n = len(a)
sr=''
sl=''
for i in range(n):
    if a[i]=='r':
        sr+=str(i+1)+' '
    else:
        sl+=str(i+1)+' '
print(sr[:-1]+sl[::-1])


s = input()
res = ''
for i in range(len(s)):
    if s[i] == 'r':
        res += str(i+1) + '\n'
for i in range(len(s)-1, -1, -1):
    if s[i] == 'l':
        res += str(i+1) + '\n'
print(res)


s = input()
res = []
for i in range(len(s)):
    if s[i] == 'r':
        res.append(str(i+1))
for i in range(len(s)-1, -1, -1):
    if s[i] == 'l':
        res.append(str(i+1))
print('\n'.join(res))


s=input()
l,r=0,1
ans={}
n=len(s)
for i in range(n):
    if s[i]=='l':
        mid=(l+r)/2
        ans[i]=mid
        r=mid
    else:
        mid=(l+r)/2
        ans[i]=mid
        l=mid
sorted_ans = sorted(ans.items(), key=lambda kv: kv[1])
for i in range(n):
    print(sorted_ans[i][0]+1)


s=input()
l,r=0,1
ans={}
n=len(s)
for i in range(n):
    if s[i]=='l':
        mid=((l+r)/2)
        ans[i]=mid*1000000
        r=mid
    else:
        mid=((l+r)/2)
        ans[i]=mid*1000000
        l=mid
sorted_ans = sorted(ans.items(), key=lambda kv: kv[1])
for i in range(n):
    print(sorted_ans[i][0]+1)


s=input()
l,r=[],[]
n=len(s)
for i in range(n):
    if s[i]=='l':
        l.append(i+1)
    else:
        r.append(i+1)
l=sorted(l,reverse=True)
r.extend(l)
for i in r:
    print(i)


s=input()
l,r=0,1000000
ans={}
n=len(s)
for i in range(n):
    if s[i]=='l':
        mid=(l+r)/2
        ans[i]=mid
        r=mid
    else:
        mid=(l+r)/2
        ans[i]=mid
        l=mid
sorted_ans = sorted(ans.items(), key=lambda kv: kv[1])
for i in range(n):
    print(sorted_ans[i][0]+1)


s=input()
l,r=0,1
ans={}
n=len(s)
for i in range(n):
    if s[i]=='l':
        mid=float((l+r)/2)
        ans[i]=mid
        r=mid
    else:
        mid=float((l+r)/2)
        ans[i]=mid
        l=mid
sorted_ans = sorted(ans.items(), key=lambda kv: kv[1])
for i in range(n):
    print(sorted_ans[i][0]+1)


s = input()
for i in range(len(s)):
    if s[i] == 'r':
        print(i+1)

i = len(s)-1
while i >= 0:
    if s[i] == 'l':
        print(i+1)
    i -= 1


from decimal import Decimal

s = input()
left,right = 0,1
stones = {}
count = 1
for i in s:
    if i == 'l':
        right = Decimal(left+right)/Decimal(2)
        stones[right] = count
    else:
        left = Decimal(left+right)/Decimal(2)
        stones[left] = count
    count += 1

key = list(stones.keys())
key.sort()
for i in key:
    print(stones[i])


s = input()
n = len(s)
l = []
r = []

for i in range(n):
    if s[i] == 'l':
        l.append(i + 1)
    else:
        r.append(i + 1)

#print(l)
#print(r)
l.reverse()
for i in r :
    print(i)

for i in l :
    print(i)


s = input()
left = []
right = []

for i in range(len(s)):
    if s[i] == "r":
        left.append(i + 1)
    else:
        right.append(i + 1)

for i in left:
    print(i)
for i in reversed(right):
    print(i)


n=input()
l=len(n)
ans=[0]*l
left=0
right=l-1
i=1
for i in range(l):
    if n[i]=='l':
        ans[right]=i+1
        right-=1
    else:
        ans[left]=i+1
        left+=1

for i in ans:
    print(i)


import heapq
n=input()
x=len(n)
v=2**(x+1)
h=[]
ref=0
j=1
for i in n:
    if i=='l':
        v//=2
        heapq.heappush(h,[ref+v+1,j])
    else:
        v//=2
        heapq.heappush(h,[ref+v-1,j])
        ref+=v
    j+=1
while h:
    print(heapq.heappop(h)[1])


import heapq
n=input()
x=len(n)
left=0
right=x+1
h=[]

j=1
for i in n:
    if i=='l':
        heapq.heappush(h,[right,j])
        right-=1
    else:
        heapq.heappush(h,[left,j])
        left+=1
    j+=1
while h:
    print(heapq.heappop(h)[1])


import heapq
n=input()
x=len(n)
left=0
right=n+1
h=[]

j=1
for i in n:
    if i=='l':
        heapq.heappush(h,[right,j])
        right-=1
    else:
        heapq.heappush(h,[left,j])
        left+=1
    j+=1
while h:
    print(heapq.heappop(h)[1])


import heapq
n=input()
x=len(n)
v=1<<(x+2)
h=[]
ref=0
j=1
for i in n:
    if i=='l':
        v=v>>1
        heapq.heappush(h,[ref+v+1,j])
    else:
        v=v>>1
        heapq.heappush(h,[ref+v-1,j])
        ref+=v
    j+=1
while h:
    print(heapq.heappop(h)[1])


s=input()
for i in range(len(s)):
    if s[i]=='r': print(i+1)
for i in range(len(s)-1,-1,-1):
    if s[i]=='l': print(i+1)


s = input()
l = [0] * len(s)
a = 0
b = len(s) - 1
for i in range(len(s)):
	if s[i] == 'l':
		l[b] = str(i + 1)
		b -= 1
	else:
		l[a] = str(i + 1)
		a += 1
print('\n'.join(l))


t = list(enumerate(input(), 1))
t.reverse()
p = []
for i, d in t:
    if d == 'r': p = [i] + p
    else: p.append(i)
print('\n'.join(map(str, p)))


t = input()
a, b = [i for i, d in enumerate(t, 1) if d == 'l'], [i for i, d in enumerate(t, 1) if d == 'r']
a.reverse()
print('\n'.join(map(str, b)))
print('\n'.join(map(str, a)))


s=input()
length=len(s)
l=[]
for i in range(length):
	if (s[i]=='r'):
		print(i+1)
	else:
		l.append(i+1);
length=len(l)-1
while(length>=0):
	print(l[length])
	length=length-1


a = input()
n = len(a)
sr=[]
sl=[]
for i in range(n):
    if a[i]=='r':
        sr.append(i+1)
    else:
        sl.append(i+1)
print(*(sr+sl[::-1]))


t = input()
print('\n'.join(map(str, [i for i, d in enumerate(t, 1) if d == 'r'])) + '\n' + '\n'.join(
    map(str, reversed([i for i, d in enumerate(t, 1) if d == 'l']))))


n = input()
length = len(n)
min,max,arr1,arr2 = 1,length,[],[]
for i in range(0,length):
    if n[i] == "l":
        arr2.append(i+1)
    else:
        arr1.append(i+1)

print('\n'.join(map(str, arr1)))
print('\n'.join(map(str, arr2[::-1])))


import sys
s=input()
a=[]
b=[]
for i in range(len(s)):
    if(s[i]=="l"):
        a.append(i+1)
    else:
        b.append(i+1)
c=b+a[::-1]
for i in c:
    print(i)


s = input()
a, b = 0, 1
p = []
for i in s:
    if i == 'l':
        p.append(b)
        b = (a+b)/2
    else:
        p.append(a)
        a = (a+b)/2
p = list(zip(p, range(1, len(s)+1)))
p.sort()
for i in p: print(i[1])


s = input()
a, b = [], []
for i, j in zip(s, range(1, len(s)+1)):
    if i == 'r': a.append(str(j))
    else: b.append(str(j))
print('\n'.join(a + b[::-1]))


s = input()
a, b = 0, len(s)-1
p = []
for i in s:
    if i == 'l':
        p.append(b)
        b = b-1
    else:
        p.append(a)
        a = a+1
p = list(zip(p, range(1, len(s)+1)))
p.sort()
for i in p: print(i[1])


a = input()
x = 1
l = []
r = []
for i in a:
    if i == 'l':
        l.append(x)
    else:
        r.append(x)
    x += 1
s = ''
for i in r:
    print(i)
for i in l[::-1]:
    print(i)


a = input()
x = 1
l = []
r = []
for i in a:
    if i == 'l':
        l.append(x)
    else:
        r.append(x)
    x += 1
s = ''
for i in r:
    s += str(i) + ' '
for i in l[::-1]:
    s += str(i) + ' '
print(s)


a = input()
x = 1
l = []
r = []
for i in a:
    if i == 'l':
        l.append(x)
    else:
        r.append(x)
    x += 1
for i in r:
    print(i, end = ' ')
for i in l[::-1]:
    print(i, end = ' ')


l, r = [], []
for i, c in enumerate(input()):
  if c == 'l':
    r += [str(i + 1)]
  else:
    l += [str(i + 1)]
r.reverse()
print('\n'.join(l + r))


l=0; r=1; dic={}; pos=1; sst=[]
s=input()
for item in s:
    hf=(l+r)/2
    dic[hf]=pos
    pos+=1
    if item=='l': r=hf
    else: l=hf
sst=sorted(dic.keys()); ans=""
for item in sst:
    ans+=f"{dic[item]}\n"
print(ans)


s=input(); ans=""
for i in range(len(s)):
    if s[i]=='r': ans+=f"{i+1}\n"
for i in range(len(s)-1,-1,-1):
    if s[i]=='l': ans+=f"{i+1}\n"
print(ans)


l=0; r=100000; dic={}; pos=1
s=input()
for item in s:
    hf=(l+r)/2
    dic.setdefault(hf,[])
    dic[hf].append(pos)
    pos+=1
    if item=='l': r=hf
    else: l=hf
sst=sorted(dic.keys()); ans=""
for item in sst:
    for value in dic[item]:
        ans+=f"{value}\n"
print(ans)


s=input()
for i in range(len(s)):
    if s[i]=='r': print(i+1)
for i in range(len(s)-1,-1,-1):
    if s[i]=='l': print(i+1)


directions = list(input())
left_side = 0
right_side = 1
points = []

for index, d in enumerate(directions):
    middle = (left_side + right_side) / 2
    points.append((index, middle))
    if d == 'l':
        right_side = middle
    else:
        left_side = middle

points = sorted(points, key=lambda x: x[1])

for p in points:
    print(p[0] + 1)


def main():
    l = [-1, 0, 6, 0, 6, 0, 1, 0, 3]
    liss = 6
    for i, c in enumerate(input()[:-1], 2):
        l.append(i)
        if c == 'l':
            l.append(l[-3])
            l.append(liss)
            liss += 3
            l[l[-5] + 2] = l[-5] = liss
        else:
            l.append(liss)
            l.append(l[-3])
            liss += 3
            l[l[-4] + 1] = l[-4] = liss
    liss, res = l[2], []
    while l[liss]:
        res.append(l[liss])
        liss = l[liss + 2]
    print(' '.join(map(str, res)))

if __name__ == '__main__':
    main()


s = input()
d = [c for c in s]
for i in range(len(d)):
    if d[i] == "r":
        print(i+1)
for i in range(len(d), -1, -1):
    if d[i] == "l":
        print(i+1)


s = input()
d = s.split()
a = 1
b = len(s)
for i in range(len(d)):
    if d[i] == "r":
        print(a)
        a+=1
for i in range(len(d)):
    if d[i] == "l":
        print(b)
        b-=1


s = input()
d = s.split()
a = 1
b = len(s)
for i in range(len(d)):
    if d[i] == "r":
        print(a)
        a+=1
    elif d[i] == "l":
        print(b)
        b-=1


s = input()
d = [c for c in s]
for i in range(len(d)):
    if d[i] == "r":
        print(i+1)
for i in range(len(d)-1, -1, -1):
    if d[i] == "l":
        print(i+1)


s = input()
d = [c for c in s]
a = 1
b = len(s)
for i in range(len(d)):
    if d[i] == "r":
        print(a)
        a+=1
for i in range(len(d)):
    if d[i] == "l":
        print(b)
        b-=1


inp = input()
length = len(inp)
min,max,dic1,dic2 = 1,length,[],[]
for i in range(0,length):
    if inp[i] == "l":
        dic2.append(i+1)
    else:
        dic1.append(i+1)

print('\n'.join(map(str, dic1)))
print('\n'.join(map(str, dic2[::-1])))


from collections import deque
s=deque(('l'+input())[:-1])
le = []
ri = []
n=0
while s:
    c = 0;ref = s[0]
    while s and s[0] == ref: c+=1;s.popleft()
    #print(ref,c)
    if ref=='l':
        for i in range(c-1):
            ri.append(n+i+1);
        le.append(n+c)
        n=n+c
    elif ref=='r':
        for i in range(c-1):
            le.append(n+i+1);
        ri.append(n+c)
        n=n+c
    #print(le,ri)
le.extend(ri[::-1])
print('\n'.join([str(i) for i in le]))


index = 0
s = gets.chomp
ans = Array.new
for i in 0...s.length
    if s[i] == 'r'
        puts i+1
    else
        ans.push(i+1)
    end
end
ans.reverse.each{|i| puts i}


index = 0
s = gets.chomp
ans = Array.new
for i in 0...s.length
    ans.insert(index,i+1)
    index += 1 if s[i]=='r'
end
ans.each{|i| puts i}


left = 0.0
right = 1.0
s = gets.chomp
ans = Hash.new
for i in 0...s.length
    tmp = (left+right)/2
    ans[tmp] = i+1
    if s[i] == 'l'
        right = tmp
    else
        left = tmp
    end
end
ans.sort.each{|i| puts i[1]}


stz = raw_input()
ri = []
le = []
i = 0
while i<len(stz):
	if stz[i] =='l':
		le.append(i+1)
	else:
		ri.append(i+1)
	i+=1
le.reverse()
for e in ri+le:
	print e


val = []
s = raw_input()
for i in range(len(s)):
	if s[i] == 'r':
		print i+1
	else:
		val.append (i+1)

for i in val.__reversed__():
	print i


s=raw_input()
for i in range(len(s)):
    if s[i]=='r':
       print i+1
for i in range(len(s)-1,-1,-1):
    if s[i]=='l':
       print i+1


s=raw_input()
a=[0.5]
pos=0.5
for i in xrange(len(s)-1):
    inc=1.0/2**(i+2)
    if s[i]=="l":
        pos-=inc
    if s[i]=="r":
        pos+=inc
    a.append(pos)
k=range(len(s))
k.sort(key=lambda x:a[x])
for i in k:
    print i+1


import os
line = raw_input()
cnt = 0
ll = []
for ch in line :
    cnt+=1
    if ch == 'r':
        print cnt
    else:
        ll.append(cnt)
for i in reversed(ll) :
    print i


s = raw_input()
begin, end = [], []
for i, c in enumerate(s):
    if c == 'l':
        end.append(i+1)
    else:
        begin.append(i+1)

for i in begin:
    print i
for i in reversed(end):
    print i


def g(s):
  h,t = [],[]
  f = {'l':t.append, 'r':h.append}
  for i,v in enumerate(s,1): f[v](i)
  t.reverse()
  for m in h,t:
    if m: print '\n'.join(`i` for i in m)

g(raw_input())


from collections import deque
d1 = deque()
d2 = deque()
s = raw_input().strip()
i = 1
for c in s:
	if c == 'l':
		d2.appendleft(i)
	else:
		d1.append(i)
	i += 1
for i in d1:
	print i
for i in d2:
	print i


#!/usr/bin/python2
# -*- coding: utf-8 -*-

import sys
import os

def main():
    s = sys.stdin.read().strip()
    head = []
    tail = []
    for i, c in enumerate(s, 1):
        if c == 'l':
            tail.append(i)
        elif c == 'r':
            head.append(i)
    for i in head:
        print i
    for i in reversed(tail):
        print i

if __name__ == '__main__':
    main()


s=raw_input()

x=lambda t: [`i` for i,e in enumerate(s,1) if e == t]

print '\n'.join(x('r')+x('l')[::-1])


s=list(raw_input())
n=len(s)
def go(i=0):
  if i<n:
    if 'l'==s[i]:
      go(i+1)
      print i+1
    else:
      print i+1
      go(i+1)
go()


s=list(raw_input())
n=len(s)
a=[0]*(n+n)
h,t=n,n
for i in range(n,0,-1):
  if 'l'==s[i-1]:
    a[t]=i
    t=t+1
  else:
    h=h-1
    a[h]=i
print '\n'.join(map(str,a[h:t]))


def main():
    s = raw_input()

    list_l,list_r = [],[]
    for i,v in enumerate(s):
        if v =='l': list_l.append(i+1)
        else:list_r.append(i+1)
    list_l.reverse()
    for x in list_r:
        print(x)
    for x in list_l:
        print(x)

main()