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.
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/priority_queue.hpp>

#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

using namespace std;

template <class T, class M>
using trtr = __gnu_pbds::tree <T, M, less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

#define sp ' '
#define en '\n'

#define _str(x) #x
#define ww(x) _str(x) << " = " << x << sp
#define wn(x) _2d << _str(x) << " = " << en << x << en

struct _flag_t { string val; }
const _1d {", "}, _2d {"\n  "};
_flag_t _flag = _1d;

ostream& operator << (ostream& os, _flag_t flag) { _flag = flag; return os; }

template <class Ch, class Tr, class It>
basic_ostream <Ch, Tr> &
_out (basic_ostream <Ch, Tr> & os, It f, It l) {
    if(f == l) return os << "{}";
    auto cur_flag = _flag;
    os << _1d << "{ " << *f;
    for(; ++f != l; os << cur_flag.val << *f);
    return os << " }";
}

template <class Ch, class Tr, class C>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, C const& cont)
{ return _out(os, begin(cont), end(cont)); }

template <class X, class Y>
ostream& operator << (ostream& os, pair <X,Y> const& p) { return os << "[" << get<0>(p) << ", " << get<1>(p) << "]"; }

template <class X, class Y> X&   maxi  (X& x, Y const& y) { return x < (X)y ? x = y : x; }
template <class X, class Y> X&   mini  (X& x, Y const& y) { return x > (X)y ? x = y : x; }
template <class X, class Y> bool bmaxi (X& x, Y const& y) { return x < (X)y ?(x = y, true) : false; }
template <class X, class Y> bool bmini (X& x, Y const& y) { return x > (X)y ?(x = y, true) : false; }

#define int ll
#define qq auto
#define qr auto &
#define qrr auto &&
#define qc auto const&
#define sz(x) int( x.size() )
#define mp(x, y) make_pair( x, y )
#define ff first
#define ss second

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair <int, int>;
using pll = pair <ll, ll>;
using pdd = pair <double, double>;

template <class K, class T>
using hash_table = __gnu_pbds::cc_hash_table<K, T>;
//using hash_table = unordered_map<K, T>;
//using hash_table = map<K, T>;

const double PI = acos(-1);
const double PIH = PI * 0.5;
const double PID = PI * 2.0;

template <class T = ll>
vector <vector <T>> make_mat(size_t n, size_t m = 0, T val = T())
{ return vector <vector <T>>(n, vector <T> (m, val)); }

#define forr(i, n) for(int i = 0; i < n; i ++)
#define forn(i, b, n) for(int i = b; i < n; i ++)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)

#define def(f, ...) qq f = [&] (qc f, __VA_ARGS__)
#define call(f, ... ) f(f, __VA_ARGS__)

template <class F> struct pred { F f; };
template <class F> auto make_pred (F const& f) { return pred <F> { f }; }
template <class F, class T> auto operator - (T && y, pred <F> const& x) { return x.f(y); }
template <class F, class T> auto operator - (pred <F> const& x, T && y) { return x.f(y); }

qq mid = make_pred([](int l){ return make_pred([l](int r){ return (l+r)/2; }); });
qq pb = make_pred([](qr v){ return make_pred([&v](qq x){ v.push_back(x); }); });

int32_t main()
{
    ios_base::sync_with_stdio( false );

    int n, k, m, t; cin >> n >> k >> m >> t;
    trtr<double, int> tr;
    k--;
    forn(i, 0, n) tr[i] = 1;

    auto del = [&](int pos) {
        int doc = tr.order_of_key(k);

        if( pos <= doc ) {
            forr(i, pos) tr.erase( tr.begin() );
        }
        else {
            int d = sz(tr)-pos;
            forr(i, d) tr.erase( tr.rbegin() );
        }
    };

    auto add = [&](int pos) {
        double key;
        if(pos < sz(tr)) {
            qq r = tr.find_by_order( pos-1 );
            qq l = prev(r);
            if(r == tr.begin()) {
                key = r->first - 1.0;
                tr[key] = 1;
            }
            else {
                trtr<double, int> tmp;
                tr.split(l->first, tmp);
                key = l->first+1;
                tr[key] = 1;
                bool inc = false;
                for(qq[kk, v] : tmp) {
                    if(kk == k) inc = true;
                    tr[kk+1] = v;
                }
                if( inc ) k++;
            }
        }
        else {
            key = tr.rbegin()->first + 1.0;
            tr[key] = 1;
        }
    };

    for(; t--;) {
        int x, y; cin >> x >> y;
        if( x == 1 ) add(y);
        else del(y);
        cout << sz(tr) << sp << tr.order_of_key( k )+1 << en;
    }
}

/**
5 2 10 3
0 1
0 2
0 1


*/
