func_code_string: #include <bits/stdc++.h>   using namespace std;   const int block_size = 320;   const long long mod = 1e9 + 7;   const long long inf = 1e9 + 7;   const long double eps = 1e-9;   const double PI = atan(1) * 4;   template <typename T>   inline int sign(const T &a) {     if (a < 0) return -1;     if (a > 0) return 1;     return 0;   }   string to_string(string s) { return     + s +    ; }   string to_string(const char *s) { return to_string((string)s); }   string to_string(bool b) { return (b ?  true  :  false ); }   template <typename A, typename B>   string to_string(pair<A, B> p) {     return  (  + to_string(p.first) +  ,   + to_string(p.second) +  ) ;   }   template <typename A>   string to_string(A v) {     bool first = true;     string res =  { ;     for (const auto &x : v) {       if (!first) {         res +=  ,  ;       }       first = false;       res += to_string(x);     }     res +=  } ;     return res;   }   void debug_out() { cerr << endl; }   template <typename Head, typename... Tail>   void debug_out(Head H, Tail... T) {     cerr <<     << to_string(H);     debug_out(T...);   }   template <typename T, typename S>   inline bool upmin(T &a, const S &b) {     return a > b ? a = b, 1 : 0;   }   template <typename T, typename S>   inline bool upmax(T &a, const S &b) {     return a < b ? a = b, 1 : 0;   }   template <typename T>   inline void in(T &x) {     x = 0;     T f = 1;     char ch = getchar();     while (!isdigit(ch)) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (isdigit(ch)) {       x = x * 10 + ch -  0 ;       ch = getchar();     }     x *= f;   }   long long twop(int x) { return 1LL << x; }   template <typename A, typename B>   inline void in(A &x, B &y) {     in(x);     in(y);   }   template <typename A, typename B, typename C>   inline void in(A &x, B &y, C &z) {     in(x);     in(y);     in(z);   }   template <typename A, typename B, typename C, typename D>   inline void in(A &x, B &y, C &z, D &d) {     in(x);     in(y);     in(z);     in(d);   }   long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }   namespace SOLVE {   int n, q;   string s;   int nxt[100010][26];   int dp[255][255][255];   vector<int> word[3];   void solve(int i, int j, int k) {     dp[i][j][k] = inf;     if (i and dp[i - 1][j][k] <= n)       upmin(dp[i][j][k], nxt[dp[i - 1][j][k]][word[0][i]]);     if (j and dp[i][j - 1][k] <= n)       upmin(dp[i][j][k], nxt[dp[i][j - 1][k]][word[1][j]]);     if (k and dp[i][j][k - 1] <= n)       upmin(dp[i][j][k], nxt[dp[i][j][k - 1]][word[2][k]]);   }   void main() {     cin >> n >> q >> s;     for (long long i = 0; i < n; i++) s[i] -=  a ;     s =     + s;     for (long long i = 0; i < 26; i++) nxt[n][i] = inf;     for (long long i = n - 1; i >= 0; i--) {       for (long long j = 0; j < 26; j++) nxt[i][j] = nxt[i + 1][j];       nxt[i][s[i + 1]] = i + 1;     }     for (long long i = 0; i < 3; i++) word[i].push_back(0);     dp[0][0][0] = 0;     while (q--) {       string op;       cin >> op;       int id;       cin >> id;       id--;       if (op ==  + ) {         string sss;         cin >> sss;         int ch = sss[0] -  a ;         word[id].push_back(ch);         if (id == 0) {           for (long long b = 0; b < ((int)word[1].size()); b++) {             for (long long c = 0; c < ((int)word[2].size()); c++) {               solve(((int)word[0].size()) - 1, b, c);             }           }         }         if (id == 1) {           for (long long b = 0; b < ((int)word[0].size()); b++) {             for (long long c = 0; c < ((int)word[2].size()); c++) {               solve(b, ((int)word[1].size()) - 1, c);             }           }         }         if (id == 2) {           for (long long b = 0; b < ((int)word[0].size()); b++) {             for (long long c = 0; c < ((int)word[1].size()); c++) {               solve(b, c, ((int)word[2].size()) - 1);             }           }         }       } else {         word[id].pop_back();       }       cout << ((dp[((int)word[0].size()) - 1][((int)word[1].size()) - 1]                   [((int)word[2].size()) - 1] <= n)                    ?  YES                     :  NO )            << endl;     }   }   }  // namespace SOLVE   signed main() {     int t;     t = 1;     while (t--) {       SOLVE::main();     }     return 0;   }   