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 mem(x) memset(x, 0, sizeof x)
#define all(x) (x).begin(), (x).end()
#define endl "\n"
typedef long long ll;
inline ll rint() { ll x = 0, f = 1; char c = getchar(); while (c<'0' || c>'9') { if (c == '-')f = -1; c = getchar(); }while (c >= '0'&&c <= '9') { x = x * 10 + c - '0'; c = getchar(); }return x * f; }
inline ll gcd(ll a, ll b) { return (b) ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
inline ll pow(ll a, ll b, ll q) { ll rtn = 1; while (b) { if (b & 1) rtn = rtn * a%q; a = a * a%q; b >>= 1; } return rtn; }
inline ll mysqrt(ll n) { ll x = sqrt(n); while (x*x < n) x++; while (x*x > n) x--; return x; }

void calc(int n, vector<ll> cnt, ll x, ll k) {
  // 判全拆不够
  ll tot = 0;
  for(ll i=0;i<n;i++) tot+=cnt[i]*(1LL<<i);
  if(tot<k) {cout<<-1<<endl; return;}

  // 算当前够不够
  tot = 0;
  for(ll i=0;i<=x;i++) tot+=cnt[i];
  if(tot>=k) {cout<<0<<endl; return;}
  k-=tot;

  // 一个x+1->x 可以1花费+2贡献
  // 一个x+2->x 可以3花费+4贡献
  // 一个x+3->x 可以7花费+8贡献
  // 小于等于x的数->x-1 每个1花费+1贡献
  // 所以x+1开始往大贪更优

  // 算小于等于x的数可以额外提供多少贡献
  ll num=0;
  for(int i=0;i<=x;i++) num+=cnt[i]*((1ll<<i)-1);

  ll res=0;
  for(int i=x+1;i<n;i++){
    // 当前够了->往前取
    if(cnt[i]*(1ll<<(i-x))>=k){
      res+=k/(1ll<<(i-x))*((1ll<<(i-x))-1);
      num+=k/(1ll<<(i-x))*(1ll<<(i-x))*((1ll<<x)-1);
      k-=k/(1ll<<(i-x))*(1ll<<(i-x));

      for(int j=i;j>x&&k>0;j--){
        if((1ll<<(j-1-x))<=k){
          res+=(1ll<<(j-1-x));
          num+=(1ll<<(j-1-x))*((1ll<<x)-1);
          k-=(1ll<<(j-1-x));
        }
        else{
          if(num>=k){res+=k;break;}
          else res++; //拆一个
        }
      }
      cout<<res<<endl;
      return;
    }

    // 全改x也不够->全改x
    else{
      res+=cnt[i]*((1ll<<(i-x))-1);
      num+=cnt[i]*(1ll<<(i-x))*((1ll<<x)-1);
      k-=cnt[i]*(1ll<<(i-x));
    }
  }
  // 剩下的k用num补(一定够)
  cout<<res+k<<endl;
}

void solve() {
  int n=rint(), q=rint();
  vector<ll> cnt(n);
  for(int i=0;i<n;i++) cnt[i]=rint();
  while(q--){
    ll a=rint(),x=rint(),k=rint();
    if(a==1) cnt[x]=k;
    else calc(n, cnt, x, k);
  }
}

int main() {
//  int t=rint(); while(t--) solve();
  solve();
  return 0;
}
