#include <bits/stdc++.h>
using namespace std;
static const int MAX = 10000;
static const long long INFTY = 1e12;
struct edge {
  long long to, cost;
};
using Graph = vector<vector<int>>;
using _Graph = vector<vector<edge>>;
int H, W;
vector<vector<char>> field;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
vector<bool> seen;
vector<int> colors;
int main() {
  string S;
  cin >> S;
  long long Q;
  cin >> Q;
  int siji;
  int flag = 0;
  for (int i = 0, i_len = (Q); i < i_len; ++i) {
    cin >> siji;
    if (siji == 1) {
    } else {
      int siji2;
      cin >> siji2;
      string c;
      cin >> c;
      if (siji2 == 1) {
      } else {
      }
    }
  }
  cout << S << endl;
}
