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.

// Problem : D1. Parallel Universes (Easy)
// Contest : Codeforces - Helvetic Coding Contest 2019 online mirror (teams allowed, unrated)
// URL : https://codeforces.com/contest/1184/problem/D1
// Memory Limit : 256 MB
// Time Limit : 1000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

 /* ..Mission 1900 soon.. */

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse2") 

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include<bits/stdc++.h>


using namespace std;
using namespace __gnu_pbds;



#define MOD1          998244353
#define MOD           1000000007
#define M             1000000009
#define pye           acos(-1)
#define int           long long
#define ld            long double
#define D             double
#define S             second
#define F             first
#define pb            push_back
#define ff            fflush(stdout)
#define all(c)        (c).begin(),(c).end()
#define rall(c)       (c).rbegin(),(c).rend()
#define SORT(v)       sort(ALL(v))  
#define lb            lower_bound
#define ub            upper_bound
#define si(c)         (int)((c).size())
#define gcd(a,b)      __gcd(a,b)
#define lcm(a,b)      (a*(b/gcd(a,b)))
#define fast          ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define accuracy      cout << fixed << setprecision(18);
#define pow(i,n)      (ll)pow((int)i,n)
#define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
#define deb(x)        cout<<#x<<" "<<x<<endl;
#define debg         cout<<"I am here!"<<endl;
#define maxe(v)       *max_element(ALL(v))
#define mine(v)       *min_element(ALL(v))
#define endl          '\n'
#define tp            template
#define ty            typename
#define mem1(a)       memset(a,-1,sizeof(a))
#define mem0(a)       memset(a,0,sizeof(a))
#define bpc           __builtin_popcount
#define rep(i,a,b)    for(int i=a;i<b;i++)


const long double pi  = 3.141592653589793238463;

#ifdef magneto07
#define TRACE
#endif
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cout << name << " : " << arg1 << std::endl;
    //use cerr if u want to display at the bottom
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#else
#define trace(...) 0;
#endif


typedef vector<int>                         vi;
typedef pair<int,int>                       pii;
typedef vector<pii>                         vpi;
typedef pair<int,pii>                       pipii;
typedef vector<vector<int>>                 vvi;
typedef map<int,int>                        mp;
typedef priority_queue<pii, vector<pii>, greater<pii> > pq;
typedef tree < int ,  null_type ,  less_equal<int> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;

inline  bool checkBit(int n, int i) { return n&((int)1<<i); }
inline  int setBit(int n, int i) { return n|((int)1<<i); }
inline  int resetBit(int n,int  i) { return n&(~((int)1<<i)); }
inline  void normal(int &a) { a = (a+MOD)%MOD; }
inline  int modMul(int a, int b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline  int modAdd(int a,int b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline  int modSub(int a, int b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline  int modPow(int b, int p) { int r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline  int modInv(int a) { return modPow(a, MOD-2); }
inline  int modDiv(int a,int b) { return modMul(a, modInv(b)); }


inline  int fact(int r){ int ans=1;while(r)ans=modMul(ans,r),r--;return ans; }
inline  int invfact(int r){int ans=1;while(r)ans=modMul(ans,modInv(r)),r--; return ans;}
inline  D dgcd(D a,D b){ if(a<b)return dgcd(b,a); if(b<.0001)return a; return dgcd(b,fmod(a,b));}


inline int toint(const std::string &s) {std::stringstream ss; ss << s; int x; ss >> x; return x;}
inline std::string tostring(int number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(int x) {return std::bitset<63>(x).to_string();}

//primes for hashing 937,991,1013,1409,1741

clock_t start;
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());

 
tp<ty T1, ty T2> istream& operator>>(istream& in, pair<T1, T2> &q){
    in >> q.F >> q.S; return in;
}
tp<ty T1, ty T2> ostream& operator<<(ostream& out, pair<T1, T2> &q){
    out << q.F << " " << q.S; return out;
}
tp< ty T1, ty T2> pair<T1, T2> operator+(pair<T1, T2> p1, pair<T1, T2> p2){
    return {p1.F+p2.F, p1.S+p2.S};
}
tp< ty T1, ty T2> pair<T1, T2> operator-(pair<T1, T2> p1, pair<T1, T2> p2){
    return {p1.F-p2.F, p1.S-p2.S};
}
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}

template <typename Arg1, typename... Args>

void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

template <typename T> T allmin(T t) {return t;}

template<typename T, typename... Args> T allmin(T t, Args... args) {return min(t, allmin(args...));}
 
template <typename T> T allmax(T t) {return t;}

template<typename T, typename... Args> T allmax(T t, Args... args) {return max(t, allmax(args...));}

template<typename T> void Unique(vector<T> &v) {
    sort(all(v)), v.resize(distance(v.begin(), unique(all(v))));
} 
/*----------------------Graph Moves----------------------*/
// const int fx[]={+1, -1, +0, +0};
// const int fy[]={+0, +0, +1, -1};
// const int fx[]={+0, +0, +1, -1, -1, +1, -1, +1};  // Kings Move
// const int fy[]={-1, +1, +0, +0, +1, +1, -1, -1};  // Kings Move
// const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
// const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1};  // Knights Move
/*-------------------------------------------------------*/

const int N=1e6;
const int INF=2e18;
   
int power( int base, int exp) {
    int res=1;
    while(exp>0) {
       if(exp%2==1) res=(res*base)%MOD;
       base=(base*base)%MOD;
       exp/=2;
    }
    return res%MOD;
} 


bool isPrime(int n) {
 
    if (n <= 1) return false;
    if (n <= 3) return true;
    if (n % 2 == 0 || n % 3 == 0) return false;
    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
    return true;
}

void Timelimitexceeded()
{   
    int n,m,k,t;
    cin>>n>>k>>m>>t;
    int curr=k;
    while(t--){
    	int q,x;
    	cin>>q>>x;
    	if(q==0){
    		if(x>=k){
    			n=x;
    			cout<<n<<" "<<curr<<endl;
    		}
    		else{
    			n-=x,curr-=x;
    			cout<<n<<" "<<curr<<endl;
    		}
    	}
    	else{
    		n++;
    		if(curr>=x)
    		curr++;
    		cout<<n<<" "<<curr<<endl;
    	}
    	//cout<<n<<endl;
    }
return;
}

signed main()
{  
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);    
    int t = 1;
    clock_t start, end; 
    start = clock(); 
    cout << fixed << setprecision(20);
    //cin>>t;
    while(t--){
        Timelimitexceeded();
    }
    end = clock();
    double time_taken = double(end - start) / double(CLOCKS_PER_SEC); 
    //cerr<<time_taken;
}