The Third Doctor Who once correctly said that travel between parallel universes is "like travelling sideways". However, he incorrectly thought that there were infinite parallel universes, whereas in fact, as we now all know, there will never be more than 250.

Heidi recently got her hands on a multiverse observation tool. She was able to see all n universes lined up in a row, with non-existent links between them. She also noticed that the Doctor was in the k-th universe.

The tool also points out that due to restrictions originating from the space-time discontinuum, the number of universes will never exceed m.

Obviously, the multiverse is unstable because of free will. Each time a decision is made, one of two events will randomly happen: a new parallel universe is created, or a non-existent link is broken.

More specifically, 

  * When a universe is created, it will manifest itself between any two adjacent universes or at one of the ends. 
  * When a link is broken, it could be cut between any two adjacent universes. After separating the multiverse into two segments, the segment NOT containing the Doctor will cease to exist. 



Heidi wants to perform a simulation of t decisions. Each time a decision is made, Heidi wants to know the length of the multiverse (i.e. the number of universes), and the position of the Doctor.

Input

The first line contains four integers n, k, m and t (2 ≤ k ≤ n ≤ m ≤ 250, 1 ≤ t ≤ 1000).

Each of the following t lines is in one of the following formats: 

  * "1 i" — meaning that a universe is inserted at the position i (1 ≤ i ≤ l + 1), where l denotes the current length of the multiverse. 
  * "0 i" — meaning that the i-th link is broken (1 ≤ i ≤ l - 1), where l denotes the current length of the multiverse. 

Output

Output t lines. Each line should contain l, the current length of the multiverse and k, the current position of the Doctor.

It is guaranteed that the sequence of the steps will be valid, i.e. the multiverse will have length at most m and when the link breaking is performed, there will be at least one universe in the multiverse.

Example

Input


5 2 10 4
0 1
1 1
0 4
1 2


Output


4 1
5 2
4 2
5 3

Note

The multiverse initially consisted of 5 universes, with the Doctor being in the second.

First, link 1 was broken, leaving the multiverse with 4 universes, and the Doctor in the first.

Then, a universe was added to the leftmost end of the multiverse, increasing the multiverse length to 5, and the Doctor was then in the second universe.

Then, the rightmost link was broken.

Finally, a universe was added between the first and the second universe.
#define COPYRIGHT "© : JAYPAL MUDALIYAR \n"

//**//<<//>>// PHIR SE UDD CHALA ...............................

//#pragma GCC optimize("Ofast") 

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define f(i,a,b) for(int i=a;i<b;i++)
#define fll(i,a,b) for(long long i=a;i<b;i++)
#define fd(i,a,b) for(int i=a-1;i>=b;i--)
#define fdll(i,a,b) for(long long i=a-1;i>=b;i--)
#define ll long long
#define ld long double
#define LLMAX LLONG_MAX
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vb vector<bool>
#define vll vector<long long>
#define vpi vector<pair<int,int>>
#define vpll vector<pair<long long,long long>>
#define vstr vector<string>
#define all(k) k.begin(),k.end()
#define rall(k) k.rbegin(),k.rend()
#define stll set <long long,greater<long long>>
#define Mi map <int,int>
#define Mll map <long long,long long>
#define dbg(x) cout << "---> [" << (x) << "]";
#define dbg2(x,y) cout << "---> [" << (x) << "]",cout << "---> [" << (y) << "]\n";
#define kill(x) { cout << (x) << "\n"; return; }
#define here() cout << "UPTO HERE" << endl;
#define printvec(v) for(auto x : v)  { cout << x << " "; } cout << "\n";
#define print3(x,y,z) cout << (x) << " " << (y) << " " << (z) << "\n"; 
#define tup(i,v) get<i>(v)
#define mt make_tuple
#define MOD 1000000007
#define nl cout << "\n";
#define printPair(x) cout << x.F << " " << x.S << "\n";
#define speed ios :: sync_with_stdio(0); cin.tie(0); cout.tie(nullptr);
#define inout(input,output) freopen(input,"r",stdin); freopen(output,"w",stdout);

using namespace std;
using namespace std::chrono;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> ord_set;

void getprime(int );
string decToBinary(ll );

bool spsort(const pair<ll,ll> &a, const pair<ll,ll> &b) { 
    // Use all(k) not rall;
    if(a.F != b.F)
        return (a.F > b.F); 
    else
        return (a.S < b.S);
    // 5 1
    // 5 2
    // 4 2
    // 4 4
    // 3 2
    // 3 8
} 

bool sortsec(const pair<ll,ll> &a, const pair<ll,ll> &b) {return (a.S < b.S);}
int numofBits(ll x) { if(x==0) { return 0; } return floor(log2(x))+1;}
template <typename T> /**/ ll lcm(T a,T b) {return (ll)(a/__gcd(a,b))*b;}
unsigned long long leastSetBitpos(ll n) {return log2(n & -n) + 1;}

template <typename T>
T mostSignificantBit(T n) { 
    n|=n>>1; n|=n>>2; n|=n>>4; n|=n>>8; n|=n>>16; ++n;
    return (n>>1);
}

template<typename T>
T gcd(T a,T b) {
    if(a==0) return b;
    else if(b==0) return a;
    return __gcd(a,b);
}

template <typename T>
bool isprime(T n) {
    if(n<=1) return false;
    for(ll i=2;(i*i)<=n;i++)
        if(n%i==0) 
            return false;
    return true;
}

bool ispalin(string s) {
    ll j=s.size()-1,i=0;
    while(i<j)
    {
        if(s[i]!=s[j]) return false; 
        ++i;--j;
    }
    return true;
}

template <typename T>
T getmod(T x,T mod) {
    T z=x%mod;
    if(z>=0) return z;
    else return (z+mod);
}

const long double PI = acos(-1);
const int max_bits=32; // for dectoBinary()
const int primel=1000050; // 1e6+50 \\ if time limit is 2s then you can go upto 1e7 //
bool prime[primel];

//**//<<//>>// GOD'S PLAN ...............................

void AJM()
{
    int n,k,m;cin >> n >> k >> m;
    vb curr(n,false); curr[k-1]=true;
    int t;cin >> t;
    f(_,0,t) {
        int op,x;cin >> op >> x;
        if(op==0) {
            vb tmp;
            fd(i,n,x) {
                tmp.pb(curr.back());
                curr.pop_back();
            }
            bool ok=false;
            for(auto i:curr) ok|=i;
            if(!ok) {
                reverse(all(tmp));
                curr=tmp;
            }
        }
        else {
            --x;
            curr.insert(curr.begin()+x,0);
        }
        int ans=-1;
        f(i,0,curr.size()) {
            if(curr[i]) {
                ans=i+1;break;
            }
        }
        cout << curr.size() << " " << ans << "\n";
    }
    return;
}

// |||||||| "CHECK BELOW" ||||||

bool GOOGLE = 0;
bool txtinp = 1;
bool TC = 0;
// 2^24 is recursion limit //

//**//<<//>>// KHAIRIYAT TO PUCHO .............................

///// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main()
{
    if(txtinp)
    {
        #ifndef ONLINE_JUDGE
            inout("1input.txt","1output.txt");
        #endif
    }
    speed
    ll t=1;
    if(TC)
        cin >> t;
    // getprime(primel);
    ll tc=1;
    while(t--)
    {
        if(GOOGLE) cout << "Case #" << tc << ": ";
        ++tc;
        AJM();
    }
    return 0;
}

void getprime(int primel)
{
    int a=primel;
    prime[0]=prime[1]=false;
    f(i,2,a+1) prime[i]=true;
    // getans[0]=getans[1]=0;
    // ll temp=0;
    for(int p=2;(p*p)<=a;p++)
    {
        if (prime[p] == true) 
        {
            for(int i=(p*p);i<=a;i+=p)
                prime[i] = false;
        }
    }
    // f(i,2,a)
    // {
    //     if(prime[i]) temp++;
    //     getans[i]=temp;
    // }
}
string decToBinary(ll n) {bitset<max_bits> b(n);  return b.to_string();}

///// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

// For t=10000
// 3761771 - without speed console
// 4977903 - with speed console
// 2999 - without speed input output
// 981 - with speed input output

