#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
const int N=3e5+5,M=1e9+7,OO=0x3f3f3f3f;

int n,q;
int arr[N];
int seg[4*N];

void build(int si=0,int ss=0,int se=n-1){
    if(ss==se){
        seg[si]=arr[ss];
        return;
    }
    int md=ss+(se-ss)/2,lf=si*2+1,rt=si*2+2;
    build(lf,ss,md);
    build(rt,md+1,se);
    seg[si]=seg[lf]^seg[rt];
}

void update(int qi,int qv,int si=0,int ss=0,int se=n-1){
    if(ss>qi||se<qi) return;
    if(ss==se){
        seg[si]^=qv;
        return;
    }
    int md=ss+(se-ss)/2,lf=si*2+1,rt=si*2+2;
    update(qi,qv,lf,ss,md);
    update(qi,qv,rt,md+1,se);
    seg[si]=seg[lf]^seg[rt];
}

int query(int qs,int qe,int si=0,int ss=0,int se=n-1){
    if(ss>qe||se<qs) return 0;
    if(ss>=qs&&se<=qe) return seg[si];
    int md=ss+(se-ss)/2,lf=si*2+1,rt=si*2+2;
    return query(qs,qe,lf,ss,md)^query(qs,qe,rt,md+1,se);
}

int main(){

    //freopen("myfile.txt","w",stdout);

    scanf("%d%d",&n,&q);
    for(int i=0;i<n;++i)
        scanf("%d",arr+i);

    build();

    while(q--){
        int t,x,y;
        scanf("%d%d%d",&t,&x,&y);
        if(t==1){
            update(--x,y);
        }
        else{
            --x,--y;
            printf("%d\n",query(x,y));
        }
    }

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef tuple<int,int,int> i3;
int x[105], y[105], z[105], n, m;
ll fat[20], dp[(1 << 18) + 5][105];

vector<int> mask[25];

ll solve(int curmask, int pos){
    int cursz = __builtin_popcount(curmask);
    if(pos == m) return fat[n-cursz];
    if(dp[curmask][pos] != -1) return dp[curmask][pos];

    int cnt = 0;
    for(int i = 0; i < y[pos]; i++)
        cnt += !!((1 << i) & curmask);
    ll res = 0;

    int biton = __builtin_popcount(curmask);
    if(cnt <= z[pos]){
        if(biton == x[pos])
            res = solve(curmask, pos+1);
        else{
            for(int j = 0; j < n; j++)
                if(!((1 << j) & curmask))
                    res += solve(curmask|(1 << j), pos);
        }

    }

    return dp[curmask][pos] = res;
}

int main(){
    
    cout.sync_with_stdio(0);
    cin.tie(0);

    memset(dp, -1, sizeof dp);
    cin >> n >> m;
    vector<i3> vec;
    for(int i = 0; i < m; i++){
        int a, b, c; cin >> a >> b >> c;
        vec.emplace_back(a, b, c);
    }
    sort(vec.begin(), vec.end());
    for(int i = 0; i < m; i++){
        int a, b, c; tie(a, b, c) = vec[i];
        x[i] = a;
        y[i] = b;
        z[i] = c;
    }

    fat[0] = 1;
    for(int i = 1; i <= n; i++)
        fat[i] = fat[i-1] * i;

    if(m == 0){
        cout << fat[n] << endl;
        return 0;
    }

    cout << solve(0, 0) << endl;
    
    

    
    return 0;
}