#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <stack>
#include <deque>
#include <ctime>
#include <random>
#include <cassert>
#include <cmath>
#include <climits>
#include <queue>
#include <cstring>
#include <bitset>
#include <iomanip>
#include <chrono>

/*
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("popcnt")
#pragma GCC target("avx2")
*/


#ifdef LOCAL
	#define dbg(x) cout << #x << " : " << x << endl;
#else 
	#define dbg(x)
#endif

#define int long long
#define fi(a,b) for (int i=a;i<b;i++)
#define fj(a,b) for (int j=a;j<b;j++)
#define fk(a,b) for (int k=a;k<b;k++)
#define fi1(a,b) for (int i=a-1;i>=b;i--)
#define fj1(a,b) for (int j=a-1;j>=b;j--)
#define fk1(a,b) for (int k=a-1;k>=b;k--)
#define fx(x,a) for (auto& x : a)
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define rep1(i, a, b) for (int i = a - 1; i >= b; --i)
#define siz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;

template<typename T1, typename T2>inline void mine(T1 &x, T2 y) { if (x > y) x = y; }
template<typename T1, typename T2>inline void maxe(T1 &x, T2 y) { if (x < y) x = y; }

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << ' ';
    return a;
}


typedef long long ll;
typedef unsigned long long ull;
typedef char ch;
typedef string str;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<ch> vch;
typedef vector<vch> vvch;
typedef vector<str> vs;



const int MOD = 1000000007;
const int INF = 1000000050;
const long long BIG = (long long)2e18 + 50;
const int MX = 200010;
const double EPS = 1e-9;


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

struct Node {
	char x;
	Node *l;
	Node *r;
	bool is_rev;
	int sz;
	int prior;
	Node (char c): x(c), l(nullptr), r(nullptr), is_rev(false), sz(1), prior(rng()) {};
};

int getsz(Node *t) {
	if (!t)
		return 0;
	return t->sz;
}

void upd(Node *t) {
	t->sz = 1 + getsz(t->l) + getsz(t->r);
}

void push(Node *t) {
	if (t->is_rev) {
		swap(t->l, t->r);
		if (t->l)  t->l->is_rev ^= 1;
		if (t->r)  t->r->is_rev ^= 1;
		t->is_rev = false;
	}
}

Node * Merge(Node * t1, Node * t2) {
	if (!t1)
		return t2;
	if (!t2)
		return t1;
	push(t1);
	push(t2);
	if (t1->prior > t2->prior) {
		t1->r = Merge(t1->r, t2);
		upd(t1);
		return t1;
	} else {
		t2->l = Merge(t1, t2->l);
		upd(t2);
		return t2;
	}
}

void print(Node *t, int depth = 0) {
	if (!t)
		return;
	push(t);
	print(t->l, depth + 1);
	//dbg(depth);
	cout << t->x;
	print(t->r, depth + 1);
}

Node * push_back(Node *t, char c) {
	Node * key_node = new Node(c);
	t = Merge(t, key_node);
	return t;
} 

Node * push_front(Node * t, char c) {
	Node * key_node = new Node(c);
	t = Merge(key_node, t);
	return t;
}


int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	
	Node *t = nullptr;
	str s;
	cin >> s;
	fx(x, s)
		t = push_back(t, x);
	int q;
	cin >> q;
	fi(0, q) {
		int type;
		cin >> type;
		if (type == 1) {
			t->is_rev ^= 1;
		} else {
			int f;
			cin >> f;
			char c;
			cin >> c;
			if (f == 1)
				t = push_front(t, c);
			else
				t = push_back(t, c);
		}
		/*print(t);
		cout << '\n';*/
	} 
	print(t);  	
	cout << '\n';
}	

Measured memory_bytes: 19408