#include<bits/stdc++.h>
#define speedio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;

typedef long long       ll;
typedef long double     ld;

typedef vector<int>     vi;
typedef vector<bool>    vb;
typedef vector<ll>      vll;
typedef vector<vi>      vvi;
typedef vector<vll>     vvll;
typedef vector<string>  vs;

typedef pair<int, int>  pii;
typedef pair<ll, int>   pli;
typedef pair<ll, ll>    pll;
typedef vector< pii >   vpi;

// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;

#define pb           push_back
#define mod          1000000007
#define INF          1e17
#define mini         INT_MIN
#define maxo         INT_MAX
#define eb           emplace_back
#define ff           first
#define ss           second
#define re           return
#define endl         "\n"

#define all(c)       c.begin(),c.end()
#define be           begin()
#define en           end()
#define sz(x)        (ll)x.size()
#define mem(a,val)   memset(a,val,sizeof(a))
#define mk(x,y)      make_pair(x,y)
#define mid(s,e)     ((s)+((e)-(s))/2)

#define fo(i,a,b)     for(int i = (int)(a); i <= (int)(b); i++)
#define rf(i,a,b)    for(int i = (int)(a); i >= (int)(b); i--)
#define read(a,n)    for(int i=0;i<n;i++)cin>>a[i];
#define show(a,n)    for(int i=0;i<n;i++)cout<<a[i]<<' ';cout<<endl;
#define p2(n)        (1LL << (n))
#define deb(x) cout <<#x << " = " << x << " | " << "LINE: "<<__LINE__<< endl;
template<typename... T> void rd(T&... args) { ((cin >> args), ...); }
template<typename... T> void pp(T... args) { ((cout << args << " "), ...); cout<<"\n"; }

void add(ll &x, ll y){ x += y; if(x>=mod) x %= mod; if(x<0) x = x%mod + mod; }

//============== *** START OF CODE ***

bool apxeq(double a, double b, double absEpsilon = 1e-12,
           double relEpsilon = 1e-8) {
  // Check if the numbers are really close -- needed when comparing numbers near
  // zero.
  double diff = abs(a - b);
  if (diff <= absEpsilon)
    return true;

  // Otherwise fall back to Knuth's algorithm
  return (diff <= (max(abs(a), abs(b)) * relEpsilon));
  // You don't need to choose the epsilons
}

void solve()
{
    ll k;rd(k);
    ld ans = 1;
    fo(i,1,k){
        ld s,q; rd(s,q);
        ld y = log(q)/log(2);
        y/=2;
        y+=s;
        ld _ans = (ll)y;
        if(!apxeq(_ans,y))_ans++;
        ans = max(ans,_ans);
    }
    pp((ll)ans);
}

void prep(){}

//=============== *** END OF CODE ***

int main(){
    speedio; cout<<fixed<<setprecision(12);

// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif

    prep();
    int t = 1;
    // cin >> t;
    while(t--)
        solve();

    cout<<"\n";
    return 0;
}


#include<bits/stdc++.h>
#define speedio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;

typedef long long       ll;
typedef long double     ld;

typedef vector<int>     vi;
typedef vector<bool>    vb;
typedef vector<ll>      vll;
typedef vector<vi>      vvi;
typedef vector<vll>     vvll;
typedef vector<string>  vs;

typedef pair<int, int>  pii;
typedef pair<ll, int>   pli;
typedef pair<ll, ll>    pll;
typedef vector< pii >   vpi;

// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;

#define pb           push_back
#define mod          1000000007
#define INF          1e17
#define mini         INT_MIN
#define maxo         INT_MAX
#define eb           emplace_back
#define ff           first
#define ss           second
#define re           return
#define endl         "\n"

#define all(c)       c.begin(),c.end()
#define be           begin()
#define en           end()
#define sz(x)        (ll)x.size()
#define mem(a,val)   memset(a,val,sizeof(a))
#define mk(x,y)      make_pair(x,y)
#define mid(s,e)     ((s)+((e)-(s))/2)

#define fo(i,a,b)     for(int i = (int)(a); i <= (int)(b); i++)
#define rf(i,a,b)    for(int i = (int)(a); i >= (int)(b); i--)
#define read(a,n)    for(int i=0;i<n;i++)cin>>a[i];
#define show(a,n)    for(int i=0;i<n;i++)cout<<a[i]<<' ';cout<<endl;
#define p2(n)        (1LL << (n))
#define deb(x) cout <<#x << " = " << x << " | " << "LINE: "<<__LINE__<< endl;
template<typename... T> void rd(T&... args) { ((cin >> args), ...); }
template<typename... T> void pp(T... args) { ((cout << args << " "), ...); cout<<"\n"; }

void add(ll &x, ll y){ x += y; if(x>=mod) x %= mod; if(x<0) x = x%mod + mod; }

//============== *** START OF CODE ***

bool apxeq(ld a, ld b, ld absEpsilon = 1e-12,
           ld relEpsilon = 1e-8) {
  // Check if the numbers are really close -- needed when comparing numbers near
  // zero.
  ld diff = abs(a - b);
  if (diff <= absEpsilon)
    return true;
  else return false;
}

void solve()
{
    ll k;rd(k);
    ld ans = 1;
    fo(i,1,k){
        ld s,q; rd(s,q);
        ld y = log(q)/log(2);
        y/=2;
        y+=s;
        ld _ans = (ll)y;
        pp(y,_ans);
        if(!apxeq(_ans,y))_ans++;
        else if(q==1)ans++;
        ans = max(ans,_ans);
    }
    pp((ll)ans);
}

void prep(){}

//=============== *** END OF CODE ***

int main(){
    speedio; cout<<fixed<<setprecision(12);

// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif

    prep();
    int t = 1;
    // cin >> t;
    while(t--)
        solve();

    cout<<"\n";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
typedef long long ll;
typedef unsigned long long ull;

void printvector(vector<ll> v)
{
    for(int i=0;i<v.size();i++)
    {
      cout<<v[i]<<" ";
    }
    cout<<endl;
}

int main()
{
  ll n,i,j,k;

  vector<pair<ll,ll>>v;

  cin>>n;
  ll mx=0;
  for(i=0;i<n;i++)
  {
    cin>>j>>k;
    v.pb({j,k});
    mx=max(mx,j);
  }

  ll f=mx+1,l=100000000000000;

  ll ans;
  while(f<=l)
  {
    ll mid=(f+l)/2;

    //cout<<"qef"<<mid<<endl;
    for(i=0;i<n;i++)
    {
      if(2*(mid-v[i].ff)<ceil(log2(v[i].ss)))
        break;
    }

    // if(mid==3)
    // {
    //   cout<<mid-v[i].ff+1<<" "<<ceil(log2(v[i].ss))<<endl;
    // }

    if(i==n)
    {
      ans=mid;
      l=mid-1;
    }
    else
      f=mid+1;
  }
  cout<<ans<<endl;
}


#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
typedef long long ll;
typedef unsigned long long ull;

void printvector(vector<ll> v)
{
    for(int i=0;i<v.size();i++)
    {
      cout<<v[i]<<" ";
    }
    cout<<endl;
}

int main()
{
  ll n,i,j,k;

  vector<pair<ll,ll>>v;

  cin>>n;
  ll mx=0;
  for(i=0;i<n;i++)
  {
    cin>>j>>k;
    v.pb({j,k});
    mx=max(mx,j);
  }

  ll f=mx+1,l=100000000000000;

  ll ans;
  while(f<=l)
  {
    ll mid=(f+l)/2;

    //cout<<"qef"<<mid<<endl;
    for(i=0;i<n;i++)
    {
      if(mid-v[i].ff+1<floor(log2(v[i].ss)))
        break;
    }

    if(i==n)
    {
      ans=mid;
      l=mid-1;
    }
    else
      f=mid+1;
  }
  cout<<ans<<endl;
}


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

void prime(int a,vector<int> &v){
    for(ll i=2;i*i<=a;i++){
        if(a%i==0)v.push_back(i);
        while(a%i==0){
            a=a/i;
        }
    }
    if(a>1)
    v.push_back(a);
}

 ll mod;
ll expmod(ll a,ll b) {
	if(b == 1) return a;
	if(b == 0) return 1;
	ll m1 = expmod(a,b/2)%mod;
	if(b%2) return ((m1*m1)%mod*a%mod)%mod;
	return (m1*m1)%mod;
}

ll gcd(ll a,ll b){
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    return (a*b)/gcd(a,b);
}

 int main(){
  int n;cin>>n;
  ll ans=0;
  ll a[n][2];
  for(int i=0;i<n;i++){
      cin>>a[i][0]>>a[i][1];
      ll lg=ceil(log2(a[i][1])/2);
      ans=max(ans,a[i][0]+lg);
  }
//   for(int i=1;i<n;i++){
//      if(a[i][0]-a[i-1][0]>20ll)continue;
//      ll z=a[i][0]-a[i-1][0];
//      ll y=a[i-1][1]/(pow(4ll,z));
//      ll x=a[i-1][1]-y*(pow(4ll,z));
//      if(x>0)y++;
//     a[i][1]+=max(0ll,(y-a[i][1]));
//   }
//  // cout<<a[n-1][1]<<" ";
//   for(ll i=1;i<20;i++){
//       if(a[n-1][1]<=pow(4,i)){
//           ans=i;break;
//       }
//   }
  cout<<a[n-1][0]+max(1ll,ans-a[n-1][0]);
  //cout<<pow(4,32);
 }


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

void prime(int a,vector<int> &v){
    for(ll i=2;i*i<=a;i++){
        if(a%i==0)v.push_back(i);
        while(a%i==0){
            a=a/i;
        }
    }
    if(a>1)
    v.push_back(a);
}

 ll mod;
ll expmod(ll a,ll b) {
	if(b == 1) return a;
	if(b == 0) return 1;
	ll m1 = expmod(a,b/2)%mod;
	if(b%2) return ((m1*m1)%mod*a%mod)%mod;
	return (m1*m1)%mod;
}

ll gcd(ll a,ll b){
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    return (a*b)/gcd(a,b);
}

 int main(){
  int n;cin>>n;
  ll ans=0;
  ll a[n][2];
  for(int i=0;i<n;i++){
      cin>>a[i][0]>>a[i][1];
  }
  ans=a[n-1][0]+1;
  for(int i=1;i<n;i++){
     if(a[i][0]-a[i-1][0]>30)continue;
     ll y=a[i][1]/(pow(4,a[i][0]-a[i-1][0]));
    a[i][1]+=max(0ll,(y-a[i][1]));
  }
  for(int i=1;i<20;i++){
      if(a[n-1][1]<=pow(4,i)){
          ans=i;break;
      }
  }
  cout<<a[n-1][0]+max(1ll,ans);
 }


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

void prime(int a,vector<int> &v){
    for(ll i=2;i*i<=a;i++){
        if(a%i==0)v.push_back(i);
        while(a%i==0){
            a=a/i;
        }
    }
    if(a>1)
    v.push_back(a);
}

 ll mod;
ll expmod(ll a,ll b) {
	if(b == 1) return a;
	if(b == 0) return 1;
	ll m1 = expmod(a,b/2)%mod;
	if(b%2) return ((m1*m1)%mod*a%mod)%mod;
	return (m1*m1)%mod;
}

ll gcd(ll a,ll b){
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    return (a*b)/gcd(a,b);
}

 int main(){
  int n;cin>>n;
  ll ans=0;
  ll a[n][2];
  for(int i=0;i<n;i++){
      cin>>a[i][0]>>a[i][1];
  }
  ans=a[n-1][0]+1;
  for(int i=1;i<n;i++){
     if(a[i][0]-a[i-1][0]>30)continue;
     ll y=a[i][1]/(pow(4,a[i][0]-a[i-1][0]));
    a[i][1]+=max(0ll,(y-a[i][1]));
  }
  for(int i=0;i<20;i++){
      if(a[n-1][1]<=pow(4,i)){
          ans=i;break;
      }
  }
  cout<<a[n-1][0]+ans;
 }


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

void prime(int a,vector<int> &v){
    for(ll i=2;i*i<=a;i++){
        if(a%i==0)v.push_back(i);
        while(a%i==0){
            a=a/i;
        }
    }
    if(a>1)
    v.push_back(a);
}

 ll mod;
ll expmod(ll a,ll b) {
	if(b == 1) return a;
	if(b == 0) return 1;
	ll m1 = expmod(a,b/2)%mod;
	if(b%2) return ((m1*m1)%mod*a%mod)%mod;
	return (m1*m1)%mod;
}

ll gcd(ll a,ll b){
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    return (a*b)/gcd(a,b);
}

 int main(){
  int n;cin>>n;
  ll ans=0;
  ll a[n][2];
  for(int i=0;i<n;i++){
      cin>>a[i][0]>>a[i][1];
  }
  for(int i=1;i<n;i++){
     if(a[i][0]-a[i-1][0]>31ll)continue;
     ll y=a[i-1][1]/(pow(4ll,a[i][0]-a[i-1][0]));
     ll x=a[i-1][1]-y*(pow(4ll,a[i][0]-a[i-1][0]));
     if(x>0)y++;
    a[i][1]+=max(0ll,(y-a[i][1]));
  }
 // cout<<a[n-1][1]<<" ";
  for(ll i=1;i<20;i++){
      if(a[n-1][1]<=pow(4,i)){
          ans=i;break;
      }
  }
  cout<<a[n-1][0]+max(1ll,ans);
 }


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

void prime(int a,vector<int> &v){
    for(ll i=2;i*i<=a;i++){
        if(a%i==0)v.push_back(i);
        while(a%i==0){
            a=a/i;
        }
    }
    if(a>1)
    v.push_back(a);
}

 ll mod;
ll expmod(ll a,ll b) {
	if(b == 1) return a;
	if(b == 0) return 1;
	ll m1 = expmod(a,b/2)%mod;
	if(b%2) return ((m1*m1)%mod*a%mod)%mod;
	return (m1*m1)%mod;
}

ll gcd(ll a,ll b){
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    return (a*b)/gcd(a,b);
}

 int main(){
  int n;cin>>n;
  ll ans=0;
  ll a[n][2];ll j=0;
  for(int i=0;i<n;i++){
      cin>>a[i][0]>>a[i][1];
      j=max(j,a[i][0]);
      ll lg=ceil(log2(a[i][1])/2);
      ans=max(ans,a[i][0]+lg);
  }
//   for(int i=1;i<n;i++){
//      if(a[i][0]-a[i-1][0]>20ll)continue;
//      ll z=a[i][0]-a[i-1][0];
//      ll y=a[i-1][1]/(pow(4ll,z));
//      ll x=a[i-1][1]-y*(pow(4ll,z));
//      if(x>0)y++;
//     a[i][1]+=max(0ll,(y-a[i][1]));
//   }
//  // cout<<a[n-1][1]<<" ";
//   for(ll i=1;i<20;i++){
//       if(a[n-1][1]<=pow(4,i)){
//           ans=i;break;
//       }
//   }
  cout<<j+max(1ll,ans-j);
  //cout<<pow(4,32);
 }


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

void prime(int a,vector<int> &v){
    for(ll i=2;i*i<=a;i++){
        if(a%i==0)v.push_back(i);
        while(a%i==0){
            a=a/i;
        }
    }
    if(a>1)
    v.push_back(a);
}

 ll mod;
ll expmod(ll a,ll b) {
	if(b == 1) return a;
	if(b == 0) return 1;
	ll m1 = expmod(a,b/2)%mod;
	if(b%2) return ((m1*m1)%mod*a%mod)%mod;
	return (m1*m1)%mod;
}

ll gcd(ll a,ll b){
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    return (a*b)/gcd(a,b);
}

 int main(){
  int n;cin>>n;
  ll ans=0;
  ll a[n][2];
  for(int i=0;i<n;i++){
      cin>>a[i][0]>>a[i][1];
  }
  ans=a[n-1][0]+1;
  for(int i=1;i<n;i++){
     if(a[i][0]-a[i-1][0]>30)continue;
     ll y=a[i][1]/(pow(4,a[i][0]-a[i-1][0]));
    a[i][1]+=max(0ll,(y-a[i][1]));
  }
  for(int i=1;i<20;i++){
      if(a[n-1][1]<pow(4,i)){
          ans=i;break;
      }
  }
  cout<<a[n-1][0]+ans;
 }


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

void prime(int a,vector<int> &v){
    for(ll i=2;i*i<=a;i++){
        if(a%i==0)v.push_back(i);
        while(a%i==0){
            a=a/i;
        }
    }
    if(a>1)
    v.push_back(a);
}

 ll mod;
ll expmod(ll a,ll b) {
	if(b == 1) return a;
	if(b == 0) return 1;
	ll m1 = expmod(a,b/2)%mod;
	if(b%2) return ((m1*m1)%mod*a%mod)%mod;
	return (m1*m1)%mod;
}

ll gcd(ll a,ll b){
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    return (a*b)/gcd(a,b);
}

 int main(){
  int n;cin>>n;
  ll ans=0;
  ll a[n][2];
  for(int i=0;i<n;i++){
      cin>>a[i][0]>>a[i][1];
  }
  for(int i=1;i<n;i++){
     if(a[i][0]-a[i-1][0]>20ll)continue;
     ll z=a[i][0]-a[i-1][0];
     ll y=a[i-1][1]/(pow(4ll,z));
     ll x=a[i-1][1]-y*(pow(4ll,z));
     if(x>0)y++;
    a[i][1]+=max(0ll,(y-a[i][1]));
  }
 // cout<<a[n-1][1]<<" ";
  for(ll i=1;i<20;i++){
      if(a[n-1][1]<=pow(4,i)){
          ans=i;break;
      }
  }
  cout<<a[n-1][0]+max(1ll,ans);
  //cout<<pow(4,32);
 }


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

void prime(int a,vector<int> &v){
    for(ll i=2;i*i<=a;i++){
        if(a%i==0)v.push_back(i);
        while(a%i==0){
            a=a/i;
        }
    }
    if(a>1)
    v.push_back(a);
}

 ll mod;
ll expmod(ll a,ll b) {
	if(b == 1) return a;
	if(b == 0) return 1;
	ll m1 = expmod(a,b/2)%mod;
	if(b%2) return ((m1*m1)%mod*a%mod)%mod;
	return (m1*m1)%mod;
}

ll gcd(ll a,ll b){
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    return (a*b)/gcd(a,b);
}

 int main(){
  int n;cin>>n;
  ll ans=0;
  ll a[n][2];
  for(int i=0;i<n;i++){
      cin>>a[i][0]>>a[i][1];
  }
  ans=a[n-1][0]+1;
  for(int i=1;i<n;i++){
     if(a[i][0]-a[i-1][0]>30)continue;
     ll y=a[i-1][1]/(pow(4,a[i][0]-a[i-1][0]));
     ll x=a[i-1][1]-y*(pow(4,a[i][0]-a[i-1][0]));
     if(x>0)y++;
    a[i][1]+=max(0ll,(y-a[i][1]));
  }
 // cout<<a[n-1][1]<<" ";
  for(int i=1;i<20;i++){
      if(a[n-1][1]<=pow(4,i)){
          ans=i;break;
      }
  }
  cout<<a[n-1][0]+max(1ll,ans);
 }


#include<bits/stdc++.h>
#define ll long long
#define mkp make_pair
#define pb push_back
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pi 3.14159265359
using namespace std;
ll maxv=1e12;
ll pov(ll n,ll p)
{   ll count=0;
	for(n;n<=maxv&&count<p;n*=4,count++);
	return n;
}
vector<pair<ll,ll> >arr;
ll check(ll n)
{
	ll curr=1;
	ll i,flag=1;
	for(i=0;i<arr.size();i++)
	{
		ll k=arr[i].first,req=arr[i].second;
		if(k<=n)
		{
			ll p=n-k;
			curr=pov(1,p);
////			cout<<curr<<" "<<req<<" "<<n<<"\n";
			if(curr<req||(curr==req&&curr==1))
			{flag=0;
////			cout<<"AHA\n";
			}
		}
		else {
////			cout<<" n "<<n<<" K "<<k<<"\n";
			flag=0;
////			cout<<"BHAKK\n";
		}
//		flag=0;

	}
	if(flag)return 1;return 0;
}
ll bst(ll l,ll u)
{    if(l==u||(l-u)==1)return l;
	ll m=(l+u)/2;
	if(check(m))
	return bst(l,m);
	else
	return bst(m+1,u);
}
int main()
{
fastio
ll n,k,i,j,l,c;
cin>>n;
for(i=0;i<n;i++)
{
	cin>>k>>c;
	arr.pb(mkp(k,c));

}
sort(arr.begin(),arr.end());
ll ans=bst(0,1e9+100);
////cout<<check(1)<<" "<<check(2)<<"\n";
if(check(ans))cout<<ans<<"\n";
else cout<<ans+1<<"\n";
return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define mkp make_pair
#define pb push_back
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pi 3.14159265359
using namespace std;
ll maxv=1e12;
ll pov(ll n,ll p)
{   ll count=0;
	for(n;n<=maxv&&count<p;n*=4,count++);
	return n;
}
vector<pair<ll,ll> >arr;
ll check(ll n)
{
	ll curr=1;
	ll i,flag=1;
	for(i=0;i<arr.size();i++)
	{
		ll k=arr[i].first,req=arr[i].second;
		if(k<=n)
		{
			ll p=n-k;
			curr=pov(1,p);
////			cout<<curr<<" "<<req<<" "<<n<<"\n";
			if(curr<=req)
			{flag=0;
////			cout<<"AHA\n";
			}
		}
		else {
////			cout<<" n "<<n<<" K "<<k<<"\n";
			flag=0;
////			cout<<"BHAKK\n";
		}
//		flag=0;

	}
	if(flag)return 1;return 0;
}
ll bst(ll l,ll u)
{    if(l==u||(l-u)==1)return l;
	ll m=(l+u)/2;
	if(check(m))
	return bst(l,m);
	else
	return bst(m+1,u);
}
int main()
{
fastio
ll n,k,i,j,l,c;
cin>>n;
for(i=0;i<n;i++)
{
	cin>>k>>c;
	arr.pb(mkp(k,c));

}
sort(arr.begin(),arr.end());
ll ans=bst(0,1e9+100);
if(check(ans))cout<<ans<<"\n";
else cout<<ans+1<<"\n";
return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define mkp make_pair
#define pb push_back
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pi 3.14159265359
using namespace std;
ll maxv=1e12;
ll pov(ll n,ll p)
{   ll count=0;
	for(n;n<=maxv&&count<p;n*=4,count++);
	return n;
}
vector<pair<ll,ll> >arr;
ll check(ll n)
{
	ll curr=1;
	ll i,flag=1;
	for(i=0;i<arr.size();i++)
	{
		ll k=arr[i].first,req=arr[i].second;
		if(k<=n)
		{
			ll p=n-k;
			curr=pov(1,p);
////			cout<<curr<<" "<<req<<" "<<n<<"\n";
			if(curr<req)
			{flag=0;
////			cout<<"AHA\n";
			}
		}
		else {
////			cout<<" n "<<n<<" K "<<k<<"\n";
			flag=0;
////			cout<<"BHAKK\n";
		}
//		flag=0;

	}
	if(flag)return 1;return 0;
}
ll bst(ll l,ll u)
{    if(l==u||(l-u)==1)return l;
	ll m=(l+u)/2;
	if(check(m))
	return bst(l,m);
	else
	return bst(m+1,u);
}
int main()
{
fastio
ll n,k,i,j,l,c;
cin>>n;
for(i=0;i<n;i++)
{
	cin>>k>>c;
	arr.pb(mkp(k,c));

}
sort(arr.begin(),arr.end());
ll ans=bst(0,1e9+100);
if(check(ans))cout<<ans<<"\n";
else cout<<ans+1<<"\n";
return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5,MOD=1e9+7;
ll n,b,i,p[35],mx;
pair<int,int>a[N];
double num;
int main(){
    p[0]=1;
    for(i=1;i<=30;i++) p[i]=4*p[i-1];
    cin>>n;
    for(i=0;i<n;i++) cin>>a[i].first>>a[i].second;
    if(n==1){
        int ans=a[0].first+1,e=a[0].second;
        double x=e;
        while(e>4){
            x/=4;
            e=ceil(x);
            x=e;
            ans++;
        }
        cout<<ans;
        return 0;
    }
    sort(a,a+n);
    for(i=0;i<n-1;i++){
        b=a[i+1].first-a[i].first;
        num=a[i].second;
        if(b<=30) num/=p[b];
        else{
            while(b>30){
                num/=p[30];
                b-=30;
                if(num==0)break;
            }
            if(b<30) num/=p[b];
        }
        int q=ceil(num);
        mx=max(q,a[i+1].second);
        //cout<<q<<" "<<a[i+1].second<<" "<<mx<<endl;
    }
    int ans=a[n-1].first+1;
    //cout<<mx<<" "<<ans<<endl;
    double x=mx;
    while(mx>4){
        x/=4;
        mx=ceil(x);
        x=mx;
        ans++;
    }
    cout<<ans;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5,MOD=1e9+7;
ll n,b,i,p[35],mx,q;
pair<int,int>a[N];
double num;
int main(){
    p[0]=1;
    for(i=1;i<=30;i++) p[i]=4*p[i-1];
    cin>>n;
    for(i=0;i<n;i++) cin>>a[i].first>>a[i].second;
    if(n==1){
        int ans=a[0].first+1,e=a[0].second;
        double x=e;
        while(e>4){
            x/=4;
            e=ceil(x);
            x=e;
            ans++;
        }
        cout<<ans;
        return 0;
    }
    sort(a,a+n);
    for(i=0;i<n-1;i++){
        b=a[i+1].first-a[i].first;
        num=max(1ll*a[i].second,q);
        if(b<=30) num/=p[b];
        else{
            while(b>30){
                num/=p[30];
                b-=30;
                if(num==0)break;
            }
            if(b<30) num/=p[b];
        }
        q=ceil(num);
        mx=max(q,1ll*a[i+1].second);
        //cout<<num<<" "<<q<<" "<<a[i+1].second<<" "<<mx<<endl;
    }
    int ans=a[n-1].first+1;
    //cout<<mx<<" "<<ans<<endl;
    double x=mx;
    while(mx>4){
        x/=4;
        mx=ceil(x);
        x=mx;
        ans++;
    }
    cout<<ans;
    return 0;
}


// Created by ...
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'

#define vll vector< ll >
#define M 100000
#define MD 1000000007
#define pb push_back
#define rep(i,a,b) for(ll i = a; i <= b; ++i)
#define fo(i,a,b) for(int i = a; i<= b; ++i)
#define pii pair<ll,ll>
#define vec(a) vector<a >
#define all(a) a.begin(),a.end()
#define se second
#define fi first
#define inf 0xffffffff
#define inchar getchar_unlocked
#define outchar(x) putchar_unlocked(x)
#define int long long
#define endl '\n'
#define IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

using namespace std;
using ll = long long;
ll md=MD;

ll exp(ll a,ll b){ll r=1ll;while(b>0){if(b&1){r=r*(a%md);r=(r+md)%md;}b>>=1;a=(a%md)*(a%md);a=(a+md)%md;}return (r+md)%md;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll Min(ll a,ll b){if(a<b)return a; return b;}
ll Max(ll a,ll b){if(a>b)return a; return b;}
int n,v[M],cnt[M];
int32_t main() {
    IOS;

        cin>>n;
        rep(i,0,n-1)
        {
        	cin>>v[i]>>cnt[i];
        }
        int maxx=1;
        rep(i,0,n-1)
        {
        	int curr=1;
        	while(cnt[i]>(1LL<<curr))++curr;
        	curr=(curr+1)/2;
        	maxx=Max(maxx,curr+v[i]);
        }
        cout<<maxx;
        cout<<'\n';
    return 0;
}


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

int main()
{
    int n;
    cin >> n;
    int maxi=0,res=0;
    for(int i=0; i<n; i++)
    {
        int x,y,a=1,b=0;
        cin >> x >> y;
        maxi=max(x,maxi);
        while(a<y)
        {
            a*=4;
            b++;
        }
        res=max(res,x+b);
    }
    if(res==maxi)
        res++;
    cout << res;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mp make_pair
int32_t main()
{
    int n;
    cin >> n;
    vector<pair<int,int> > v;
    for(int i=0; i<n; i++)
    {
        int x,y;
        cin >> x >> y;
        v.push_back(mp(x,y));
    }
    sort(v.begin(),v.end());
    int cum=0;
    for(int i=0;i<n;i++)
    {
        int x=v[i].first;
        int y=v[i].second;
        cum=y*pow(pow(2,x),2)+max((double)0,cum-y*pow(pow(2,x),2));
    }
    if(cum==1)
        cout << 1 << endl;
    else
        cout << ceil(log2(ceil(sqrt(cum)))) << endl;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mp make_pair
int32_t main()
{
    int n;
    cin >> n;
    vector<pair<int,int> > v;
    for(int i=0; i<n; i++)
    {
        int x,y;
        cin >> x >> y;
        v.push_back(mp(x,y));
    }
    sort(v.begin(),v.end());
    int cum=0;
    for(int i=0;i<n;i++)
    {
        int x=v[i].first;
        int y=v[i].second;
        cum=y*pow(pow(2,x),2)+max((double)0,cum-y*pow(pow(2,x),2));
    }
    cout << ceil(log2(ceil(sqrt(cum)))) << endl;
}


#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main()
{
    int n;
    cin>>n;
    vector< pair<ll,ll> > v(n);
    for(int i=0;i<n;i++)
    {
        cin>>v[i].first>>v[i].second;
    }
    sort(v.begin(),v.end());
    for(int i=1;i<n;i++)
    {
        v[i].second = max((double)v[i].second, ceil( (double)v[i-1].second / 4.0 ) );
    }
    ll sz = v[n-1].first , rem = v[n-1].second;
    while( rem > 1 )
    {
        rem = ceil( (double)rem / 4.0 );
        sz++;
    }
    cout<<sz<<endl;

}


#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main()
{
    int n;
    cin>>n;
    vector< pair<int,int> > v(n);
    for(int i=0;i<n;i++)
    {
        cin>>v[i].first>>v[i].second;
    }
    sort(v.begin(),v.end());
    int last = v[n-1].first;
    for(int i=1;i<n;i++)
    {
        int dist = v[i].first - v[i-1].first;
        int prev = ceil( (double)v[i-1].second / 4.0 );
        for(int j=1;j<dist;j++)
        {
            prev = ceil( (double)prev / 4.0 );
            if(prev == 1) break;
        }

        v[i].second = max(v[i].second, prev);
    }
    int sz = v[n-1].first , rem = v[n-1].second;
    while( rem > 1 )
    {
        rem = ceil( (double)rem / 4.0 );
        sz++;
    }
    if(sz == last) sz++;
    cout<<sz<<endl;

}


#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main()
{
    int n;
    cin>>n;
    vector< pair<int,int> > v(n);
    for(int i=0;i<n;i++)
    {
        cin>>v[i].first>>v[i].second;
    }
    sort(v.begin(),v.end());
    for(int i=1;i<n;i++)
    {
        int dist = v[i].first - v[i-1].first;
        int prev = ceil( (double)v[i-1].second / 4.0 );
        for(int j=1;j<dist;j++)
        {
            prev = ceil( (double)prev / 4.0 );
            if(prev == 1) break;
        }
        v[i].second = max(v[i].second, prev);
    }
    int sz = v[n-1].first , rem = v[n-1].second;
    while( rem > 1 )
    {
        rem = ceil( (double)rem / 4.0 );
        sz++;
    }
    cout<<sz<<endl;

}


#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main()
{
    int n;
    cin>>n;
    vector< pair<int,int> > v(n);
    for(int i=0;i<n;i++)
    {
        cin>>v[i].first>>v[i].second;
    }
    sort(v.begin(),v.end());
    for(int i=1;i<n;i++)
    {
        int dist = v[i].first - v[i-1].first;
        int prev = ceil( (double)v[i-1].second / 4.0 );
        for(int j=1;j<dist;j++)
        {
            prev = ceil( (double)prev / 4.0 );
            if(prev == 1) break;
        }

        v[i].second = max(v[i].second, prev);
    }
    int sz = v[n-1].first , rem = v[n-1].second;
    while( rem > 1 )
    {
        rem = ceil( (double)rem / 4.0 );
        sz++;
    }
    cout<<max(sz,1)<<endl;

}


#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<string>
#include<cmath>
#include<vector>
#include<set>
#include<queue>
#include<stack>
#include<fstream>
#include<map>
#include<bitset>
#include<unordered_map>
#include<cstring>
#include<cctype>
using namespace std;
#define  ll long long
#define  ull unsigned long long
#define  ul unsigned long
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define sz(n) (int)n.size()
#define pb(s) push_back(s);
#define format(n) fixed<<setprecision(n)
#define finl "\n"
#define Mohammed_Atef_Hassan fast();
#define md 1000000007
#define INF LLONG_MAX
#define PI acos(-1)
#define clr(dp,n) memset(dp,n,sizeof dp)
#define ex(n) return cout<<n<<finl,0;
int dx[] = { 0, 1, 0, -1, 1, 1, -1, -1 };
int dy[] = { 1, 0, -1, 0, 1, -1, 1, -1 };
ll fix_mod(ll x, ll y)
{
	return (y + x % y) % y;
}
void fast() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);

#ifdef ONLINE_JUDGE
	//freopen("crosses.in", "r", stdin);

	//freopen("crosses.out", "w", stdout);
#endif
#ifndef ONLINE_JUDGE
	freopen("input.in", "r", stdin);
	freopen("output.out", "w", stdout);
#endif
}
int main()
{
	Mohammed_Atef_Hassan
		int n;
	cin >> n;
	vector<pair<ll, ll>>v(n);
	for (int i = 0; i < n; i++)cin >> v[i].first >> v[i].second;
	sort(all(v));
	for (int i = 1; i < n; i++)
	{
		while (v[i - 1].first != v[i].first && v[i - 1].second > v[i].second)
		{
			v[i - 1].first++;
			v[i - 1].second = v[i - 1].second / 4 + (v[i - 1].second % 4 ? 1 : 0);
		}
		if (v[i - 1].first == v[i].first)
		{
			v[i].second += max(0LL, v[i - 1].second - v[i].second);
		}
	}
	while (v.back().second > 1)
	{
		v.back().first++;
		v.back().second= v.back().second / 4 + (v.back().second % 4 ? 1 : 0);
	}
	cout << v.back().first << finl;
}


#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<string>
#include<cmath>
#include<vector>
#include<set>
#include<queue>
#include<stack>
#include<fstream>
#include<map>
#include<bitset>
#include<unordered_map>
#include<cstring>
#include<cctype>
using namespace std;
#define  ll long long
#define  ull unsigned long long
#define  ul unsigned long
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define sz(n) (int)n.size()
#define pb(s) push_back(s);
#define format(n) fixed<<setprecision(n)
#define finl "\n"
#define Mohammed_Atef_Hassan fast();
#define md 1000000007
#define INF LLONG_MAX
#define PI acos(-1)
#define clr(dp,n) memset(dp,n,sizeof dp)
#define ex(n) return cout<<n<<finl,0;
int dx[] = { 0, 1, 0, -1, 1, 1, -1, -1 };
int dy[] = { 1, 0, -1, 0, 1, -1, 1, -1 };
ll fix_mod(ll x, ll y)
{
	return (y + x % y) % y;
}
void fast() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);

#ifdef ONLINE_JUDGE
	//freopen("crosses.in", "r", stdin);

	//freopen("crosses.out", "w", stdout);
#endif
#ifndef ONLINE_JUDGE
	freopen("input.in", "r", stdin);
	freopen("output.out", "w", stdout);
#endif
}
int main()
{
	Mohammed_Atef_Hassan
		int n;
	cin >> n;
	vector<pair<ll, ll>>v(n);
	for (int i = 0; i < n; i++)cin >> v[i].first >> v[i].second;
	sort(all(v));
	v[0].first++;
	v[0].second = v[0].second / 4 + (v[0].second % 4 ? 1 : 0);
	if (n > 1)
	{
		v.back().first++;
		v.back().second = v.back().second / 4 + (v.back().second % 4 ? 1 : 0);
	}

	for (int i = 1; i < n; i++)
	{
		while (v[i - 1].first != v[i].first && v[i - 1].second > v[i].second)
		{
			v[i - 1].first++;
			v[i - 1].second = v[i - 1].second / 4 + (v[i - 1].second % 4 ? 1 : 0);
		}
		if (v[i - 1].first == v[i].first)
		{
			v[i].second += max(0LL, v[i - 1].second - v[i].second);
		}
	}
	while (v.back().second > 1)
	{
		v.back().first++;
		v.back().second= v.back().second / 4 + (v.back().second % 4 ? 1 : 0);
	}
	cout << v.back().first << finl;
}


#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<string>
#include<cmath>
#include<vector>
#include<set>
#include<queue>
#include<stack>
#include<fstream>
#include<map>
#include<bitset>
#include<unordered_map>
#include<cstring>
#include<cctype>
using namespace std;
#define  ll long long
#define  ull unsigned long long
#define  ul unsigned long
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define sz(n) (int)n.size()
#define pb(s) push_back(s);
#define format(n) fixed<<setprecision(n)
#define finl "\n"
#define Mohammed_Atef_Hassan fast();
#define md 1000000007
#define INF LLONG_MAX
#define PI acos(-1)
#define clr(dp,n) memset(dp,n,sizeof dp)
#define ex(n) return cout<<n<<finl,0;
int dx[] = { 0, 1, 0, -1, 1, 1, -1, -1 };
int dy[] = { 1, 0, -1, 0, 1, -1, 1, -1 };
ll fix_mod(ll x, ll y)
{
	return (y + x % y) % y;
}
void fast() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);

#ifdef ONLINE_JUDGE
	//freopen("crosses.in", "r", stdin);

	//freopen("crosses.out", "w", stdout);
#endif
#ifndef ONLINE_JUDGE
	freopen("input.in", "r", stdin);
	freopen("output.out", "w", stdout);
#endif
}
int main()
{
	Mohammed_Atef_Hassan
		int n;
	cin >> n;
	vector<pair<ll, ll>>v(n);
	for (int i = 0; i < n; i++)cin >> v[i].first >> v[i].second;
	sort(all(v));
	v[0].first++;
	v[0].second = v[0].second / 4 + (v[0].second % 4 ? 1 : 0);
	for (int i = 1; i < n; i++)
	{
		while (v[i - 1].first != v[i].first && v[i - 1].second > v[i].second)
		{
			v[i - 1].first++;
			v[i - 1].second = v[i - 1].second / 4 + (v[i - 1].second % 4 ? 1 : 0);
		}
		if (v[i - 1].first == v[i].first)
		{
			v[i].second += max(0LL, v[i - 1].second - v[i].second);
		}
	}
	while (v.back().second > 1)
	{
		v.back().first++;
		v.back().second= v.back().second / 4 + (v.back().second % 4 ? 1 : 0);
	}
	cout << v.back().first << finl;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
using namespace std;
using namespace __gnu_pbds;
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
//#define int long long
// int dx[]={-1,1,0,0}; int dy[]={0,0,1,-1};
// int dx[]={2,2,-2,-2,1,1,-1,-1}; int dy[]={1,-1,1,-1,2,-2,2,-2};
const long long mod = 1e9 + 7;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> ii;
typedef vector< pair< int, int > > vii;
typedef map<int, int> mii;
typedef pair<int, ii> pip;
typedef pair<ii, int> ppi;
#define arrinp(arr,init,final,size,type) type* arr=new type[size];for(int i=init;i<final;i++)cin>>arr[i];
#define cr2d(arr,n,m,t) t**arr=new t*[n];for(int i=0;i<n;i++)arr[i]=new t[m];
#define w(t) int t;cin>>t; while(t--)
#define takeInp(n) int n;cin>>n;
#define fr(i,init,final) for(int i=init;i<final;i++)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>  nds;
vi init(string s)
{
	istringstream sin(s);
	int n;
	vi arr;
	while(sin>>n)arr.push_back(n);
	return arr;
}
int pow(int x, int y)
{
	if(y==0)return 1;
	int u=pow(x,y/2);
	u=u*u;
	if(y%2)u=x*u;
	return u;

}
int gcd(int a,int b)
{
	if(a<b)return gcd(b,a);
	return (b==0?a:(a%b?gcd(b,a%b):b));
}
int gcd_e(int a,int b,int &x,int &y)
{

	if(b==0){x=1; y=0; return a;}
	int x1,y1;
	int p=gcd_e(b,a%b,x1,y1);
	x=y1;
	y=x1-(a/b)*y1;
	return p;
}
signed main()
{
	IOS
	int n;
	cin>>n;
	ii arr[n];
	fr(i,0,n)cin>>arr[i].fi>>arr[i].se;
	sort(arr,arr+n);
	fr(i,1,n)
	{
	  arr[i].se+=ceil(arr[i-1].se/pow(4,arr[i].fi-arr[i-1].fi));

	}
	cout<<arr[n-1].fi+ceil(log((double)arr[n-1].se)/log(4.00));

}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
using namespace std;
using namespace __gnu_pbds;
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
//#define int long long
// int dx[]={-1,1,0,0}; int dy[]={0,0,1,-1};
// int dx[]={2,2,-2,-2,1,1,-1,-1}; int dy[]={1,-1,1,-1,2,-2,2,-2};
const long long mod = 1e9 + 7;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> ii;
typedef vector< pair< int, int > > vii;
typedef map<int, int> mii;
typedef pair<int, ii> pip;
typedef pair<ii, int> ppi;
#define arrinp(arr,init,final,size,type) type* arr=new type[size];for(int i=init;i<final;i++)cin>>arr[i];
#define cr2d(arr,n,m,t) t**arr=new t*[n];for(int i=0;i<n;i++)arr[i]=new t[m];
#define w(t) int t;cin>>t; while(t--)
#define takeInp(n) int n;cin>>n;
#define fr(i,init,final) for(int i=init;i<final;i++)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>  nds;
vi init(string s)
{
	istringstream sin(s);
	int n;
	vi arr;
	while(sin>>n)arr.push_back(n);
	return arr;
}
int pow(int x, int y)
{
	if(y==0)return 1;
	int u=pow(x,y/2);
	u=u*u;
	if(y%2)u=x*u;
	return u;

}
int gcd(int a,int b)
{
	if(a<b)return gcd(b,a);
	return (b==0?a:(a%b?gcd(b,a%b):b));
}
int gcd_e(int a,int b,int &x,int &y)
{

	if(b==0){x=1; y=0; return a;}
	int x1,y1;
	int p=gcd_e(b,a%b,x1,y1);
	x=y1;
	y=x1-(a/b)*y1;
	return p;
}
signed main()
{
	IOS
	int n;
	cin>>n;
	ii arr[n];
	fr(i,0,n)cin>>arr[i].fi>>arr[i].se;

	sort(arr,arr+n);
	fr(i,1,n)
	{
	  if(log(arr[i].fi-arr[i-1].fi)/log(4.00)>arr[i-1].se)arr[i].se+=1; else arr[i].se+=ceil(arr[i-1].se/pow(4,arr[i].fi-arr[i-1].fi));

	}
	cout<<arr[n-1].fi+(ceil(log((double)arr[n-1].se)/log(4.00))?ceil(log((double)arr[n-1].se)/log(4.00)):1);

}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
using namespace std;
using namespace __gnu_pbds;
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
//#define int long long
// int dx[]={-1,1,0,0}; int dy[]={0,0,1,-1};
// int dx[]={2,2,-2,-2,1,1,-1,-1}; int dy[]={1,-1,1,-1,2,-2,2,-2};
const long long mod = 1e9 + 7;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> ii;
typedef vector< pair< int, int > > vii;
typedef map<int, int> mii;
typedef pair<int, ii> pip;
typedef pair<ii, int> ppi;
#define arrinp(arr,init,final,size,type) type* arr=new type[size];for(int i=init;i<final;i++)cin>>arr[i];
#define cr2d(arr,n,m,t) t**arr=new t*[n];for(int i=0;i<n;i++)arr[i]=new t[m];
#define w(t) int t;cin>>t; while(t--)
#define takeInp(n) int n;cin>>n;
#define fr(i,init,final) for(int i=init;i<final;i++)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>  nds;
vi init(string s)
{
	istringstream sin(s);
	int n;
	vi arr;
	while(sin>>n)arr.push_back(n);
	return arr;
}
int pow(int x, int y)
{
	if(y==0)return 1;
	int u=pow(x,y/2);
	u=u*u;
	if(y%2)u=x*u;
	return u;

}
int gcd(int a,int b)
{
	if(a<b)return gcd(b,a);
	return (b==0?a:(a%b?gcd(b,a%b):b));
}
int gcd_e(int a,int b,int &x,int &y)
{

	if(b==0){x=1; y=0; return a;}
	int x1,y1;
	int p=gcd_e(b,a%b,x1,y1);
	x=y1;
	y=x1-(a/b)*y1;
	return p;
}
signed main()
{
	IOS
	int n;
	cin>>n;
	ii arr[n];
	fr(i,0,n)cin>>arr[i].fi>>arr[i].se;
	sort(arr,arr+n);
	fr(i,1,n)
	{
	  if(log(arr[i].fi-arr[i-1].fi)/log(4.00)>arr[i-1].se)arr[i].se+=1; else arr[i].se+=ceil(arr[i-1].se/pow(4,arr[i].fi-arr[i-1].fi));

	}
	cout<<arr[n-1].fi+ceil(log((double)arr[n-1].se)/log(4.00));

}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
using namespace std;
using namespace __gnu_pbds;
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
//#define int long long
// int dx[]={-1,1,0,0}; int dy[]={0,0,1,-1};
// int dx[]={2,2,-2,-2,1,1,-1,-1}; int dy[]={1,-1,1,-1,2,-2,2,-2};
const long long mod = 1e9 + 7;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> ii;
typedef vector< pair< int, int > > vii;
typedef map<int, int> mii;
typedef pair<int, ii> pip;
typedef pair<ii, int> ppi;
#define arrinp(arr,init,final,size,type) type* arr=new type[size];for(int i=init;i<final;i++)cin>>arr[i];
#define cr2d(arr,n,m,t) t**arr=new t*[n];for(int i=0;i<n;i++)arr[i]=new t[m];
#define w(t) int t;cin>>t; while(t--)
#define takeInp(n) int n;cin>>n;
#define fr(i,init,final) for(int i=init;i<final;i++)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>  nds;
vi init(string s)
{
	istringstream sin(s);
	int n;
	vi arr;
	while(sin>>n)arr.push_back(n);
	return arr;
}
int pow(int x, int y)
{
	if(y==0)return 1;
	int u=pow(x,y/2);
	u=u*u;
	if(y%2)u=x*u;
	return u;

}
int gcd(int a,int b)
{
	if(a<b)return gcd(b,a);
	return (b==0?a:(a%b?gcd(b,a%b):b));
}
int gcd_e(int a,int b,int &x,int &y)
{

	if(b==0){x=1; y=0; return a;}
	int x1,y1;
	int p=gcd_e(b,a%b,x1,y1);
	x=y1;
	y=x1-(a/b)*y1;
	return p;
}
signed main()
{
	IOS
	int n;
	cin>>n;
	int maxd=0;
	int p=0;
	fr(i,0,n)
	{
		int a,b;
		cin>>a>>b;
		maxd=max(maxd,a);
		int s=1,m=0;
		while(s<b)
		{
			s*=4;
			m++;
		}
		p=max(p,a+m);

	}
	if(maxd==p)p++;
	cout<<p<<endl;

}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<long long, long long> pll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> ii;
typedef vector<pair<ll,ll> > vii;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<pair<long long,long long> > vpll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<ll,pair<ll,ll> > iii;
#define PI 3.141592653589793
#define mod (ll)(1000*1000*1000+7)
//# define N 300005
template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=((ans%m)*(a%m))%m; b/=2; a=((a%m)*(a%m))%m; } return ans%m; }
# define INF (ll)1e18+5LL
# define LN 20
typedef pair<ll,pair<ll,ll> > pii;
# define INF1 (ll)4e9+2
# define maxn 200006
# define offset 1005

/*************************************************
struct Coupon {
    ll l;
    ll r;
    ll id;

    Coupon(ll l, ll r, ll id): l(l), r(r), id(id) {} // Initialization

    bool operator<(const Coupon& c) { // Sorting
        return l < c.l;
    }
};

**************************************************/
int main()
{
  IOS;
  int n;
  cin >> n;
  ll ans=0;
  ll k[n+1],a[n+1];
  for(int i=1;i<=n;i++)
  {
     cin >> k[i] >> a[i];
     int cnt=1;
     for(ll j=4;j<=INF1;j*=4)
     {
       cnt++;
       if(a[i]<=j)
        {
           ans=max(ans,(k[i]+cnt-1));
           //trace2(a[i],j);
           break;
        }
     }
  }

  cout << ans;
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<long long, long long> pll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> ii;
typedef vector<pair<ll,ll> > vii;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<pair<long long,long long> > vpll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<ll,pair<ll,ll> > iii;
#define PI 3.141592653589793
#define mod (ll)(1000*1000*1000+7)
//# define N 300005
template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=((ans%m)*(a%m))%m; b/=2; a=((a%m)*(a%m))%m; } return ans%m; }
# define INF (ll)1e18+5LL
# define LN 20
typedef pair<ll,pair<ll,ll> > pii;
# define INF1 (ll)1e9+2
# define maxn 200006
# define offset 1005

/*************************************************
struct Coupon {
    ll l;
    ll r;
    ll id;

    Coupon(ll l, ll r, ll id): l(l), r(r), id(id) {} // Initialization

    bool operator<(const Coupon& c) { // Sorting
        return l < c.l;
    }
};

**************************************************/
int main()
{
  IOS;
  int n;
  cin >> n;
  ll ans=0;
  ll k[n+1],a[n+1];
  for(int i=1;i<=n;i++)
  {
     cin >> k[i] >> a[i];
     int cnt=1;
     for(ll j=4;j<=INF1;j*=4)
     {
       cnt++;
       if(a[i]<=j)
        {
           ans=max(ans,(k[i]+cnt-1));
           //trace2(a[i],j);
           break;
        }
     }
  }

  cout << ans;
}


#pragma GCC Optimize ("O3")
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N=1e5+5,OO=0x3f3f3f3f;
int main(){
    //freopen("inp.txt","r",stdin);
    int n,dif,t;  ll res;  pair<int,int>arr[N];
    scanf("%d",&n);
    for(int i=0;i<n;i++)scanf("%d%d",&arr[i].first,&arr[i].second);
    sort(arr,arr+n);
    for(int i=0;i<n-1;i++){
        //cout<<arr[i].first<<" "<<arr[i].second<<endl;
        dif=arr[i+1].first-arr[i].first;
        if(dif>29)continue;
        res=(1<<(dif+1))*arr[i+1].second;
        if(res>=arr[i].second)continue;
        t=arr[i].second-res;
        arr[i+1].second+=ceil(double(t)/double(1<<(dif+1)));
    }
            //cout<<arr[n-1].first<<" "<<arr[n-1].second<<endl;
    if(arr[n-1].second==1)printf("%d",arr[n-1].first+1);
    else printf("%d",int(arr[n-1].first+ceil(log2(arr[n-1].second))-1));
}


#pragma GCC Optimize ("O3")
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N=1e5+5,OO=0x3f3f3f3f;
int main(){
    //freopen("inp.txt","r",stdin);
    int n;  ll res,dif,t;  pair<ll,ll>arr[N];
    scanf("%d",&n);
    for(int i=0;i<n;i++)scanf("%lld%lld",&arr[i].first,&arr[i].second);
    sort(arr,arr+n);
    for(int i=0;i<n-1;i++){
        dif=2*(arr[i+1].first-arr[i].first);
        if(dif>=30)continue;
        res=(1<<dif)*arr[i+1].second;
        if(res>=arr[i].second)continue;
        t=arr[i].second-res;
        arr[i+1].second+=ceil(double(t)/double(1<<dif));
    }
    if(arr[n-1].second==1)printf("%d",arr[n-1].first+1);
    else printf("%lld",(ll)ceil(log2(arr[n-1].second)/2+arr[n-1].first));
}


#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <unordered_map>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(bool x) {cerr << (x ? "true" : "false");}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}

template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";}
template <typename T, typename... V>void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define gcd __gcd
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f
#define MOD 1000000007
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

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

int main() {

	long long n; cin >> n;
	vector<vector<long long>> v(n, vector<long long>(2, 0));
	for (long long i = 0; i <= n - 1; i++) cin >> v[i][0] >> v[i][1];

	long long lo = 0, hi = 1e18;
	long long ans = -1;

	while (lo <= hi) {
		long long mid = ((lo + hi) >> 1);
		bool flg = true;
		for (auto p : v) {
			if (p[0] >= mid) {flg = false; break;}
			if (log2(p[1]) > 2 * mid - 2 * p[0]) {flg = false; break;}
		}

		if (flg) {
			ans = mid;
			hi = mid - 1;
		}
		else lo = mid + 1;
	}

	cout << ans;

	return 0;
}


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

int main()
{
int n;
    cin>>n;
    int ans=0,t=0;
    for(int i=0;i<n;i++)
    {
        int k,a;
        cin>>k>>a;
        t=max(k,t);
        int cn=1,l=0;
        while(cn<a)
        {
            l++;
            cn*=4;
        }
        ans=max(ans,k+l);
    }
    if(ans==t)
        ans++;
    cout<<ans;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define endl '\n'

int main(){

  ios_base :: sync_with_stdio(false);
  cin.tie(NULL);

  int n;
  cin >> n;
  int ans = 0;
  int mxK = 0;

  for(int i=0;i<n;i++){
    int k,a;
    cin >> k >> a;
    int lg = ceil(log2(a)/2);
    mxK = max(mxK,k);
    ans = max(ans,k + lg);
  }

  cout << ans + (mxK == ans) << endl;

  return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define endl '\n'

int main(){

  ios_base :: sync_with_stdio(false);
  cin.tie(NULL);

  int n;
  cin >> n;
  vector <pair <long long,long long> > vet(n);

  for(int i=0;i<n;i++){
    cin >> vet[i].first >> vet[i].second;
  }

  sort(vet.begin(),vet.end());

  stack <pair<long long,long long> > s;

  for(int i=n-1;i>=0;i--){
    s.push({vet[i].first,vet[i].second});
  }

  long long ans = 0;

  while(!s.empty()){
    long long k = s.top().first;
    long long a = s.top().second;
    s.pop();
    ans = max(ans,k);
    if(a <= 4)
      continue;

    if(!s.empty() && s.top().first == k+1){
      s.top().second += a/4;
    }else{
      s.push({k+1,a/4});
    }
  }

  cout << ans+1 << endl;

  return 0;
}


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

using ll = long long;

void bober () {
	int n;
	cin >> n;
	vector <pair <int, int>> a(n+1);
	for (int i=1; i<=n; i++) {
		cin >> a[i].first >> a[i].second;
	}
	sort(a.begin()+1, a.end());
	int l = 1, cnt = a[1].second, st = a[1].first;
	while (l <= n) {
		if (l == n && cnt <= 4) {
			cout << st+1;
			return;
		}
		st ++;
		cnt = (cnt+3)/4;
		if (l+1 <= n && a[l+1].first == st) {
			l ++;
			cnt = max(a[l].second, cnt);
		}
	}

}

int main () {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int q;
	q = 1; //cin >> q;
	while (q--) {
		bober ();
	}
	return 0;
}


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

using ll = long long;

void bober () {
	int n;
	cin >> n;
	vector <pair <int, int>> a(n+1);
	for (int i=1; i<=n; i++) {
		cin >> a[i].first >> a[i].second;
	}
	sort(a.begin()+1, a.end());
	int l = 0, cnt = a[0].second, st = a[0].first;
	while (l <= n) {
		if (cnt <= 4) {
			if (l == n) {
				cout << st;
				return;
			}
			l ++;
			cnt = a[l].second+1;
			st = a[l].first;
		}
		st ++;
		cnt = (cnt+3)/4;
		if (l+1 <= cnt && a[l+1].first == st) {
			l ++;
			cnt += a[l].second;
		}
	}

}

int main () {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int q;
	q = 1; //cin >> q;
	while (q--) {
		bober ();
	}
	return 0;
}


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

using ll = long long;

void bober () {
	int n;
	cin >> n;
	vector <pair <int, int>> a(n+1);
	for (int i=1; i<=n; i++) {
		cin >> a[i].first >> a[i].second;
	}
	sort(a.begin()+1, a.end());
	int l = 1, cnt = a[1].second, st = a[1].first;
	while (l <= n) {
		if (l == n && cnt <= 4) {
			cout << st+1;
			return;
		}
		st ++;
		cnt = (cnt+3)/4;
		if (l+1 <= n && a[l+1].first == st) {
			l ++;
			cnt = max(a[l].second, cnt);
		}
		else {
			if (l+1 <= n && a[l+1].first-a[l].first > 31) {
				cnt = a[l+1].second;
				st = a[l+1].first;
				l ++;
			}
		}
	}

}

int main () {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int q;
	q = 1; //cin >> q;
	while (q--) {
		bober ();
	}
	return 0;
}


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

using ll = long long;

void bober () {
	int n;
	cin >> n;
	vector <pair <int, int>> a(n+1);
	for (int i=1; i<=n; i++) {
		cin >> a[i].first >> a[i].second;
	}
	sort(a.begin()+1, a.end());
	int l = 1, cnt = a[1].second, st = a[1].first;
	while (l <= n) {
		if (l == n && cnt <= 4) {
			cout << st+1;
			return;
		}
		st ++;
		cnt = (cnt+3)/4;
		if (l+1 <= n && a[l+1].first == st) {
			l ++;
			cnt = max(a[l].second, cnt);
		}
		else {
			if (l+1 <= n && a[l+1].first-a[l].first > 31) {
				cnt = a[l+1].first;
				st = a[l+1].second;
				l ++;
			}
		}
	}

}

int main () {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int q;
	q = 1; //cin >> q;
	while (q--) {
		bober ();
	}
	return 0;
}


import sys

n,k = map(int,sys.stdin.readline().strip().split())

#n is the number of decimals
#k is the number of changes allowed

s = list(input())
s = [int(x) for x in s]

left = 0

if len(s) == 1 and k!= 0:
    s[0] = 0

else:
    if s[0] != 1 and k!= 0:
        s[0] = 1
        k -= 1
    left += 1

    while k != 0 and left < len(s):
        if s[left] != 0:
            s[left] = 0
            left += 1
            k -=1
        else:
            left += 1

s = [str(x) for x in s]

print("".join(s))


n,k = input().split(' ')
n = int(n)
k = int(k)

#n is the number of decimals
#k is the number of changes allowed

s = list(input())
s = [int(x) for x in s]

left = 0

if len(s) == 1:
    s[0] = 0

elif len(s) != 1 and k != 0:
    s[0] = 1
    k -= 1
    left += 1

    while k!= 0:
        if s[left] != 0:
            s[left] = 0
            left += 1
            k -=1
        else:
            left += 1

s = [str(x) for x in s]

print("".join(s))


import sys

n,k = map(int,sys.stdin.readline().strip().split())

#n is the number of decimals
#k is the number of changes allowed

s = list(input())
s = [int(x) for x in s]

left = 0

if len(s) == 1 and k>0:
    s[0] = 0

elif len(s) != 1 and k != 0:
    s[0] = 1
    k -= 1
    left += 1

    while k!= 0 and left < len(s):
        if s[left] != 0:
            s[left] = 0
            left += 1
            k -=1
        else:
            left += 1

s = [str(x) for x in s]

print("".join(s))


n,k = input().split(' ')
n = int(n)
k = int(k)

#n is the number of decimals
#k is the number of changes allowed

s = list(input())
s = [int(x) for x in s]

left = 0

print(s)

if s[left] > 1:
    s[0]= 1
    left += 1
    while k >1:
        if s[left]!= 0:
            s[left] = 0
            left += 1
            k-=1
        else:
            left += 1
elif len(s) == 1:
    s[left] = 0

else:
    left += 1
    while k >1:
        if s[left]!= 0:
            s[left] = 0
            left += 1
            k-=1
        else:
            left += 1

s = [str(x) for x in s]

print("".join(s))


n,k = input().split(' ')
n = int(n)
k = int(k)

#n is the number of decimals
#k is the number of changes allowed

s = list(input())
s = [int(x) for x in s]

left = 0

print(s)

if s[left] > 1:
    s[0]= 1
    left += 1
    while k >1:
        if s[left]!= 0:
            s[left] = 0
            left += 1
            k-=1
        else:
            left += 1
elif len(s) == 1:
    s[left] = 0

else:
    left += 1
    while k >1:
        if s[left]!= 0:
            s[left] = 0
            left += 1
            k-=1
        else:
            left += 1

print(s)


import sys

n,k = map(int,sys.stdin.readline().strip().split())

#n is the number of decimals
#k is the number of changes allowed

s = list(input())
s = [int(x) for x in s]

left = 0

if len(s) == 1:
    s[0] = 0

elif len(s) != 1 and k != 0:
    s[0] = 1
    k -= 1
    left += 1

    while k!= 0:
        if s[left] != 0:
            s[left] = 0
            left += 1
            k -=1
        else:
            left += 1

s = [str(x) for x in s]

print("".join(s))


import sys

n,k = map(int,sys.stdin.readline().strip().split())

#n is the number of decimals
#k is the number of changes allowed

s = list(input())
s = [int(x) for x in s]

left = 0

while k!= 0:
    if len(s) == 1:
        s[0] = 0

    else:
        if s[0] != 1:
            s[0] = 1
            k -= 1
        left += 1

        while k != 0 and left < len(s):
            if s[left] != 0:
                s[left] = 0
                left += 1
                k -=1
            else:
                left += 1

s = [str(x) for x in s]

print("".join(s))


n, k = map(int, input().split())
c = input()
if n == 1 and k > 0:
    print(0)
else:
    res = ""
    for i in range(k+c.count('0')):
        if i == 0:
            res += '1'
        else:
            res += '0'
    print(res + c[k+c.count('0'):])


n, k = map(int, input().split())
c = input()
if n == 1 and k > 0:
    print(0)
else:
    res = ""
    t = min(n,k+c.count('0'))
    for i in range(t):
        if i == 0:
            res += '1'
        else:
            res += '0'
    print(res + c[t:])


n, k = map(int, input().split())
c = input()
i = 0
while i < n:
    #print(k)
    if (i == 0 and c[0]>'1' and k > 0):
        print(1, end ='')
        k -= 1
    elif ((i > 0 and c[i] != '0'  or n == 1) and k > 0):
        print(0,end='')
        k -= 1
    else:
        print(c[i], end='')
    i += 1
   # print(k)


n, k = map(int, input().split())
c = int(input())
a = [0 for i in range(n)]
for i in range(n):
    a[-i-1] = c%10
    c = c//10
if a[0] != 1:
    a[0] = 1
    k -= 1
    i = 1
while k > 0 and i < n:
    if a[i]:
        a[i] = 0
        k -= 1
    i+=1
if len(a) == 1:
    print(0)
else:
    for i in range(n):
        print(a[i], end='')


n, k = map(int, input().split())
c = input()
if n == 1 and k > 0:
    print(0)
else:
    res = ""
    #t = min(n,k+c.count('0'))
    e = k
    j = 0
    while e > 0 and j < n:
        if j == 0 and c[j] != '1':
            e-=1
        elif j > 0 and c[j] != '0':
            e-=1
        j+=1
    for i in range(j):
        if i == 0:
            res += '1'
        else:
            res += '0'
    print(res + c[j:])


n,k=map(int,input().split())
s=list(input())
if n==1 and s[0]!='0':
    from sys import exit
    print(0);exit()
if s[0]!='1':s[0]='1';k-=1
for i in range(1,n):
    if k==0:break
    if s[i]!='0':s[i]='0';k-=1
print(''.join(s))


n,k=map(int,input().split())
s=list(input())
if n==1 and s[0]!='0':
    from sys import exit
    print(0);exit()
if s[0]!='1' and k>0\:s[0]='1';k-=1
for i in range(1,n):
    if k==0:break
    if s[i]!='0':s[i]='0';k-=1
print(''.join(s))


n,k=map(int,input().split())
s=list(input())
from sys import exit
if s[0]=='0':print(0);exit()
else:
    if n==1:
        if k>0:print(0)
        else:print(s[0])
        exit()
    else:
        if k>0:
            if s[0]!='1':
                s[0]='1';k-=1
for i in range(1,n):
    if k==0:break
    if s[i]!='0':s[i]='0';k-=1
print(''.join(s))


n,k=map(int,input().split())
s=list(input())
from sys import exit
if s[0]=='0':print(0);exit()
else:
    if n==1:
        if k>0:print(0)
        else:print(s[0])
        exit()
    else:
        if k>0:s[0]='1';k-=1
for i in range(1,n):
    if k==0:break
    if s[i]!='0':s[i]='0';k-=1
print(''.join(s))


n,k=map(int,input().split())
s=list(input())
if n==1 and s[0]!='0':
    from sys import exit
    print(0);exit()
if s[0]!='1' and k>0:s[0]='1';k-=1
for i in range(1,n):
    if k==0:break
    if s[i]!='0':s[i]='0';k-=1
print(''.join(s))


n,k=map(int,input().split())
s=list(input())
if s[0]!='0' and n==1 and k==1:
    from sys import exit
    print('0');exit()
if s[0]!='1' and k>0:s[0]='1';k-=1
for i in range(1,n):
    if k==0:break
    if s[i]!='0':s[i]='0';k-=1
print(''.join(s))


n,k=map(int,input().split())
s=list(input())
from sys import exit
if s[0]=='0':print(0);exit()
else:
    if n==1:
        if k>0:print(0)
        else:print(s[0])
        exit()
    else:
        if k>0:s[0]='1';k-=1;exit()
for i in range(1,n):
    if k==0:break
    if s[i]!='0':s[i]='0';k-=1
print(''.join(s))


n,k= map(int,input().split())
a= int(input())
if k==0:
    print(a)
elif n==1:
    if k==0:
        print(a)
    else:
        print("0")
else:
    l=''
    c=0
    if str(a)[0]!="1":
        c+=1
        l+="1"
    else:
        c+=0
        l+="1"
    m=1
    for i in range(1,n):
        while c<k:
            if str(a)[i]!=0:
                l+="0"
                c+=1
            else:
                l+=str(a)[i]
            m+=1
    p=''
    p+="1"
    for i in range(1,n):
        if l[-1]=="0" and str(a)[i]!="0":
            p+="0"
            l=l[:len(l)-1]
        else:
            p+= str(a)[i]
    print(p)


n,k= map(int,input().split())
a= input()
if k==0:
    print(a)
elif n==1:
    if k==0:
        print(a)
    else:
        print("0")
else:
    s= list(a)
    i=0
    if (s[0]!='1'):
        s[0]='1'
        k-=1
    i=1
    while(i<n):
        if (s[i]!='0' and k>0):
            s[i]='0'
            k-=1
        if (k==0):
            break
        i+=1
    print("".join(s))


n,k= map(int,input().split())
a= int(input())
if k==0:
    print(a)
elif n==1:
    if k==0:
        print(a)
    else:
        print("0")
else:
    l=''
    c=0
    if str(a)[0]!="1":
        c+=1
        l+="1"
    else:
        c+=0
        l+="1"
    m=1
    p="1"
    for i in range(1,n):
        while c<k:
            if str(a)[i]!=0:
                l+="0"
                c+=1
            else:
                l+=str(a)[i]
            m+=1
        if l[-1]=="0" and str(a)[i]!="0":
            p+="0"
            l=l[:len(l)-1]
        else:
            p+= str(a)[i]
    print(p)


n,k= map(int,input().split())
a= int(input())
if k==0:
    print(a)
elif n==1:
    if k==0:
        print(a)
    else:
        print("0")
else:
    s= list(str(a))
    i=0
    if (s[0]!='1'):
        s[0]='1'
        k-=1
    i=1
    while(i<n):
        if (s[i]!='0' and k>0):
            s[i]='0'
            k-=1

        if (k==0):
            break
        i+=1
    print("".join(s))


n,k= map(int,input().split())
a= int(input())
if k==0:
    print(a)
elif n==1:
    if k==0:
        print(a)
    else:
        print("0")
else:
    l=''
    c=0
    if str(a)[0]!="1":
        c+=1
        l+="1"
    else:
        c+=0
        l+="1"
    m=1
    for i in range(1,n):
        while c<k:
            if str(a)[i]!=0:
                l+="0"
                c+=1
            else:
                l+="0"
                c+=0
        m+=1

    o= n-k
    l+= str(a)[o+1:]
    if len(l)==n:
        print(l)
    else:
        print(l[:n])


n,k= map(int,input().split())
a= int(input())
if k==0:
    print(a)
elif n==1:
    if k==0:
        print(a)
    else:
        print("0")
else:
    l=''
    c=0
    if str(a)[0]!="1":
        c+=1
        l+="1"
    else:
        c+=0
        l+="1"
    m=1
    for i in range(n):
        while c<k or m!=n:
            if str(a)[i]!=0:
                l+="0"
                c+=1
                m+=1
            else:
                l+="0"
                c+=0
                m+=1
    print(l)


m, k = input().split()
k = int(k)
n = input()
if n == '0':
    print(0)
elif k == 0:
    print(n)
else:
    if n[0] != '1':
        k -= 1
    awn = '1'
    for i in n[1:]:
        if i != '0' and k != 0:
            k -= 1
            awn += '0'
        else:
            awn += i
    print(awn)


m, k = input().split()
k = int(k)
n = input()
if k == 0:
    print(n)
else:
    if n[0] != '1':
        k -= 1
    awn = '1'
    for i in n[1:]:
        if i != '0' and k != 0:
            k -= 1
            awn += '0'
        else:
            awn += i
    print(awn)


m, k = input().split()
k = int(k)
n = input()
if k == 0:
    print(n)
elif n == '0':
    print(0)
else:
    if n[0] != '1':
        k -= 1
    awn = '1'
    for i in n[1:]:
        if i != '0' and k != 0:
            k -= 1
            awn += '0'
        else:
            awn += i
    print(awn)


m, k = input().split()
k = int(k)
n = input()
if k == 0:
    print(n)
elif m == '1':
    print(0)
else:
    if n[0] != '1':
        k -= 1
    awn = '1'
    for i in n[1:]:
        if i != '0' and k != 0:
            k -= 1
            awn += '0'
        else:
            awn += i
    print(awn)


n,k  =list(map(int,input().split()))
a = list(input())
if a[0]=="1":
    i=1
    while i<n and k>0:
        if a[i]!="0":
            a[i]="0"
            k=k-1
        i+=1
    print("".join(a))
else:
    i=1
    a[0]="1"
    k=k-1
    while i<n and k>0:
        if a[i]!="0":
            a[i]="0"
            k=k-1
        i+=1
    print("".join(a))


n,k = list(map(int,input().split()))
a = list(input())
if k==0:
    print("".join(a))
else:
    a[0]=1
    p = 1
    for i in range(k-1):
        a[p]=0
        p=p+1
    print("".join(a))


n,k  =list(map(int,input().split()))
a = list(input())
if k==0:
    print("".join(a))
else:
    if n==1:
        print(0)
    else:
        if a[0]=="1":
            i=1
            while i<n and k>0:
                if a[i]!="0":
                    a[i]="0"
                    k=k-1
                i+=1
            print("".join(a))
        else:
            i=1
            a[0]="1"
            k=k-1
            while i<n and k>0:
                if a[i]!="0":
                    a[i]="0"
                    k=k-1
                i+=1
            print("".join(a))


n,k  =list(map(int,input().split()))
a = list(input())
if n==1:
    print(0)
else:
    if a[0]=="1":
        i=1
        while i<n and k>0:
            if a[i]!="0":
                a[i]="0"
                k=k-1
            i+=1
        print("".join(a))
    else:
        i=1
        a[0]="1"
        k=k-1
        while i<n and k>0:
            if a[i]!="0":
                a[i]="0"
                k=k-1
            i+=1
        print("".join(a))


n,k = list(map(int,input().split()))
a = list(input())
if k==0:
    print("".join(a))
else:
    a[0]="1"
    p = 1
    for i in range(k-1):
        a[p]="0"
        p=p+1
    print("".join(a))


a,b=map(int,input().split())
s=input()
d=""
p=0
cnt=0
if a==1 and b>=1:
	print(0)
	exit()
if a==1 and b==0:
	print(s)
	exit()
for i in range(len(s)):
	if cnt>=b:
		p=1
	if p==1:
		d+=s[i]
	elif i==0:
		if s[i]!="1":
			cnt+=1
		d+="1"
	else:
		if s[i]!="0":
			cnt+=1
		d+="0"
print(d)


a,b=map(int,input().split())
s=input()
if len(s)==1:
	if b==0:
		print(s)
	else:
		print(0)
	exit()
cnt=0
i=1
if s[0]!="1":
	cnt+=1
d="1"
while cnt<b:
	if s[i]!="0":
		cnt+=1
	i+=1
	d+="0"
for pp in range(len(s)-len(d)):
	d+=s[len(d)]
print(d)


a,b=map(int,input().split())
s=input()
if len(s)==1:
	if b==0:
		print(s)
	else:
		print(0)
	exit()
cnt=0
i=1
if s[0]!="1":
	cnt+=1
d="1"
while cnt<b:
	if s[i]!="0":
		cnt+=1
	i+=1
	d+="0"
	if i>=len(s):
		break
for pp in range(len(s)-len(d)):
	d+=s[len(d)]
print(d)


a,b=map(int,input().split())
s=input()
d=""
p=0
cnt=0
if s=="1" or s=="0":
	print(0)
	exit()
for i in range(len(s)):
	if cnt>=b:
		p=1
	if p==1:
		d+=s[i]
	elif i==0:
		if s[i]!="1":
			cnt+=1
		d+="1"
	else:
		if s[i]!="0":
			cnt+=1
		d+="0"
print(d)


a,b=map(int,input().split())
s=input()
if s=="1":
	print(0)
	exit()
d=""
i=0
cnt=0
while cnt<b and i<a:
	if i==0 and int(s[i])>1:
		cnt+=1
		d+="1"
	elif i==0:
		d+="1"
	elif s[i]!="0":
		cnt+=1
		d+="0"
	else:
		d+="0"
	i+=1
d+=s[i:]
print(d)


n, k = map(int, input().split())
s = input()
if(n==1):
    print("0")
else:
    if(s[0]=='1'):
        k+=1
    print("1",end="")
    for i in range(1,len(s)):
        if(k-1>0 and s[i]!='0'):
            print("0",end="")
            k-=1
        else:
            print(s[i],end="")


n, k = map(int, input().split())
s = input()
if(n==1):
    print("0")
else:
    if(s[0]=='1'):
        k+=1
    print("1",end="")
    for i in range(1,len(s)):
        if(k-1>0):
            print("0",end="")
            k-=1
        else:
            print(s[i],end="")
            k-=1


n, k = map(int, input().split())
s = input()
if(k==0):
    print(s)
elif(n==1):
    print("0")
else:
    if(s[0]=='1'):
        k+=1
    print("1",end="")
    for i in range(1,len(s)):
        if(k-1>0 and s[i]!='0'):
            print("0",end="")
            k-=1
        else:
            print(s[i],end="")


n, k = map(int, input().split())
s = input()
if(n==1):
    print("0")
elif(k==0):
    print(s)
else:
    if(s[0]=='1'):
        k+=1
    print("1",end="")
    for i in range(1,len(s)):
        if(k-1>0 and s[i]!='0'):
            print("0",end="")
            k-=1
        else:
            print(s[i],end="")


n, k = map(int, input().split())
s = input()
if(k==0):
    print(s)
elif(n==1):
    print(s)
else:
    if(s[0]=='1'):
        k+=1
    print("1",end="")
    for i in range(1,len(s)):
        if(k-1>0 and s[i]!='0'):
            print("0",end="")
            k-=1
        else:
            print(s[i],end="")


n,k=map(int,input().split())
s=input()
a=[int(s[i]) for i in range(n)]
if n==1:a[0]=0
if a[0]!=1 and n!=1:
    a[0]=1
    k-=1
for x in range(1,n):
    if a[x]!=0:
        a[x]=0
        k-=1
    if k==0: break
for m in range(0,n):
    print(a[m],end="")


n,k=map(int,input().split())
s=input()
a=[int(s[i]) for i in range(n)]
if n==1:a[0]=0
if a[0]!=1 and n!=1:
    a[0]=1
    k-=1
for x in range(1,n):
    if a[x]!=0:
        a[x]=0
        k-=1
    if k==0: break
if(k==0):print(s)
else:
    for m in range(0,n):
        print(a[m],end=")


n,k=map(int,input().split())
s=input()
k1=k
a=[int(s[i]) for i in range(n)]
if n==1:a[0]=0
if a[0]!=1 and n!=1:
    a[0]=1
    k-=1
for x in range(1,n):
    if a[x]!=0:
        a[x]=0
        k-=1
    if k==0: break
if(k1==0):print(s)
else:
    for m in range(0,n):
        print(a[m],end="")


n,k=map(int,input().split())
s=input()
a=[s[i] for i in range(n)]
if n==1:a[0]=0;
if a[0]!=1 and n!=1:
    a[0]=1
    k-=1
for x in range(1,n):
    if a[x]!=0:
        a[x]=0
        k-=1
    if k==0: break
for m in range(0,n):
    print(a[m],end="")


n,k=map(int,input().split())
s=input()
a=[int(s[i]) for i in range(n)]
if n==1:a[0]=0
if a[0]!=1 and n!=1:
    a[0]=1
    k-=1
for x in range(1,n):
    if a[x]!=0:
        a[x]=0
        k-=1
    if k==0: break
for m in range(0,n):
    print(a[m],end=""


n,k=map(int,input().split())
s=input()
k1=k
a=[int(s[i]) for i in range(n)]
if n==1:a[0]=0
if a[0]!=1 and n!=1:
    a[0]=1
    k-=1
for x in range(1,n):
    if k == 0: break
    if a[x]!=0:
        a[x]=0
        k-=1
if(k1==0):print(s)
else:
    for m in range(0,n):
        print(a[m],end="")


n,k=map(int,input().split())
s=input()
a=[int(s[i]) for i in range(n)]
if n==1:a[0]=0
if a[0]!=1 and n!=1:
    a[0]=1
    k-=1
for x in range(1,n):
    if a[x]!=0:
        a[x]=0
        k-=1
    if k==0: break
if(k==0):print(s)
else:
    for m in range(0,n):
        print(a[m],end="")


n, k = (map(int, input().split()))
p = int(input())
s = list(str(p))
l = s
s[0]="1"
c=0
if k > 1:
    #s[0:k]=list(str(10**k))
    for i in range(1,n):
        if l[i]!="0":
            s[i]="0"
            c=c+1
            if c==k-1:
                break
    print("".join(s))

    #print("".join(s))
else:
    print(0)


n, k = (map(int, input().split()))
p=int(input())
s = list(str(p))
l = s
if k >= 1:
    c = 0
    s[0] = "1"
    for i in range(1, len(s)):
        #print(i)

        if l[i] == "0":
            #print("**********")
            pass

        else:
            #print("$$$$$$$$$$")
            s[i] = "0"
            c = c + 1
            if c == k - 1:
                break
    print("".join(s))
else:
    print(n,"hui")


n, k = (map(int, input().split()))
p = int(input())
s = list(str(p))
l = s
if k > 1:
    c = 0
    s[0] = "1"
    for i in range(1, len(s)):
        # print(i)

        if l[i] == "0":
            # print("**********")
            pass

        else:
            # print("$$$$$$$$$$")
            s[i] = "0"
            c = c + 1
            if c == k - 1:
                break
    print("".join(s))
else:
    print(0)


n, k = (map(int, input().split()))
p = int(input())
s = list(str(p))
l = s
s[0]="1"
c=0
if k > 1:
    if "0" not in s[1:k+1]:
        s[0:k] = list(str(10 ** (k-1)))
        print("".join(s))
    else:
    #s[0:k]=list(str(10**k))
        for i in range(1,n):
            if l[i]!="0":
                s[i]="0"
                c=c+1
                if c==k-1:
                    break
        print("".join(s))

    #print("".join(s))
else:
    print(0)


n, k = (map(int, input().split()))
p = int(input())
s = list(str(p))
l = s
s[0]="1"
c=0
if k > 1:
    if "0" not in s:
        s[0:k] = list(str(10 ** (k-1)))
        print("".join(s))
    else:
    #s[0:k]=list(str(10**k))
        for i in range(1,n):
            if l[i]!="0":
                s[i]="0"
                c=c+1
                if c==k-1:
                    break
        print("".join(s))

    #print("".join(s))
else:
    print(0)


n, k = (map(int, input().split()))
p = int(input())
s = list(str(p))
l = s
c=s[1:k].count(("0"))
if k > 1:
    if s[0]!=1:
        s[0:k+1]=list(str(10**(k+c-1)))
    else:
        s[0:k+1] = list(str(10 ** (k + c)))

    print("".join(s))
else:
    print(0)


n,k=list(map(int,input().split()))
l=list(map(int,input()))

if n==1:
	print(0)
elif k==0:
	for i in l:
		print(i,end='')
else:
	if l[0]==1:
		ch=k
	else:
		l[0]=1
		ch=k-1
	p=0
	for i in range(1,n):
		if p==ch:
			break
		if l[i]!=0:
			l[i]=0
			p+=1
	for i in l:
		print(i,end='')


n,k=list(map(int,input().split()))
l=list(map(int,input()))

if l[0]==1:
	ch=k
else:
	l[0]=1
	ch=k-1

if n==1:
	print(0)
else:
	p=0
	for i in range(1,n):
		if l[i]!=0:
			l[i]=0
			p+=1
		if p==ch:
			break
	for i in l:
		print(i,end='')


if k==0:
	for i in l:
		print(i,end='')
elif n==1:
	print(0)
else:
	if l[0]==1:
		ch=k
	else:
		l[0]=1
		ch=k-1
	p=0
	for i in range(1,n):
		if p==ch:
			break
		if l[i]!=0:
			l[i]=0
			p+=1
	for i in l:
		print(i,end='')


n,k=list(map(int,input().split()))
l=list(map(int,input()))

if l[0]==1:
	ch=k
else:
	l[0]=1
	ch=k-1

if n==1:
	print(0)
else:
	p=0
	for i in range(1,n):
		if p==ch:
			break
		if l[i]!=0:
			l[i]=0
			p+=1
	for i in l:
		print(i,end='')


n,k=list(map(int,input().split()))
l=list(map(int,input()))
c=list(set(l))
c.sort()
if min(c)==0:
	sm=l.index(c[1])
else:
	sm=l.index(c[0])
if l[0]==l[sm]:
	ch=k
else:
	ch=k-1
l[0],l[sm]=l[sm],l[0]

p=0
if n==1:
	print(0)
else:
	for i in range(1,n):
		if l[i]!=0:
			l[i]=0
			p+=1
		if p==ch:
			break
	for i in l:
		print(i,end='')


n,k=list(map(int,input().split()))
l=list(map(int,input()))

if k==0:
	for i in l:
		print(i,end='')
elif n==1:
	print(0)
else:
	if l[0]==1:
		ch=k
	else:
		l[0]=1
		ch=k-1
	p=0
	for i in range(1,n):
		if p==ch:
			break
		if l[i]!=0:
			l[i]=0
			p+=1
	for i in l:
		print(i,end='')


n, k = map(int, input().split())
s = input()

result = ""
i = 0
for i in range(n):
    if k == 0:
        result += s[i]
    else:
        if i == 0:
            if s[0] != "1":
                result += "1"
                k -= 1
            else:
                result += s[i]

        else:
            if s[i] != "0":
                result += "0"
                k -= 1
            else:
                result += s[i]

print(result)


def string(arr):
    result = ""
    for i in arr:
        result += i
    return result

n, k = map(int, input().split())
s = input()
s = list(s)

if s[0] != "1":
    s[0] = "1"
    k -= 1

for i in range(k):
    try:
        s[1 + i] = "0"
    except:
        pass
print(string(s))


def string(arr):
    result = ""
    for i in arr:
        result += i
    return result

n, k = map(int, input().split())
s = input()
s = list(s)
if n == 1:
    if k == 1:
        print(0)
    else:
        print(n)
    exit()

if s[0] != "1":
    s[0] = "1"
    k -= 1

for i in range(k):
    s[1 + i] = "0"

print(string(s))


n, k = map(int, input().split())
s = input()

if n == 1:
    if k == 0:
        print(s)
    else:
        print(0)
    exit()

if k == 0:
    print(s)
    exit()

result = ""
i = 0
for i in range(n):
    if k == 0:
        result += s[i]
    else:
        if i == 0:
            if s[0] != "1":
                result += "1"
                k -= 1
            else:
                result += s[i]

        else:
            if s[i] != "0":
                result += "0"
                k -= 1
            else:
                result += s[i]

print(result)


def string(arr):
    result = ""
    for i in arr:
        result += i
    return result

n, k = map(int, input().split())
s = input()
s = list(s)

if n == 1:
    if k == 1:
        print(0)
    else:
        print(n)
    exit()
if k == 0:
    print(n)
    exit()

if s[0] != "1":
    s[0] = "1"
    k -= 1

i = 1
while k > 0 and i < n:
    if s[i] != "0":
        s[i] = "0"
        k -= 1
    i += 1

print(string(s))


n, k = map(int, input().split())
s = input()

if n == 1:
    if k == 0:
        print(s)
    else:
        print(0)
    exit()

if k == 0:
    print(s)

result = ""
i = 0
for i in range(n):
    if k == 0:
        result += s[i]
    else:
        if i == 0:
            if s[0] != "1":
                result += "1"
                k -= 1
            else:
                result += s[i]

        else:
            if s[i] != "0":
                result += "0"
                k -= 1
            else:
                result += s[i]

print(result)


def string(arr):
    result = ""
    for i in arr:
        result += i
    return result

n, k = map(int, input().split())
s = input()
s = list(s)
if n == 1:
    if k == 1:
        print(0)
    else:
        print(n)
    exit()

if s[0] != "1":
    s[0] = "1"
    k -= 1

i = 1
while k > 0 and i < n:
    if s[i] != "0":
        s[i] = "0"
        k -= 1
    i += 1
print(string(s))


def string(arr):
    result = ""
    for i in arr:
        result += i
    return result

n, k = map(int, input().split())
s = input()
s = list(s)

if n == 1:
    if k == 1:
        print(0)
    else:
        print(s)
    exit()

if k == 0:
    print(s)
    exit()

if s[0] != "1":
    s[0] = "1"
    k -= 1

i = 1
while k > 0 and i < n:
    if s[i] != "0":
        s[i] = "0"
        k -= 1
    i += 1

print(string(s))


def string(arr):
    result = ""
    for i in arr:
        result += i
    return result

n, k = map(int, input().split())
s = input()
s = list(s)
if n == 1:
    if k == 1:
        print(0)
    else:
        print(n)
    exit()

if s[0] != "1":
    s[0] = "1"
    k -= 1

for i in range(1, k + 1):
    s[i] = "0"

print(string(s))


n,m=map(int,input().split())
a=list(input())
if n==1 and m>0:
    print(0)
elif n==1 and m==0:
    print(1)
elif a[0]=='1':
    i=1
    t=0
    while t!=m  and i<n:
        if a[i]!='0':
            a[i]='0'
            t+=1
        i+=1

    s=''.join([str(i)for i in a])
    print(s)

else:
    a[0]='1'
    t=1
    i=1
    while t!=m and i<n:

        if a[i]!='0':
            a[i]='0'
            t+=1

        i+=1

    s=''.join([str(i)for i in a])
    print(s)


n,m=map(int,input().split())
a=list(input())
if n==1 and m>0:
    print(0)
elif n==1 and m==0:
    print(1)
elif a[0]=='1':
    i=1
    t=0
    while t!=m  and i<n:
        if a[i]!='0':
            a[i]='0'
            t+=1
        i+=1

    s=''.join([str(i)for i in a])
    print(s)

else:
    a[0]='1'
    t=1
    i=1
    while t!=m and i<n:
        print(i)
        if a[i]!='0':
            a[i]='0'
            t+=1
            print(0)
        i+=1

    s=''.join([str(i)for i in a])
    print(s)


n,m=map(int,input().split())
a=list(input())
if m==1 and n==1:
    print(0)

elif m>0:
    if a[0]!='1':
        a[0]='1'
        for i in range(1,m):
            a[i]='0'
    else:
        for i in range(1,m+1):
            a[i]='0'
    s=''.join([str(i)for i in a])
    print(s)
else:
    s=''.join([str(i)for i in a])
    print(s)


n,m=map(int,input().split())
a=list(input())
if m>0:
    if a[0]!='1':
        a[0]='1'
        for i in range(1,m):
            a[i]='0'
    else:
        for i in range(1,m+1):
            a[i]='0'
s=''.join([str(i)for i in a])
print(s)


n,m=map(int,input().split())
a=list(input())
if n==1 and m>0:
    print(0)
elif n==1 and m==0:
    print(1)
elif m==0:
    s=''.join([str(i)for i in a])
    print(s)

elif a[0]=='1':
    i=1
    t=0
    while t!=m  and i<n:
        if a[i]!='0':
            a[i]='0'
            t+=1
        i+=1

    s=''.join([str(i)for i in a])
    print(s)

else:
    a[0]='1'
    t=1
    i=1
    while t!=m and i<n:

        if a[i]!='0':
            a[i]='0'
            t+=1

        i+=1

    s=''.join([str(i)for i in a])
    print(s)


n, m = map(int, input().split())
a = list(input())
if n == 1 and m > 0:
    print(0)

elif m == 0:
    s = ''.join([str(i) for i in a])
    print(s)

elif a[0] == '1':
    i = 1
    t = 0
    while t != m and i < n:
        if a[i] != '0':
            a[i] = '0'
            t += 1
        i += 1

    s = ''.join([str(i) for i in a])
    print(s)

else:
    a[0] = '1'
    t = 1
    i = 1
    while t != m and i < n:

        if a[i] != '0':
            a[i] = '0'
            t += 1

        i += 1

    s = ''.join([str(i) for i in a])
    print(s)


n,k = map(int,input().split())
s = input()

a = ""
for i in range(k):
    if i == 0:
        a+="1"

    elif s[i] != "0":
         a += "0"
    else:
        a+=s[i]

for i in range(k,len(s)):
    a+=s[i]

if len(s) != 1:
    print(a)
else:
    print(0)


n,k = map(int,input().split())
s = input()

a = ""
i = 0
o = 0
while i < len(s)  and o < k:
    if i == 0:
        if (s[i] != "1"):
            a+="1"
            o+=1
        else:
            a+="1"

    elif s[i] != "0":
         a += "0"
         o+=1
    else:
        a+=s[i]

    i += 1

for i in range(i,len(s)):
    a+=s[i]

if len(s) != 1:
    print(a)
else:
    if (k!=0):
        print(0)
    else:
        print(a)


n,k = map(int,input().split())
s = input()

a = ""
i = 0
o = 0
while i < len(s)  and o < k:
    if i == 0:
        if (s[i] != "1"):
            a+="1"
            o+=1
        else:
            a+="1"

    elif s[i] != "0":
         a += "0"
         o+=1
    else:
        a+=s[i]

    i += 1

for i in range(i,len(s)):
    a+=s[i]

if len(s) != 1:
    print(a)
else:
    if (s=="1") or s=="0":
        print(0)
    else:
        print(1)


n,k = map(int,input().split())
s = input()

a = ""
i = 0
o = 0
while i < len(s)  and o < k:
    if i == 0:
        if (s[i] != "1"):
            a+="1"
            o+=1
        else:
            a+="1"

    elif s[i] != "0":
         a += "0"
         o+=1
    else:
        a+=s[i]

    i += 1

for i in range(i,len(s)):
    a+=s[i]

if len(s) != 1:
    print(a)
else:
    print(0)


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

int main() {

	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    ll t;
    cin>>t;
    vector<ll > p,ng;
    while(t--){

       ll n;
       cin>>n;
       ll a[n],p[n],ng[n],ans[4];
       ll k=0,kk=0;
       for(int i=0;i<n;i++){
           cin>>a[i];
       }
       sort(a,a+n,greater<>());

       ll f=1;
       for(ll i=0;i<3;i++){
           f*=a[i];
       }
       ans[0]=f*a[n-1]*a[n-2];

       int f1=1;
       for(ll i=n-1;i>=n-4;i--){
           f1*=a[i];
       }
       ans[1]=f1*a[0];

       int f2=1;
       for(ll i=0;i<5;i++){
           f2*=a[i];
       }
       ans[2]=f2;

       ll f3=1;
       for(ll i=n-1;i>=n-5;i--){
           f3*=a[i];
       }
       ans[3]=f3;

       sort(ans,ans+4);

    //   for(ll i=0;i<4;i++)
    //       cout<<ans[i]<<" ";
    //   cout<<endl;

        cout<<ans[3]<<endl;
   }
}


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

int main() {

	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    ll t;
    cin>>t;
    while(t--){

       ll n;
       cin>>n;
       ll a[n],ans[3]={1};
       ll ps=0,ng=0;
       for(int i=0;i<n;i++){
           cin>>a[i];
           if(a[i]<0)
              ng++;
            else ps++;
       }
       sort(a,a+n,greater<>());

        if(ng==n){
            ll anss=1;
        for(ll i=0;i<5;i++)
            anss*=a[i];
        cout<<anss<<endl;

        }
        else if(ps==n){
            ll anss=1;
        for(ll i=0;i<5;i++)
            anss*=a[i];
        cout<<anss<<endl;

        }
        else{
           ll f=1;
           for(ll i=0;i<3;i++){
               f*=a[i];
           }
           ans[0]=f*a[n-1]*a[n-2];

           int f1=1;
           for(ll i=n-1;i>=n-4;i--){
               f1*=a[i];
           }
           ans[1]=f1*a[0];

           int f2=1;
           for(ll i=0;i<5;i++){
               f2*=a[i];
           }
           ans[2]=f2;

           sort(ans,ans+3);

        //   for(ll i=0;i<4;i++)
        //       cout<<ans[i]<<" ";
        //   cout<<endl;

            cout<<ans[2]<<endl;
       }
   }
}


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

int main() {

	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    ll t;
    cin>>t;
    while(t--){

       ll n;
       cin>>n;
       ll a[n],ans[4]={1};
       ll ps=0,ng=0;
       for(int i=0;i<n;i++){
           cin>>a[i];
           if(a[i]<0)
              ng++;
            else ps++;
       }
       sort(a,a+n,greater<>());

        if(ng==n){
            ll anss=1;
        for(ll i=0;i<5;i++)
            anss*=a[i];
        cout<<anss<<endl;

        }
        else if(ps==n){
            ll anss=1;
        for(ll i=0;i<5;i++)
            anss*=a[i];
        cout<<anss<<endl;

        }
        else{
           ll f=1;
           for(ll i=0;i<3;i++){
               f*=a[i];
           }
           ans[0]=f*a[n-1]*a[n-2];

           int f1=1;
           for(ll i=n-1;i>=n-4;i--){
               f1*=a[i];
           }
           ans[1]=f1*a[0];

           int f2=1;
           for(ll i=0;i<5;i++){
               f2*=a[i];
           }
           ans[2]=f2;

           ll f3=1;
           for(ll i=n-1;i>=n-5;i--){
               f3*=a[i];
           }
           ans[3]=f3;

           sort(ans,ans+4);

        //   for(ll i=0;i<4;i++)
        //       cout<<ans[i]<<" ";
        //   cout<<endl;

            cout<<ans[3]<<endl;
       }
   }
}


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

int main() {

	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    ll t;
    cin>>t;
    while(t--){

       int n;
       cin>>n;
       ll a[n]; //ans[3]={1};
       //ll ps=0,ng=0;
       for(int i=0;i<n;i++){
           cin>>a[i];
        //   if(a[i]<0)
        //       ng++;
        //     else ps++;
       }
       sort(a,a+n,greater<ll>());

        // if(ng==n){
        //     ll anss=1;
        // for(ll i=0;i<5;i++)
        //     anss*=a[i];
        // cout<<anss<<endl;

        // }
        // else if(ps==n){
        //     ll anss=1;
        // for(ll i=0;i<5;i++)
        //     anss*=a[i];
        // cout<<anss<<endl;

        // }
        // else{
           ll f=1;
           for(ll i=0;i<3;i++){
               f*=a[i];
           }
           ll first=a[0]*a[1]*a[2]*a[n-1]*a[n-2];

           ll f1=1;
           for(ll i=n-1;i>=n-4;i--){
               f1*=a[i];
           }
           ll second=f1*a[0];

           ll f2=1;
           for(ll i=0;i<5;i++){
               f2*=a[i];
           }
           ll third=f2;

        //   for(ll i=0;i<4;i++)
        //       cout<<ans[i]<<" ";
        //   cout<<endl;

            cout<<max(third,max(first,second))<<endl;
       }
}


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

int main() {

	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    ll t;
    cin>>t;
    while(t--){

       ll n;
       cin>>n;
       ll a[n],ans[3]={1};
       ll ps=0,ng=0;
       for(int i=0;i<n;i++){
           cin>>a[i];
           if(a[i]<0)
              ng++;
            else ps++;
       }
       sort(a,a+n,greater<>());

        if(ng==n){
            ll anss=1;
        for(ll i=0;i<5;i++)
            anss*=a[i];
        cout<<anss<<endl;

        }
        else if(ps==n){
            ll anss=1;
        for(ll i=0;i<5;i++)
            anss*=a[i];
        cout<<anss<<endl;

        }
        else{
           ll f=1;
           for(ll i=0;i<3;i++){
               f*=a[i];
           }
           ll first=f*a[n-1]*a[n-2];

           int f1=1;
           for(ll i=n-1;i>=n-4;i--){
               f1*=a[i];
           }
           ll second=f1*a[0];

           int f2=1;
           for(ll i=0;i<5;i++){
               f2*=a[i];
           }
           ll third=f2;

        //   for(ll i=0;i<4;i++)
        //       cout<<ans[i]<<" ";
        //   cout<<endl;

            cout<<max(third,max(first,second))<<endl;
       }
   }
}


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

int main() {

	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    ll t;
    cin>>t;
    while(t--){

       ll n;
       cin>>n;
       ll a[n],ans[4]={1};
       ll ps=0,ng=0;
       for(int i=0;i<n;i++){
           cin>>a[i];
           if(a[i]<0)
              ng++;
            else ps++;
       }
       sort(a,a+n,greater<>());

        if(ng==n){
            ll anss=1;
        for(ll i=n-1;i>=n-5;i--)
            anss*=a[i];
        cout<<anss<<endl;
        }
        else if(ps==n){
            ll anss=1;
        for(ll i=0;i<5;i++)
            anss*=a[i];
        cout<<anss<<endl;

        }
        else{
           ll f=1;
           for(ll i=0;i<3;i++){
               f*=a[i];
           }
           ans[0]=f*a[n-1]*a[n-2];

           int f1=1;
           for(ll i=n-1;i>=n-4;i--){
               f1*=a[i];
           }
           ans[1]=f1*a[0];

           int f2=1;
           for(ll i=0;i<5;i++){
               f2*=a[i];
           }
           ans[2]=f2;

           ll f3=1;
           for(ll i=n-1;i>=n-5;i--){
               f3*=a[i];
           }
           ans[3]=f3;

           sort(ans,ans+4);

        //   for(ll i=0;i<4;i++)
        //       cout<<ans[i]<<" ";
        //   cout<<endl;

            cout<<ans[3]<<endl;
       }
   }
}


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

int main() {

	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    ll t;
    cin>>t;
    vector<ll > p,ng;
    while(t--){

       ll n;
       cin>>n;
       ll a[n],p[n],ng[n],ans[4];
       ll k=0,kk=0;
       for(int i=0;i<n;i++){
           cin>>a[i];
       }
       sort(a,a+n,greater<>());

       ll f=1;
       for(ll i=0;i<3;i++){
           f*=a[i];
       }
       ans[0]=f*a[n-1]*a[n-2];

       int f1=1;
       for(ll i=n-1;i>=n-4;i--){
           f1*=a[i];
       }
       ans[1]=f1*a[0];

       int f2=1;
       for(ll i=0;i<5;i++){
           f2*=a[i];
       }
       ans[2]=f2;

       int f3=1;
       for(ll i=n-1;i>=n-5;i--){
           f3*=a[i];
       }
       ans[3]=f3;

       sort(ans,ans+4);

    //   for(ll i=0;i<4;i++)
    //       cout<<ans[i]<<" ";
    //   cout<<endl;

        cout<<ans[3]<<endl;
   }
}


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

int main() {

	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    ll t;
    cin>>t;
    while(t--){

       ll n;
       cin>>n;
       ll a[n],ans[3]={1};
       ll ps=0,ng=0;
       for(int i=0;i<n;i++){
           cin>>a[i];
           if(a[i]<0)
              ng++;
            else ps++;
       }
       sort(a,a+n,greater<>());

        // if(ng==n){
        //     ll anss=1;
        // for(ll i=0;i<5;i++)
        //     anss*=a[i];
        // cout<<anss<<endl;

        // }
        // else if(ps==n){
        //     ll anss=1;
        // for(ll i=0;i<5;i++)
        //     anss*=a[i];
        // cout<<anss<<endl;

        // }
        // else{
           ll f=1;
           for(ll i=0;i<3;i++){
               f*=a[i];
           }
           ll first=f*a[n-1]*a[n-2];

           int f1=1;
           for(ll i=n-1;i>=n-4;i--){
               f1*=a[i];
           }
           ll second=f1*a[0];

           int f2=1;
           for(ll i=0;i<5;i++){
               f2*=a[i];
           }
           ll third=f2;

        //   for(ll i=0;i<4;i++)
        //       cout<<ans[i]<<" ";
        //   cout<<endl;

            cout<<max(third,max(first,second))<<endl;
       }
}


#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<utility>
using namespace std;
#define ll long long
#define endl "\n"
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i, n) for(int i=n-1;i>=0;i--)
long long mod=1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

//to find nth fibonacci number.
//This code returns Fn and Fn+1 as a pair.
pair<int, int> fib (int n) {
    if (n == 0)
        return {0, 1};

    auto p = fib(n >> 1);
    int c = p.first * (2 * p.second - p.first);
    int d = p.first * p.first + p.second * p.second;
    if (n & 1)
        return {d, c + d};
    else
        return {c, d};
}

ll fact(ll n)
{
    ll res=1;
    for(ll i=n;i>=1;i--)
        (res*=i)%=mod;
    return (res%mod);

}

int pow(int a, int b, int m)
{
	int ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}

bool isPrime(long long n)
{

    if (n <= 1)
        return false;

    for (long long i = 2; i <= sqrt(n); i++)
        if (n % i == 0)
            return false;

    return true;
}

//THIS IS THE CODE TO FIND ALL PRIME NUMBERS IN THE RANGE "L" to "R";

vector<long long > segmentedSieve(long long L, long long R) {
    // generate all primes up to sqrt(R)
    long long lim = sqrt(R);
    vector<bool> mark(lim + 1, false);
    vector<long long> primes;
    for (long long i = 2; i <= lim; ++i) {
        if (!mark[i]) {
            primes.emplace_back(i);
            for (long long j = i * i; j <= lim; j += i)
                mark[j] = true;
        }
    }

    vector<bool> isPrime(R - L + 1, true);
    for (long long i : primes)
        for (long long j = max(i * i, (L + i - 1) / i * i); j <= R; j += i)
            isPrime[j - L] = false;
    if (L == 1)
        isPrime[0] = false;
    vector<long long >realprime;
   for(int i=0;i<=R-L;i++){
      if(isPrime[i]){
         realprime.emplace_back(i+L);

      }
   }
    return realprime;

}

bool isPalindrome(string s)
{

    int l = 0;
    int h = s.size()-1;

    while (h > l)
    {
        if (s[l++] != s[h--])
        {

            return false;
        }
    }
   return true;
}

int ternarySearch(int l, int r, int key, int ar[])

{
    while (r >= l) {

        // Find the mid1 and mid2
        int mid1 = l + (r - l) / 3;
        int mid2 = r - (r - l) / 3;

        // Check if key is present at any mid
        if (ar[mid1] == key) {
            return mid1;
        }
        if (ar[mid2] == key) {
            return mid2;
        }

        // Since key is not present at mid,
        // check in which region it is present
        // then repeat the Search operation
        // in that region

        if (key < ar[mid1]) {

            // The key lies in between l and mid1
            r = mid1 - 1;
        }
        else if (key > ar[mid2]) {

            // The key lies in between mid2 and r
            l = mid2 + 1;
        }
        else {

            // The key lies in between mid1 and mid2
            l = mid1 + 1;
            r = mid2 - 1;
        }
    }

    // Key not found
    return -1;
}

  int binarySearch(int arr[], int l, int r, int x)
{
    while (l <= r) {
        int m = l + (r - l) / 2;

        // Check if x is present at mid
        if (arr[m] == x)
            return m;

        // If x greater, ignore left half
        if (arr[m] < x)
            l = m + 1;

        // If x is smaller, ignore right half
        else
            r = m - 1;
    }

    // if we reach here, then element was
    // not present
    return -1;
}

//"KADANE'S ALGORITHM"
//iski time complexity o(n) hn i.e the smallest possible
long long maxsubarraysum(long long *array,long long n){
   long long best = 0, sum = 0;
for (long long  k = 0; k < n; k++) {
sum = max(array[k],sum+array[k]);
best = max(best,sum);
}
return  best ;

}
//to add two very large numbers

string findSum(string str1, string str2)
{
	if (str1.length() > str2.length())
		swap(str1, str2);
	string str = "";
	int n1 = str1.length(), n2 = str2.length();

	reverse(str1.begin(), str1.end());
	reverse(str2.begin(), str2.end());

	int carry = 0;
	for (int i=0; i<n1; i++)
	{

		int sum = ((str1[i]-'0')+(str2[i]-'0')+carry);
		str.push_back(sum%10 + '0');

		carry = sum/10;
	}
	for (int i=n1; i<n2; i++)
	{
		int sum = ((str2[i]-'0')+carry);
		str.push_back(sum%10 + '0');
		carry = sum/10;
	}
	if (carry)
		str.push_back(carry+'0');
	reverse(str.begin(), str.end());
	return str;
}

string smin(string a,string b)
{

if(a.size()<b.size())return a;
if(a.size()>b.size())return b;
if(a<=b)return a;
else return b;
}

  bool so(const pair<ll,ll> &a,
              const pair<ll,ll> &b)
{
    return (a.second < b.second);
}

int main(){
ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
int t;
cin>>t;
while(t--){
   int n;
   cin>>n;
   int a[n];
    for(int i=0;i<n;i++){
       cin>>a[i];

    }
    vector<int>pos;
    vector<int>neg;
    for(int i=0;i<n;i++){
       if(a[i]>=0){
          pos.pb(a[i]);

       }else{
          neg.pb(a[i]);

       }
    }
    sort(pos.rbegin(),pos.rend());
    sort(neg.begin(),neg.end());
    ll sum=1;

    if(pos.size()==1){
       for(int i=0;i<4;i++){
          sum=sum*neg[i];

       }
       sum=sum*pos[0];

    }else
    if(pos.size()==0){
       for(int i=0;i<5;i++){
         sum=sum*neg[i];

       }

    }else
    if(neg.size()==0||neg.size()==1){
       for(int i=0;i<5;i++){
          sum=sum*pos[i];

       }
    }else
    {
      int sz=pos.size();
      if(sz%2==0){
         sz=sz-1;
      }
       int x=5;
       int j=0;
       int k=0;
       while(j+1<sz&&k+1<neg.size()&&x!=0){
         if(pos[j]*pos[j+1]>neg[k]*neg[k+1]){
            sum=sum*(pos[j]*pos[j+1]);
            j=j+2;
            x=x-2;

         }else{
            sum=sum*(neg[k]*neg[k+1]);
            k=k+2;
            x=x-2;

         }

       }
       while(j<sz&&x!=0){

             sum=sum*pos[j];
             j++;
             x--;

       }
       while(k<neg.size()&&x!=0){

             sum=sum*neg[k];
             k++;
             x--;

       }

    }
    cout<<sum<<endl;
}
return 0;
}