#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<(a)<<endl
#define dumparr(a,n) cerr<<#a<<"["<<(n)<<"]="<<(a[n])<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = (ll)a;i < (ll)b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = (ll)b-1LL;i >= (ll)a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define SIGN(a) (a==0?0:(a>0?1:-1))

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;
typedef long double ld;
typedef pair<ld,ld> pdd;

pll operator+(pll a,pll b){
  return pll(a.first+b.first,a.second+b.second);
}
pll operator-(pll a,pll b){
  return pll(a.first-b.first,a.second-b.second);
}
pll operator*(ll a,pll b){
  return pll(b.first*a,b.second*a);
}
const ll INF=(1LL<<60);
#if __cplusplus<201700L
ll gcd(ll a, ll b) {
  a=abs(a);
  b=abs(b);
  if(a==0)return b;
  if(b==0)return a;
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif
template<class T>
bool chmax(T& a,const T& b){
  if(a<b){
    a=b;
    return true;
  }
  return false;
}
template<class T>
bool chmin(T& a,const T& b){
  if(a>b){
    a=b;
    return true;
  }
  return false;
}
template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


int main(){
  cout<<setprecision(1000);
  ll N,M;
  cin>>N>>M;
  vector<ll> dp(1LL<<N);
  vector<vector<pll>> cond(N);
  REP(M){
    ll x,y,z;
    cin>>x>>y>>z;
    --x;--y;
    cond[x].push_back(pll(y,z));
  }
  auto f=[](ll num,ll y,ll z){
    ll mask=(1LL<<(y+1))-1;
    num&=mask;
    return __builtin_popcountll(num)<=z;
  };
  dp[0]=1;
  For(j,(1LL<<N)){
    ll n=__builtin_popcountll(j);
    if(n==N)continue;
    ll cur=1;
    REP(N){
      if((cur&j)==0){
        ll jj=(j|cur);
        ([&]() {
          FOR(cidx, n, N)
          {
            for (auto &&[y, z] : cond[cidx])
            {
              if (!f(jj, y, z))
              {
                return;
              }
            }
          }
          dp[jj]+=dp[j];
        })();
      }
      cur<<=1;
    }
  }
  dump(dp);
  cout<<dp[(1LL<<N)-1]<<endl;
  return 0;
}

#define _USE_MATH_DEFINES

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <complex>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <queue>

#define	INF   1010101010LL
#define INFLL 1010101010101010101LL

using namespace std;

int mod = 1000000007;

class Segtree {
public:
	Segtree(int n) //サイズ
	{
		int t = 1;
		while (t < n) {
			t *= 2;
		}
		a = vector<long long>(2 * t - 1);
		this->n = t;
	}

	int sum(int l, int r)
	{
		return query(l, r, 0, n - 1, 0);
	}

	void update(int p, long long num)
	{
		p += this->n - 1;
		a[p] ^= num;
		while (p > 0) {
			p = (p - 1) / 2;
			a[p] = a[2 * p + 1] ^ a[2 * p + 2];
		}
	}

private:
	int query(int l, int r, int p, int q, int k)
	{
		if (l <= p && q <= r) return a[k];
		else if (q < l || r < p) return 0;

		return query(l, r, p, (p + q) / 2, 2 * k + 1) ^ query(l, r, (p + q) / 2 + 1, q, 2 * k + 2);
	}

private:
	vector<long long> a;
	int n;
};

int main()
{
	int n, q;
	cin >> n >> q;
	Segtree seg(n);
	for (int i = 0; i < n; i++) {
		int t;
		cin >> t;
		seg.update(i, t);
	}
	for (int i = 0; i < q; i++) {
		int t, x, y;
		cin >> t >> x >> y;
		if (t == 1) {
			seg.update(x - 1, y);
		} else {
			cout << seg.sum(x - 1, y - 1) << endl;
		}
	}

	return 0;
}