#include <bits/stdc++.h>   using namespace std;   int mida;   void update(vector<int>& T, int p, int x) {     T[mida + p] = x;     for (int i = (mida + p) / 2; i > 0; i /= 2) T[i] = T[2 * i] + T[2 * i + 1];   }   int suma(vector<int>& T, int a, int b, int c = 0, int d = mida - 1, int p = 1) {     if (a <= c and d <= b) return T[p];     if (d < a or c > b) return 0;     return suma(T, a, b, c, (c + d) / 2, 2 * p) +            suma(T, a, b, (c + d) / 2 + 1, d, 2 * p + 1);   }   int main() {     int k;     string r;     cin >> k >> r;     string s;     for (int i = 0; i < k; ++i) s += r;     int n = s.size();     mida = 1;     while (mida < n) mida *= 2;     vector<vector<int> > T( z  -  a  + 1, vector<int>(2 * mida, 0));     for (int i = 0; i < n; ++i) update(T[s[i] -  a ], i, 1);     int q;     cin >> q;     while (q--) {       int p;       char c;       cin >> p >> c;       int ini = 0, fin = n - 1;       while (ini <= fin) {         int m = (ini + fin) / 2;         if (suma(T[c -  a ], 0, m) >= p)           fin = m - 1;         else           ini = m + 1;       }       s[fin + 1] = 0;       update(T[c -  a ], fin + 1, 0);     }     for (int i = 0; i < n; ++i)       if (s[i] > 0) cout << s[i];     cout << endl;   }   