#include<bits/stdc++.h>
using namespace std;
#define debug printf("%d %s\n",__LINE__,__FUNCTION__)
using ll=long long;using ld=double;using pii=pair<int,int>;using vi=vector<int>;
using qi=queue<int>;using pqi=priority_queue<int>;using si=set<int>;
#define pb push_back
#define mk make_pair
#define ins insert
#define era erase
#define fi first
#define se second
#define lowbit(x) x&-x
const int INF=0x3f3f3f3f;
const ll INFLL=0x3f3f3f3f3f3f3f3f;
const double PI=acos(-1.0);
int _w,_t;FILE* _f;

const int N=3e5+5;

int n,q,a[N],sum[N];

void add(int u,int d){
    while(u<=n){
        sum[u]^=d;
        u+=lowbit(u);
    }
}

int qsum(int u){
    int tmp=0;
    while(u>0){
        tmp^=sum[u];
        u-=lowbit(u);
    }
    return tmp;
}

void solve(){
    scanf("%d%d",&n,&q);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        add(i,a[i]);
    }
    int t,x,y;
    while(q--){
        scanf("%d%d%d",&t,&x,&y);
        if(t^2){
            add(x,y);
        }
        else{
            printf("%d\n",qsum(y)^qsum(x-1));
        }
    }
}

int main(){
    #ifdef MULTI_CASES
    _w=scanf("%d",&_t);while(_t--)
    #endif
    solve();
    return 0;
}
#include <bits/stdc++.h>

using namespace std;

//#pragma target("sse,sse2,sse3,ssse3,sse,popcnt,abm,mmx,avx,avx2,fma,tune=native")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")


template <typename T>
istream& operator >> (istream& in, vector<T>& a) {
    for (auto& i : a)
        in >> i;
    return in;
}

template <typename T>
ostream& operator << (ostream& out, const vector<T>& a) {
    for (auto& i : a) {
        out << i << " ";
    }
    return out;
}

template <typename T, typename D>
istream& operator >> (istream& in, pair<T, D>& a) {
    in >> a.first >> a.second;
    return in;
}

template <typename T, typename D>
ostream& operator << (ostream& out, const pair<T, D>& a) {
    out << a.first << " " << a.second;
    return out;
}

struct LogOutput{
    template<typename T>
    LogOutput& operator<<(T x) {
#ifdef DIVAN
        cout << x;
#endif
        return *this;
    }
};

LogOutput fout;

typedef long long ll;
typedef unsigned long long ull;
typedef double dl;

#define nl '\n'
#define elif else if
#define all(_v) _v.begin(), _v.end()
#define rall(v) v.rbegin(), v.rend()
#define sz(v) (int)(v.size())
#define sqr(_v) ((_v) * (_v))
#define vpi vector<pair<int, int>>
#define eb emplace_back
#define pb push_back
#define mod(x, m) ((x) >= 0 ? ((x) % m) : (((x) % m) + m))
#define vi vector<int>
#define pi pair<int, int>
#define ti tuple<int, int, int>
#define minq(x, y) x = min((x), (y))
#define maxq(x, y) x = max((x), (y))
#define forn(i, n) for (int i = 0; i < (n); ++i)

const ll INFL = 9187201950435737471;
const ll nINFL = -9187201950435737472;
const int INF = 2139062143;
const int nINF = -2139062144;
const ull ULINF = numeric_limits<ull>::max();
const long double Pi = acos(-1);
auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 rnd(seed);

inline void IO() {
#ifdef DIVAN
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
}

const int MAXN = 1e5 + 15;

vpi adj[MAXN];
int col[MAXN];
bool used[MAXN];

void DFS(int v) {
    used[v] = 1;
    for (auto [to, c] : adj[v]) {
        if (used[to]) {continue;}
        if (col[v] == c) {
            if (c == 1) {
                col[to] = 2;
            } else {
                col[to] = 1;
            }
        } else {
            col[to] = c;
        }
        DFS(to);
    }
}

void Solve() {
    int n, m;
    cin >> n >> m;
    while (m--) {
        int a, b, c;
        cin >> a >> b >> c;
        adj[a].eb(b, c);
        adj[b].eb(a, c);
    }
    col[1] = 1;
    DFS(1);
    for (int i = 1; i <= n; ++i) {
        cout << col[i] << '\n';
    }
}

signed main() {
    IO();
    int t = 1;
//    cin >> t;
    int startTime = clock();
    while (t--) {
        Solve();
    }
    int endTime = clock();
#ifdef DIVAN
    cout << '\n' << "Time: " << (endTime - startTime + 999) / 1000;
#endif
    return 0;
}
