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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T1, class T2> inline void minup(T1& m, T2 x){ if(m>x) m=static_cast<T2>(x); }
template<class T1, class T2> inline void maxup(T1& m, T2 x){ if(m<x) m=static_cast<T2>(x); }

#define INF 1000000000
#define MOD 1000000007
#define EPS 1E-12

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
const int MAX_H = 12;
const int MAX_W = 12;
char m[MAX_H+1][MAX_W+1];


inline bool check(int x, int y){ return 0<=x&&x<MAX_H && 0<=y&&y<MAX_W; }

void dfs(int hx, int hy)
{
  rep(i, 4){
    int nx = hx + dx[i];
    int ny = hy + dy[i];

    if(!check(nx, ny)) continue;

    if(m[nx][ny] == '1'){
      m[nx][ny] = '0';
      dfs(nx, ny);
    }
  }
}

int main()
{

  while(true){
    rep(i, MAX_H) rep(j, MAX_W) if(!(cin >> m[i][j])) return 0;

    int res = 0;
    rep(i, MAX_H) rep(j, MAX_W) if(m[i][j] == '1'){
      res += 1;
      dfs(i, j);
    }

    cout << res << endl;
  }

  return 0;
}
#include<bits/stdc++.h>
#pragma GCC optimization ("Ofast")
#pragma GCC optimization ("unroll-loops")
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
 
template<class T> inline bool chmin(T &a, T b){
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b){
	if(a<b){a=b;return true;}
	return false;
}
constexpr int mod = 1e9+7;
constexpr long long inf = 3e18;


class BIT{
	int N;
	vector<int>bit;
	void add_(int x,int y){
		while(x<=N){
			bit[x]+=y;x+=x&-x;
		}
	}
	int sum_(int x){
		int res=0;
		while(x>0){
			res+=bit[x];x-=x&-x;
		}
		return res;
	}
public:
	int lower_bound(int w){
		if(w<=0)return -1;
		int x=0;
		int k=1;while(k*2<=N)k*=2;
		for(;k>0;k/=2){
			if(x+k<=N&&bit[x+k]<w){
				w-=bit[x+k];
				x+=k;
			}
		}
		return x;
	}
	void add(int x,int y){add_(x+1,y);}
	int sum(int l,int r){return sum_(r)-sum_(l);}
	BIT(int x):N(x),bit(x+1){}
};
signed main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int N,Q;cin>>N>>Q;
	BIT bit(N);
	rep(i,N){int a;cin>>a;bit.add(i,a);}
	while(Q--){
		int t;cin>>t;
		if(!t){
			int p,x;cin>>p>>x;bit.add(p,x);
		}else {
			int l,r;cin>>l>>r;cout<<bit.sum(l,r)<<"\n";
		}
	}
}