#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define FOR(i,a,b)  for(ll i=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll i=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      v.begin(), v.end()
#define UNIQ(v)     sort(ALL(v)); v.erase(unique(ALL(v)), v.end())
#define BIT(n)      (1LL<<(n))
#define DEBUG(a)    cerr << #a << " = " << a << endl

const double PI = acos(-1);
const int inf = 1001001001;
const int mod = (int)1e9+7;
//const ll inf = 1e15;
//const ll mod = 1e9+7;

int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};

int t2 = 0;

void swp(int q, vector<int>& t, vector<int>& a, vector<int>& b, string& s) {
    if (t[q] == 1) {
        if (t2%2 == 1) {
            if (a[q] )
            a[q] = (a[q] + s.size() / 2) % s.size();
            if (a[q] == 0) a[q] = s.size();
            b[q] = (b[q] + s.size() / 2) % s.size();
            if (b[q] == 0) b[q] = s.size();
        }
        swap(s[a[q]-1], s[b[q]-1]);
    } else {
        t2++;
    }
}

int main() {
    int n;
    string s;
    cin >> n >> s;
    int q;
    cin >> q;
    vector<int> t(q), a(q), b(q);
    REP(i, q) {
        cin >> t[i] >> a[i] >> b[i];
    }

    REP(i, q) {
        swp(i, t, a, b, s);
    }
    if (t2%2 == 1) {
        REP(i, s.size() / 2) {
            swap(s[i], s[i+s.size()/2]);
        }
    }
    cout << s << endl;
}

#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdio>
#include<stdio.h>
#include<cmath>
#include<math.h>
#include<vector>
#include<set>
#include<queue>
#include<map>
#include<sstream>
#include<iomanip>
#define forn(i,n) for(int (i)=0;i<(n);i++)
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int>pii;
typedef long long ll;
typedef pair<ll,ll> pll;
const int MAXN=100005;
const int INF=2147483647;
const ll LINF=9223372036854775807;
const int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
int n,x,cnt;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>x;
	x*=100;
	forn(i,n)
	{
		int a,b;
		cin>>a>>b;
		cnt+=a*b;
		if(cnt>x)
		{
			cout<<i+1;
			return 0;
		}
	}
	cout<<-1;
	return 0;
}
