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
//CLOCKS_PER_SEC
using namespace std;
#include<bits/stdc++.h>
#define sqr(x) 1ll*(x)*(x)
//#define sort stable_sort
#define ll long long
#define mk make_pair
#define pb push_back
#define in insert
#define mtr(x,y,z) mk(mk(x,y),z)
#define fi first
#define se second
#define lch(x) ((x)<<1)
#define rch(x) (((x)<<1)|1)
#define all(x) (x).begin(),(x).end()
#define titose CLOCKS_PER_SEC
#define fpi(x) freopen(x,"r",stdin);
#define fpo(x) freopen(x,"w",stdout);
#define fprio fpi("in.txt");fpo("out.txt");
#define fast ios_base::sync_with_stdio(false);
inline void read(int &x){int v=0,f=1;char c=getchar();while (!isdigit(c)&&c!='-') c=getchar();if (c=='-') f=-1; else v=(c&15);while (isdigit(c=getchar())) v=(v<<1)+(v<<3)+(c&15);x=v*f;}
inline void read(ll &x){ll v=0ll,f=1ll;char c=getchar();while (!isdigit(c)&&c!='-') c=getchar();if (c=='-') f=-1; else v=(c&15);while (isdigit(c=getchar())) v=(v<<1)+(v<<3)+(c&15);x=v*f;}
inline void readc(char &x){char c;while (((c=getchar())==' ')||c=='\n');x=c;}
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define si set<int>
//#define sl set<ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define msi map<string,int>
#define msl map<string,ll>
#define piii pair<int,pii >
#define piipi pair<pii,int>
#define plll pair<ll,pll >
#define pllpl pair<pll,ll>
#define pqi priority_queue<int>
#define pql priority_queue<ll>
#define npqi priority_queue<int,vector<int>,greater<int> >
#define npql priority_queue<ll,vector<ll>,greater<ll> >
#define forup(i,a,b) for ((i)=(a);(i)<=(b);(i)++)
#define fordo(i,a,b) for ((i)=(a);(i)>=(b);(i)--)
#define rep(i,x) forup ((i),1,(x))
#define repd(i,x) fordo ((i),(x),1)
#define rep0(i,x) forup ((i),0,((int)(x))-1)
#define rep0d(i,x) fordo ((i),((int)(x))-1,0)
#define itr iterator
#define fe(itcalc,c) for(__typeof((c).begin()) itcalc=(c).begin();itcalc!=(c).end();itcalc++)
#define NO {cout<<"NO";return 0;}
#define YES {cout<<"YES";return 0;}
#define y0 y000000000000000000000000000
#define y1 y111111111111111111111111111
#define j0 j000000000000000000000000000
#define j1 j111111111111111111111111111
#define cl0(a) memset((a),(0),(sizeof((a))))
#define clz(a) memset((a),(0x16),(sizeof((a))))
#define clf(a) memset((a),(-(0x16)),(sizeof((a))))
#define inf 0x3bbbbbbb
#define lnf 0x2bbbbbbbbbbbbbbbll
//#define sqrt divi
#define p2(i) (1ll<<(i))
#define readi read
#define readll read
/*************************************************/
int n,m,i,j,cnt[35],cur[35];
long long s,sl,res;
int main()
{
	read(n);read(m);
	rep0(i,n)read(cnt[i]);
	while(m--){
		int op;
		read(op);
		if(op==1){
			int x,y;
			read(x);read(y);
			cnt[x]=y; 
		}
		else{
			int x;long long rem;read(x);read(rem);s=sl=0;
			res=lnf;
			rep0(i,n) cur[i]=cnt[i];
			rep0(i,x+1){
				sl+=cnt[i]*((1ll<<i)-1);
				rem-=cnt[i];
			}
			if(sl>=rem)res=max(0ll,rem);
			while(rem>0){
				for(i=x+1;i<n;i++){
					long long t=min((rem>>(i-x)),1ll*cur[i]);
					rem-=(1ll<<(i-x))*t;s+=(1ll<<(i-x))*t-t;
					sl+=((1ll<<i)-(1ll<<(i-x)))*t;
					if(sl>=rem)res=min(res,max(0ll,rem)+s);
					cur[i]-=t;
					if(cur[i]){
						s++;
						cur[i]--;
						cur[i-1]+=2;
						if(i==x+1){
							sl+=(1ll<<i)-1;
							rem-=2;
						}
						if(sl>=rem)res=min(res,max(0ll,rem)+s);
						break;
					}
				}
				if(i>=n) break;
			}
			printf("%lld\n",res==lnf?-1:res);
		}
	}
	return 0;
}