#include <bits/stdc++.h>
using namespace std;
#define REPP(i,a,b,d) for(int i=(a);i<=(int)(b);i+=(d))
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,d) for(int i=(a);i>=(int)(b);i-=(d))
#define REV(i,a,b) REVV(i,a,b,1)
#define FOR(i,a) for(int i=0; i<(int)(a); i++)
#define FORD(i,a) for(int i=(int)(a)-1; i>=0; i--)
#define pb push_back
typedef long long ll;
 
int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	int t; cin >> t;
	while(t--) {
		int n; cin >> n;
		vector<string> s(3);
		FOR(i, 3) cin >> s[i];
		FOR(i, n) cout << 0;
		FOR(i, n) cout << 1;
		cout << 0 << '\n';
	}
	return 0;
}
#include<bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#define endl "\n"
#define pb push_back
#define ll long long
#define d1(x)  cerr << #x << "--> " << x << endl
#define d2(x,y)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<endl
#define d3(x,y,z)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<" | " << #z << "--> "<< z<< endl
#define d4(x,y,z,w)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<" | " << #z << "--> "<< z << " | "<< #w << "--> " << w <<endl
#define vpll vector<pair<ll,ll>>
#define F first
#define S second
using namespace std;
ll mode = 1e9 + 7;
const ll maxn = 2*1e5 + 5;
const ll inf = 1e18;
ll __lcm(ll a, ll b){ return (a*b)/__gcd(a,b); }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll getRand(ll l, ll r){ uniform_int_distribution<int> uid(l, r); return uid(rng); }
template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a) { return out << "(" << a.F << ", " << a.S << ")"; }
template <class A> ostream& operator << (ostream& out, const vector<A> &v) { 
out << "["; for (int i=0;i<v.size();i++) { if(i) out << ", "; out << v[i]; } return out << "]"; }

void solve(){
	
	ll n,k;
	cin>>n>>k;
	map<ll,ll> mp;
	for (int i=0;i<n;i++){
		ll a,b;
		cin>>a>>b;
		mp[a]+=b;
	}
	vpll v;
	for (auto i:mp){
		v.push_back({i.F, i.S});
	}
	n = v.size();
	ll pos = 0, cur = k;
	for (int i=0;i<n;i++){
		if (pos+cur>=v[i].F){
			cur -= (v[i].F - pos);
			pos = v[i].F;
			cur += v[i].S;
		}
		else{
			pos += cur;
			break;
		}
		if (i==n-1){
			pos += cur;
		}
	}
	cout<<pos<<endl;
	
	
	
}


int main(){ 
    
    #ifndef ONLINE_JUDGE
//		freopen("input.txt", "r", stdin);
//		freopen("output.txt", "w", stdout);
    #endif
    srand(time(0)); 
    
    ios::sync_with_stdio(0);
    cin.tie(0);
	
	ll test_case = 1;
	//cin>>test_case;
	for (int i=1;i<=test_case;i++){
		solve();
	}
	
	return 0;
}