You are given a multiset of powers of two. More precisely, for each i from 0 to n exclusive you have cnt_i elements equal to 2^i.

In one operation, you can choose any one element 2^l > 1 and divide it into two elements 2^{l - 1}.

You should perform q queries. Each query has one of two types: 

  * "1 pos val" — assign cnt_{pos} := val; 
  * "2 x k" — calculate the minimum number of operations you need to make at least k elements with value lower or equal to 2^x. 



Note that all queries of the second type don't change the multiset; that is, you just calculate the minimum number of operations, you don't perform them.

Input

The first line contains two integers n and q (1 ≤ n ≤ 30; 1 ≤ q ≤ 2 ⋅ 10^5) — the size of array cnt and the number of queries.

The second line contains n integers cnt_0, cnt_1, ..., cnt_{n - 1} (0 ≤ cnt_i ≤ 10^6).

Next q lines contain queries: one per line. Each query has one of two types: 

  * "1 pos val" (0 ≤ pos < n; 0 ≤ val ≤ 10^6); 
  * "2 x k" (0 ≤ x < n; 1 ≤ k ≤ 10^{15}). 



It's guaranteed that there is at least one query of the second type.

Output

For each query of the second type, print the minimum number of operations you need to make at least k elements with a value lower or equal to 2^x or -1 if there is no way to do it.

Example

Input


6 11
0 1 0 0 1 0
2 1 5
2 4 18
1 1 0
2 2 5
2 0 17
1 0 3
2 1 2
1 1 4
1 4 0
1 5 1
2 2 8


Output


4
16
4
-1
0
1
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define mii map<int, int>
#define pb push_back
#define mk make_pair
const int inf = 0x3f3f3f3f;
const ll mod = 1000000007;
const ll linf = 0x3f3f3f3f3f3f3f3f;
#define deb(k) cerr << #k << ": " << k << "\n";
#define fastcin cin.tie(0)->sync_with_stdio(0);
#define st first
#define nd second
#define MAXN 1000100
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

ll cnt[32];
ll count(ll l, ll x, ll k, ll small){
	if(l == x+1){
		if(small >= k) return min(k, (k+1)/2);
		return (k+1)/2;
	}
	if( ( 1ll<<(l-x) ) == k ) return (1ll<<(l-x)) - 1;
	if( ( 1ll<<(l-x) ) < k ){
		k -= (1ll<<(l-x));
		small += (1ll<<l) - (1ll<<(l-x));
		if(small >= k) return min( (1ll<<(l-x)) -1 + 1 + count(l-1, x, k, small) , (1ll<<(l-x)) - 1 + k);
		return (1ll<<(l-x)) - 1 + 1 + count(l-1, x, k, small);
	}
	if(small >= k) return min(1 + count(l-1, x, k, small), k);
	return 1 + count(l-1, x, k, small);
}

void solve(){
	int n,q;
	cin>>n>>q;
	for(int i=0;i<n;i++) cin>>cnt[i];
	while(q--){
		ll p, x, k;
		cin>>p>>x>>k;
		if(p == 1) cnt[x] = k;
		else{
			ll small = 0;
			ll ans = 0;
			for(int i=0;i<=x;i++){
			 	k -= cnt[i];
				small += (cnt[i]<<i) - cnt[i];
			}
			if(k < 0){
				cout<<"0\n";
				continue;
			}

			ll ind = -1;
			//cout<<-1<<" "<<ans<<" "<<k<<" "<<" "<<small<<"\n";
			for(int i=x+1;i<n;i++){
				ll aux = k / (1ll<<(i-x));
				if(aux >= cnt[i]){
					k -= (cnt[i]<<(i-x));
					ans += (cnt[i]<<(i-x)) - cnt[i];
					small += (cnt[i]<<i) - (cnt[i]<<(i-x));
					continue;
				}
				ind = i;
				k -= (aux<<(i-x));
				ans += (aux<<(i-x)) - aux;
				small += (aux<<i) - (aux<<(i-x));
				break;
			}
			if(ind == -1){
				if(small >= k) cout<<ans + k<<"\n";
				else cout<<"-1\n";
				continue;
			}
			//cout<<ind<<" "<<ans<<" "<<k<<" "<<small<<"\n";
			ans += count(ind, x, k, small) ;
			cout<<ans<<"\n";
		}
	}


	// Have you read the problem again?
	// Maybe you understood the wrong problem
}

int main(){
	fastcin;
	solve();
	return 0;
}
