///      TANVIR HASAN

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

#define hello      printf("HELLO\n")
#define uu         first
#define vv         second
#define pb         push_back
#define mp         make_pair
#define LL         long long
#define inf        INT_MAX/3
#define mod        1000000007ll
#define PI         acos(-1.0)
#define linf       (1ll<<60)-1
#define pii        pair<int,int>
#define vl        vector<LL>
#define vi        vector<int>
#define vs        vector<string>
#define pii        pair<int,int>

#define ALL(A)     (A).begin(),(A).end()
#define mset(a,v)     memset(a,v,sizeof a)
#define setinf(ar)  memset(ar,126,sizeof ar)
#define vsort(v)   sort(v.begin(),v.end())

#define FOR(I,A,B) for (__typeof (B) I = (A) ; I <= B ; ++I)
#define rof(i, a, b)    for (__typeof (b)i = (b) ; i >= a ; --i)
#define rep(I, n)       for (__typeof (n) I = 0 ; I < n ; ++I)
#define per(i, n)       for (__typeof (n)i = (n-1) ; i >= 0 ; --i)
#define forstl(I, s)    for (__typeof ((s).end ()) I = (s).begin (); I != (s).end (); ++I)
#define rofstl(I, s)    for (__typeof ((s).end ()) I = (s).end ()-1; I != (s).begin (); --I)

#define Int ({int a; scanf("%d", &a); a;})
#define I64 ({LL a; scanf("%I64d", &a); a;})
#define Double ({double a; scanf("%lf", &a); a;})
#define Char ({char a; scanf("%c", &a); a;})
void FastIO()  {ios::sync_with_stdio(0);cin.tie(0);}

#define En "\n"
#define round(a,b,n) ((a-1+b)% n + n)% n + 1  /// 1 base round,, a starting index ,,+b for left to right,,-b for left,|b| turn,,total n gor
#define tata return 0
///           error////////////////////

#define error(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); puts(""); }

vector<string> split(const string& s, char c) {
    vector<string> v;
    stringstream ss(s);
    string x;
    while (getline(ss, x, c))
        v.emplace_back(x);
    return move(v);
}

void err(vector<string>::iterator it) {}
template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
    cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << "  ";
    err(++it, args...);
}

#define dbg(x) cout<<#x<<" : "<<x<<endl
///          eeerrrrooooooorrrrrrr //////////////////

template <class T> inline T bigmod(T p,T e,T M){LL ret = 1;for(; e > 0; e >>= 1){if(e & 1) ret = (ret * p) % M;p = (p * p) % M;}return (T)ret;}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}   // M is prime}
template <class T> inline T bpow(T p,T e){LL ret = 1;for(; e > 0; e >>= 1){if(e & 1) ret = (ret * p);p = (p * p);}return (T)ret;}

#define EPS numeric_limits<double>::epsilon()

/// ///////////////////////////////////////////////////////////////////////////////////////////////////////////
///                                      Let's do it                                                        ///
///                                      Let's try it                                                       ///
/// ///////////////////////////////////////////////////////////////////////////////////////////////////////////

//////////////

int main(){
// freopen("in.txt","r",stdin);

    int  N=Int;
    int m=Int;

    N=1<<N;
     int tree[N<<1];
    // error(N);

      rep(i,N){
        tree[N+i]=Int;
        //error(N+i,tree[N+i]);
      }
      bool f=1;
      int itrval=N>>1;
      for(int i=N-1,k=1,j=0;i>0;i--){
              if(f)
              tree[i] = tree[i<<1]|tree[i<<1 |1];
              else tree[i] = tree[i<<1]^tree[i<<1 |1];

             /* j++;
              if(j>=itrval){
                k++;
                j=0;
                itrval=N>>k;
                f^=1;
              }*/
                if(i &(i-1)==0) f^=1;

            }
            //error(tree[1],tree[2],tree[3],tree[4]);

      rep(i,m){
         int t=Int-1;

           f=1;
          tree[N+t]=Int;
            for(int i=(N+t)>>1;i>0;i>>=1){
              if(f)
              tree[i] = tree[i<<1]|tree[i<<1 |1];
              else tree[i] = tree[i<<1]^tree[i<<1|1];
              f^=1;

            }
          cout<<tree[1]<<En;

      }

 return 0;
}


///      TANVIR HASAN

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

#define hello      printf("HELLO\n")
#define uu         first
#define vv         second
#define pb         push_back
#define mp         make_pair
#define LL         long long
#define inf        INT_MAX/3
#define mod        1000000007ll
#define PI         acos(-1.0)
#define linf       (1ll<<60)-1
#define pii        pair<int,int>
#define vl        vector<LL>
#define vi        vector<int>
#define vs        vector<string>
#define pii        pair<int,int>

#define ALL(A)     (A).begin(),(A).end()
#define mset(a,v)     memset(a,v,sizeof a)
#define setinf(ar)  memset(ar,126,sizeof ar)
#define vsort(v)   sort(v.begin(),v.end())

#define FOR(I,A,B) for (__typeof (B) I = (A) ; I <= B ; ++I)
#define rof(i, a, b)    for (__typeof (b)i = (b) ; i >= a ; --i)
#define rep(I, n)       for (__typeof (n) I = 0 ; I < n ; ++I)
#define per(i, n)       for (__typeof (n)i = (n-1) ; i >= 0 ; --i)
#define forstl(I, s)    for (__typeof ((s).end ()) I = (s).begin (); I != (s).end (); ++I)
#define rofstl(I, s)    for (__typeof ((s).end ()) I = (s).end ()-1; I != (s).begin (); --I)

#define Int ({int a; scanf("%d", &a); a;})
#define I64 ({LL a; scanf("%I64d", &a); a;})
#define Double ({double a; scanf("%lf", &a); a;})
#define Char ({char a; scanf("%c", &a); a;})
void FastIO()  {ios::sync_with_stdio(0);cin.tie(0);}

#define En "\n"
#define round(a,b,n) ((a-1+b)% n + n)% n + 1  /// 1 base round,, a starting index ,,+b for left to right,,-b for left,|b| turn,,total n gor
#define tata return 0
///           error////////////////////

#define error(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); puts(""); }

vector<string> split(const string& s, char c) {
    vector<string> v;
    stringstream ss(s);
    string x;
    while (getline(ss, x, c))
        v.emplace_back(x);
    return move(v);
}

void err(vector<string>::iterator it) {}
template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
    cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << "  ";
    err(++it, args...);
}

#define dbg(x) cout<<#x<<" : "<<x<<endl
///          eeerrrrooooooorrrrrrr //////////////////

template <class T> inline T bigmod(T p,T e,T M){LL ret = 1;for(; e > 0; e >>= 1){if(e & 1) ret = (ret * p) % M;p = (p * p) % M;}return (T)ret;}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}   // M is prime}
template <class T> inline T bpow(T p,T e){LL ret = 1;for(; e > 0; e >>= 1){if(e & 1) ret = (ret * p);p = (p * p);}return (T)ret;}

#define EPS numeric_limits<double>::epsilon()

/// ///////////////////////////////////////////////////////////////////////////////////////////////////////////
///                                      Let's do it                                                        ///
///                                      Let's try it                                                       ///
/// ///////////////////////////////////////////////////////////////////////////////////////////////////////////

//////////////

int  tree[1<<20];

int main(){
 // freopen("in.txt","r",stdin);

    int  N=Int;
    int m=Int;

    N=1<<N;
    // error(N);

      rep(i,N){
        tree[N+i]=Int;
        //error(N+i,tree[N+i]);
      }
      bool f=1;
      int itrval=N>>1;
      for(int i=N-1,k=1,j=0;i>0;i--){
              if(f)
              tree[i] = tree[i<<1]|tree[i<<1 |1];
              else tree[i] = tree[i<<1]^tree[i<<1 |1];

             /* j++;
              if(j>=itrval){
                k++;
                j=0;
                itrval=N>>k;
                f^=1;
              }*/
                if(i &(i-1)==0) f^=1;

            }
            //error(tree[1],tree[2],tree[3],tree[4]);

      rep(i,m){
         int t=Int-1;
          int ans=0;
           f=1;
          tree[N+t]=Int;
            for(int i=N+t;i>1;i>>=1){
              if(f)
              tree[i>>1] = tree[i]|tree[i^1];
              else tree[i>>1] = tree[i]^tree[i^1];
              f^=1;

            }
          cout<<tree[1]<<En;

      }

 return 0;
}


///      TANVIR HASAN
///   http://codeforces.com/problemset/problem/339/D

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

#define hello      printf("HELLO\n")
#define uu         first
#define vv         second
#define pb         push_back
#define mp         make_pair
#define LL         long long
#define inf        INT_MAX/3
#define mod        1000000007ll
#define PI         acos(-1.0)
#define linf       (1ll<<60)-1
#define pii        pair<int,int>
#define vl        vector<LL>
#define vi        vector<int>
#define vs        vector<string>
#define pii        pair<int,int>

#define ALL(A)     (A).begin(),(A).end()
#define mset(a,v)     memset(a,v,sizeof a)
#define setinf(ar)  memset(ar,126,sizeof ar)
#define vsort(v)   sort(v.begin(),v.end())

#define FOR(I,A,B) for (__typeof (B) I = (A) ; I <= B ; ++I)
#define rof(i, a, b)    for (__typeof (b)i = (b) ; i >= a ; --i)
#define rep(I, n)       for (__typeof (n) I = 0 ; I < n ; ++I)
#define per(i, n)       for (__typeof (n)i = (n-1) ; i >= 0 ; --i)
#define forstl(I, s)    for (__typeof ((s).end ()) I = (s).begin (); I != (s).end (); ++I)
#define rofstl(I, s)    for (__typeof ((s).end ()) I = (s).end ()-1; I != (s).begin (); --I)

#define Int ({int a; scanf("%d", &a); a;})
#define I64 ({LL a; scanf("%I64d", &a); a;})
#define Double ({double a; scanf("%lf", &a); a;})
#define Char ({char a; scanf("%c", &a); a;})
void FastIO()  {ios::sync_with_stdio(0);cin.tie(0);}

#define En "\n"
#define round(a,b,n) ((a-1+b)% n + n)% n + 1  /// 1 base round,, a starting index ,,+b for left to right,,-b for left,|b| turn,,total n gor
#define tata return 0
///           error////////////////////

#define error(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); puts(""); }

vector<string> split(const string& s, char c) {
    vector<string> v;
    stringstream ss(s);
    string x;
    while (getline(ss, x, c))
        v.emplace_back(x);
    return move(v);
}

void err(vector<string>::iterator it) {}
template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
    cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << "  ";
    err(++it, args...);
}

#define dbg(x) cout<<#x<<" : "<<x<<endl
///          eeerrrrooooooorrrrrrr //////////////////

template <class T> inline T bigmod(T p,T e,T M){LL ret = 1;for(; e > 0; e >>= 1){if(e & 1) ret = (ret * p) % M;p = (p * p) % M;}return (T)ret;}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}   // M is prime}
template <class T> inline T bpow(T p,T e){LL ret = 1;for(; e > 0; e >>= 1){if(e & 1) ret = (ret * p);p = (p * p);}return (T)ret;}

#define EPS numeric_limits<double>::epsilon()

/// ///////////////////////////////////////////////////////////////////////////////////////////////////////////
///                                      Let's do it                                                        ///
///                                      Let's try it                                                       ///
/// ///////////////////////////////////////////////////////////////////////////////////////////////////////////

//////////////

int  tree[1<<22];

int main(){
 // freopen("in.txt","r",stdin);

    int  N=Int;
    int m=Int;

    N=1<<N;
    // error(N);

      rep(i,N){
        tree[N+i]=Int;
        //error(N+i,tree[N+i]);
      }
      bool f=1;
      for(int i=N-1,k=1,j=0;i;i--){
              if(f)
              tree[i] = tree[i<<1]|tree[i<<1 |1];
              else tree[i] = tree[i<<1]^tree[i<<1 |1];

             if(i &(i-1)==0) f^=1;

            }
            //error(tree[1],tree[2],tree[3],tree[4]);

      rep(i,m){
         int t=Int-1;

           f=1;
          tree[N+t]=Int;
            for(int i=(N+t)>>1;i;i>>=1){
              if(f)
              tree[i] = tree[i<<1]|tree[i<<1 |1];
              else tree[i] = tree[i<<1]^tree[i<<1 |1];
              f^=1;

            }
          cout<<tree[1]<<En;

      }

 return 0;
}


///      TANVIR HASAN

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

#define hello      printf("HELLO\n")
#define uu         first
#define vv         second
#define pb         push_back
#define mp         make_pair
#define LL         long long
#define inf        INT_MAX/3
#define mod        1000000007ll
#define PI         acos(-1.0)
#define linf       (1ll<<60)-1
#define pii        pair<int,int>
#define vl        vector<LL>
#define vi        vector<int>
#define vs        vector<string>
#define pii        pair<int,int>

#define ALL(A)     (A).begin(),(A).end()
#define mset(a,v)     memset(a,v,sizeof a)
#define setinf(ar)  memset(ar,126,sizeof ar)
#define vsort(v)   sort(v.begin(),v.end())

#define FOR(I,A,B) for (__typeof (B) I = (A) ; I <= B ; ++I)
#define rof(i, a, b)    for (__typeof (b)i = (b) ; i >= a ; --i)
#define rep(I, n)       for (__typeof (n) I = 0 ; I < n ; ++I)
#define per(i, n)       for (__typeof (n)i = (n-1) ; i >= 0 ; --i)
#define forstl(I, s)    for (__typeof ((s).end ()) I = (s).begin (); I != (s).end (); ++I)
#define rofstl(I, s)    for (__typeof ((s).end ()) I = (s).end ()-1; I != (s).begin (); --I)

#define Int ({int a; scanf("%d", &a); a;})
#define I64 ({LL a; scanf("%I64d", &a); a;})
#define Double ({double a; scanf("%lf", &a); a;})
#define Char ({char a; scanf("%c", &a); a;})
void FastIO()  {ios::sync_with_stdio(0);cin.tie(0);}

#define En "\n"
#define round(a,b,n) ((a-1+b)% n + n)% n + 1  /// 1 base round,, a starting index ,,+b for left to right,,-b for left,|b| turn,,total n gor
#define tata return 0
///           error////////////////////

#define error(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); puts(""); }

vector<string> split(const string& s, char c) {
    vector<string> v;
    stringstream ss(s);
    string x;
    while (getline(ss, x, c))
        v.emplace_back(x);
    return move(v);
}

void err(vector<string>::iterator it) {}
template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
    cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << "  ";
    err(++it, args...);
}

#define dbg(x) cout<<#x<<" : "<<x<<endl
///          eeerrrrooooooorrrrrrr //////////////////

template <class T> inline T bigmod(T p,T e,T M){LL ret = 1;for(; e > 0; e >>= 1){if(e & 1) ret = (ret * p) % M;p = (p * p) % M;}return (T)ret;}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}   // M is prime}
template <class T> inline T bpow(T p,T e){LL ret = 1;for(; e > 0; e >>= 1){if(e & 1) ret = (ret * p);p = (p * p);}return (T)ret;}

#define EPS numeric_limits<double>::epsilon()

/// ///////////////////////////////////////////////////////////////////////////////////////////////////////////
///                                      Let's do it                                                        ///
///                                      Let's try it                                                       ///
/// ///////////////////////////////////////////////////////////////////////////////////////////////////////////

//////////////

int  tree[1<<20];

int main(){
 // freopen("in.txt","r",stdin);

    int  N=Int;
    int m=Int;

    N=1<<N;
    // error(N);

      rep(i,N){
        tree[N+i]=Int;
        //error(N+i,tree[N+i]);
      }
      bool f=1;
      int itrval=N>>1;
      for(int i=N-1,k=1,j=0;i>0;i--){
              if(f)
              tree[i] = tree[i<<1]|tree[i<<1 |1];
              else tree[i] = tree[i<<1]^tree[i<<1 |1];
             // error(i,tree[i],i<<1,tree[i<<1],i<<1 |1,tree[i<<1 |1])
              j++;
              if(j>=itrval){
                k++;
                j=0;
                itrval=N>>k;
                f^=1;
              }

            }
            //error(tree[1],tree[2],tree[3],tree[4]);

      rep(i,m){
         int t=Int-1;
          int ans=0;
           f=1;
          tree[N+t]=Int;
            for(int i=N+t;i>1;i>>=1){
              if(f)
              tree[i>>1] = tree[i]|tree[i^1];
              else tree[i>>1] = tree[i]^tree[i^1];
              f^=1;

            }
          cout<<tree[1]<<En;

      }

 return 0;
}


///      TANVIR HASAN

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

#define hello      printf("HELLO\n")
#define uu         first
#define vv         second
#define pb         push_back
#define mp         make_pair
#define LL         long long
#define inf        INT_MAX/3
#define mod        1000000007ll
#define PI         acos(-1.0)
#define linf       (1ll<<60)-1
#define pii        pair<int,int>
#define vl        vector<LL>
#define vi        vector<int>
#define vs        vector<string>
#define pii        pair<int,int>

#define ALL(A)     (A).begin(),(A).end()
#define mset(a,v)     memset(a,v,sizeof a)
#define setinf(ar)  memset(ar,126,sizeof ar)
#define vsort(v)   sort(v.begin(),v.end())

#define FOR(I,A,B) for (__typeof (B) I = (A) ; I <= B ; ++I)
#define rof(i, a, b)    for (__typeof (b)i = (b) ; i >= a ; --i)
#define rep(I, n)       for (__typeof (n) I = 0 ; I < n ; ++I)
#define per(i, n)       for (__typeof (n)i = (n-1) ; i >= 0 ; --i)
#define forstl(I, s)    for (__typeof ((s).end ()) I = (s).begin (); I != (s).end (); ++I)
#define rofstl(I, s)    for (__typeof ((s).end ()) I = (s).end ()-1; I != (s).begin (); --I)

#define Int ({int a; scanf("%d", &a); a;})
#define I64 ({LL a; scanf("%I64d", &a); a;})
#define Double ({double a; scanf("%lf", &a); a;})
#define Char ({char a; scanf("%c", &a); a;})
void FastIO()  {ios::sync_with_stdio(0);cin.tie(0);}

#define En "\n"
#define round(a,b,n) ((a-1+b)% n + n)% n + 1  /// 1 base round,, a starting index ,,+b for left to right,,-b for left,|b| turn,,total n gor
#define tata return 0
///           error////////////////////

#define error(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); puts(""); }

vector<string> split(const string& s, char c) {
    vector<string> v;
    stringstream ss(s);
    string x;
    while (getline(ss, x, c))
        v.emplace_back(x);
    return move(v);
}

void err(vector<string>::iterator it) {}
template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
    cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << "  ";
    err(++it, args...);
}

#define dbg(x) cout<<#x<<" : "<<x<<endl
///          eeerrrrooooooorrrrrrr //////////////////

template <class T> inline T bigmod(T p,T e,T M){LL ret = 1;for(; e > 0; e >>= 1){if(e & 1) ret = (ret * p) % M;p = (p * p) % M;}return (T)ret;}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}   // M is prime}
template <class T> inline T bpow(T p,T e){LL ret = 1;for(; e > 0; e >>= 1){if(e & 1) ret = (ret * p);p = (p * p);}return (T)ret;}

#define EPS numeric_limits<double>::epsilon()

/// ///////////////////////////////////////////////////////////////////////////////////////////////////////////
///                                      Let's do it                                                        ///
///                                      Let's try it                                                       ///
/// ///////////////////////////////////////////////////////////////////////////////////////////////////////////

//////////////

int  tree[1<<20];

int main(){
//  freopen("in.txt","r",stdin);

    int  N=Int;
    int m=Int;

    N=1<<N;
    // error(N);

      rep(i,N){
        tree[N+i]=Int;
        //error(N+i,tree[N+i]);
      }
      bool f=1;
      int itrval=N>>1;
      for(int i=N-1,k=1,j=0;i>0;i--){
              if(f)
              tree[i] = tree[i<<1]|tree[i<<1 |1];
              else tree[i] = tree[i<<1]^tree[i<<1 |1];
             // error(i,tree[i],i<<1,tree[i<<1],i<<1 |1,tree[i<<1 |1])
              /*j++;
              if(j>=itrval){
                k++;
                j=0;
                itrval=N>>k;
                f^=1;
              }*/
                if(i &(i-1)==0) f^=1;

            }
            //error(tree[1],tree[2],tree[3],tree[4]);

      rep(i,m){
         int t=Int-1;
          int ans=0;
           f=1;
          tree[N+t]=Int;
            for(int i=N+t;i>1;i>>=1){
              if(f)
              tree[i>>1] = tree[i]|tree[i^1];
              else tree[i>>1] = tree[i]^tree[i^1];
              f^=1;

            }
          cout<<tree[1]<<En;

      }

 return 0;
}


///      TANVIR HASAN
///   http://codeforces.com/problemset/problem/339/D

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

#define hello      printf("HELLO\n")
#define uu         first
#define vv         second
#define pb         push_back
#define mp         make_pair
#define LL         long long
#define inf        INT_MAX/3
#define mod        1000000007ll
#define PI         acos(-1.0)
#define linf       (1ll<<60)-1
#define pii        pair<int,int>
#define vl        vector<LL>
#define vi        vector<int>
#define vs        vector<string>
#define pii        pair<int,int>

#define ALL(A)     (A).begin(),(A).end()
#define mset(a,v)     memset(a,v,sizeof a)
#define setinf(ar)  memset(ar,126,sizeof ar)
#define vsort(v)   sort(v.begin(),v.end())

#define FOR(I,A,B) for (__typeof (B) I = (A) ; I <= B ; ++I)
#define rof(i, a, b)    for (__typeof (b)i = (b) ; i >= a ; --i)
#define rep(I, n)       for (__typeof (n) I = 0 ; I < n ; ++I)
#define per(i, n)       for (__typeof (n)i = (n-1) ; i >= 0 ; --i)
#define forstl(I, s)    for (__typeof ((s).end ()) I = (s).begin (); I != (s).end (); ++I)
#define rofstl(I, s)    for (__typeof ((s).end ()) I = (s).end ()-1; I != (s).begin (); --I)

#define Int ({int a; scanf("%d", &a); a;})
#define I64 ({LL a; scanf("%I64d", &a); a;})
#define Double ({double a; scanf("%lf", &a); a;})
#define Char ({char a; scanf("%c", &a); a;})
void FastIO()  {ios::sync_with_stdio(0);cin.tie(0);}

#define En "\n"
#define round(a,b,n) ((a-1+b)% n + n)% n + 1  /// 1 base round,, a starting index ,,+b for left to right,,-b for left,|b| turn,,total n gor
#define tata return 0
///           error////////////////////

#define error(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); puts(""); }

vector<string> split(const string& s, char c) {
    vector<string> v;
    stringstream ss(s);
    string x;
    while (getline(ss, x, c))
        v.emplace_back(x);
    return move(v);
}

void err(vector<string>::iterator it) {}
template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
    cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << "  ";
    err(++it, args...);
}

#define dbg(x) cout<<#x<<" : "<<x<<endl
///          eeerrrrooooooorrrrrrr //////////////////

template <class T> inline T bigmod(T p,T e,T M){LL ret = 1;for(; e > 0; e >>= 1){if(e & 1) ret = (ret * p) % M;p = (p * p) % M;}return (T)ret;}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}   // M is prime}
template <class T> inline T bpow(T p,T e){LL ret = 1;for(; e > 0; e >>= 1){if(e & 1) ret = (ret * p);p = (p * p);}return (T)ret;}

#define EPS numeric_limits<double>::epsilon()

/// ///////////////////////////////////////////////////////////////////////////////////////////////////////////
///                                      Let's do it                                                        ///
///                                      Let's try it                                                       ///
/// ///////////////////////////////////////////////////////////////////////////////////////////////////////////

//////////////

int  tree[1<<22];

int main(){
 // freopen("in.txt","r",stdin);

    int  N=Int;
    int m=Int;

    N=1<<N;
    // error(N);

      rep(i,N){
        tree[N+i]=Int;
        //error(N+i,tree[N+i]);
      }

      for(int i=N-1,k=1,j=0;i;i--){
              if(f)
              tree[i] = tree[i<<1]|tree[i<<1 |1];
              else tree[i] = tree[i<<1]^tree[i<<1 |1];

             if(i &(i-1)==0) f^=1;

            }
            //error(tree[1],tree[2],tree[3],tree[4]);

      rep(i,m){
         int t=Int-1;

           f=1;
          tree[N+t]=Int;
            for(int i=(N+t)>>1;i;i>>=1){
              if(f)
              tree[i] = tree[i<<1]|tree[i<<1 |1];
              else tree[i] = tree[i<<1]^tree[i<<1 |1];
              f^=1;

            }
          cout<<tree[1]<<En;

      }

 return 0;
}


///      TANVIR HASAN

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

#define hello      printf("HELLO\n")
#define uu         first
#define vv         second
#define pb         push_back
#define mp         make_pair
#define LL         long long
#define inf        INT_MAX/3
#define mod        1000000007ll
#define PI         acos(-1.0)
#define linf       (1ll<<60)-1
#define pii        pair<int,int>
#define vl        vector<LL>
#define vi        vector<int>
#define vs        vector<string>
#define pii        pair<int,int>

#define ALL(A)     (A).begin(),(A).end()
#define mset(a,v)     memset(a,v,sizeof a)
#define setinf(ar)  memset(ar,126,sizeof ar)
#define vsort(v)   sort(v.begin(),v.end())

#define FOR(I,A,B) for (__typeof (B) I = (A) ; I <= B ; ++I)
#define rof(i, a, b)    for (__typeof (b)i = (b) ; i >= a ; --i)
#define rep(I, n)       for (__typeof (n) I = 0 ; I < n ; ++I)
#define per(i, n)       for (__typeof (n)i = (n-1) ; i >= 0 ; --i)
#define forstl(I, s)    for (__typeof ((s).end ()) I = (s).begin (); I != (s).end (); ++I)
#define rofstl(I, s)    for (__typeof ((s).end ()) I = (s).end ()-1; I != (s).begin (); --I)

#define Int ({int a; scanf("%d", &a); a;})
#define I64 ({LL a; scanf("%I64d", &a); a;})
#define Double ({double a; scanf("%lf", &a); a;})
#define Char ({char a; scanf("%c", &a); a;})
void FastIO()  {ios::sync_with_stdio(0);cin.tie(0);}

#define En "\n"
#define round(a,b,n) ((a-1+b)% n + n)% n + 1  /// 1 base round,, a starting index ,,+b for left to right,,-b for left,|b| turn,,total n gor
#define tata return 0
///           error////////////////////

#define error(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); puts(""); }

vector<string> split(const string& s, char c) {
    vector<string> v;
    stringstream ss(s);
    string x;
    while (getline(ss, x, c))
        v.emplace_back(x);
    return move(v);
}

void err(vector<string>::iterator it) {}
template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
    cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << "  ";
    err(++it, args...);
}

#define dbg(x) cout<<#x<<" : "<<x<<endl
///          eeerrrrooooooorrrrrrr //////////////////

template <class T> inline T bigmod(T p,T e,T M){LL ret = 1;for(; e > 0; e >>= 1){if(e & 1) ret = (ret * p) % M;p = (p * p) % M;}return (T)ret;}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}   // M is prime}
template <class T> inline T bpow(T p,T e){LL ret = 1;for(; e > 0; e >>= 1){if(e & 1) ret = (ret * p);p = (p * p);}return (T)ret;}

#define EPS numeric_limits<double>::epsilon()

/// ///////////////////////////////////////////////////////////////////////////////////////////////////////////
///                                      Let's do it                                                        ///
///                                      Let's try it                                                       ///
/// ///////////////////////////////////////////////////////////////////////////////////////////////////////////

//////////////

int  tree[1<<20];

int main(){
//  freopen("in.txt","r",stdin);

    int  N=Int;
    int m=Int;

    N=1<<N;
    // error(N);

      rep(i,N){
        tree[N+i]=Int;
        //error(N+i,tree[N+i]);
      }
      bool f=1;
      int itrval=N>>1;
      for(int i=N-1,k=1,j=0;i>0;i--){
              if(f)
              tree[i] = tree[i<<1]|tree[i<<1 |1];
              else tree[i] = tree[i<<1]^tree[i<<1 |1];

              j++;
              if(j>=itrval){
                k++;
                j=0;
                itrval=N>>k;
                f^=1;
              }
               // if(i &(i-1)==0) f^=1;

            }
            //error(tree[1],tree[2],tree[3],tree[4]);

      rep(i,m){
         int t=Int-1;
          int ans=0;
           f=1;
          tree[N+t]=Int;
            for(int i=N+t;i>1;i>>=1){
              if(f)
              tree[i>>1] = tree[i]|tree[i^1];
              else tree[i>>1] = tree[i]^tree[i^1];
              f^=1;

            }
          cout<<tree[1]<<En;

      }

 return 0;
}


///      TANVIR HASAN

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

#define hello      printf("HELLO\n")
#define uu         first
#define vv         second
#define pb         push_back
#define mp         make_pair
#define LL         long long
#define inf        INT_MAX/3
#define mod        1000000007ll
#define PI         acos(-1.0)
#define linf       (1ll<<60)-1
#define pii        pair<int,int>
#define vl        vector<LL>
#define vi        vector<int>
#define vs        vector<string>
#define pii        pair<int,int>

#define ALL(A)     (A).begin(),(A).end()
#define mset(a,v)     memset(a,v,sizeof a)
#define setinf(ar)  memset(ar,126,sizeof ar)
#define vsort(v)   sort(v.begin(),v.end())

#define FOR(I,A,B) for (__typeof (B) I = (A) ; I <= B ; ++I)
#define rof(i, a, b)    for (__typeof (b)i = (b) ; i >= a ; --i)
#define rep(I, n)       for (__typeof (n) I = 0 ; I < n ; ++I)
#define per(i, n)       for (__typeof (n)i = (n-1) ; i >= 0 ; --i)
#define forstl(I, s)    for (__typeof ((s).end ()) I = (s).begin (); I != (s).end (); ++I)
#define rofstl(I, s)    for (__typeof ((s).end ()) I = (s).end ()-1; I != (s).begin (); --I)

#define Int ({int a; scanf("%d", &a); a;})
#define I64 ({LL a; scanf("%I64d", &a); a;})
#define Double ({double a; scanf("%lf", &a); a;})
#define Char ({char a; scanf("%c", &a); a;})
void FastIO()  {ios::sync_with_stdio(0);cin.tie(0);}

#define En "\n"
#define round(a,b,n) ((a-1+b)% n + n)% n + 1  /// 1 base round,, a starting index ,,+b for left to right,,-b for left,|b| turn,,total n gor
#define tata return 0
///           error////////////////////

#define error(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); puts(""); }

vector<string> split(const string& s, char c) {
    vector<string> v;
    stringstream ss(s);
    string x;
    while (getline(ss, x, c))
        v.emplace_back(x);
    return move(v);
}

void err(vector<string>::iterator it) {}
template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
    cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << "  ";
    err(++it, args...);
}

#define dbg(x) cout<<#x<<" : "<<x<<endl
///          eeerrrrooooooorrrrrrr //////////////////

template <class T> inline T bigmod(T p,T e,T M){LL ret = 1;for(; e > 0; e >>= 1){if(e & 1) ret = (ret * p) % M;p = (p * p) % M;}return (T)ret;}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}   // M is prime}
template <class T> inline T bpow(T p,T e){LL ret = 1;for(; e > 0; e >>= 1){if(e & 1) ret = (ret * p);p = (p * p);}return (T)ret;}

#define EPS numeric_limits<double>::epsilon()

/// ///////////////////////////////////////////////////////////////////////////////////////////////////////////
///                                      Let's do it                                                        ///
///                                      Let's try it                                                       ///
/// ///////////////////////////////////////////////////////////////////////////////////////////////////////////

//////////////

int  tree[1<<20];

int main(){
 // freopen("in.txt","r",stdin);

    int  N=Int;
    int m=Int;

    N=1<<N;
    // error(N);

      rep(i,N){
        tree[N+i]=Int;
        //error(N+i,tree[N+i]);
      }
      bool f=1;
      int itrval=N>>1;
      for(int i=N-1,k=1,j=0;i>0;i--){
              if(f)
              tree[i] = tree[i<<1]|tree[i<<1 |1];
              else tree[i] = tree[i<<1]^tree[i<<1 |1];

              j++;
              if(j>=itrval){
                k++;
                j=0;
                itrval=N>>k;
                f^=1;
              }
               // if(i &(i-1)==0) f^=1;

            }
            //error(tree[1],tree[2],tree[3],tree[4]);

      rep(i,m){
         int t=Int-1;
          int ans=0;
           f=1;
          tree[N+t]=Int;
            for(int i=N+t;i>1;i>>=1){
              if(f)
              tree[i>>1] = tree[i]|tree[i^1];
              else tree[i>>1] = tree[i]^tree[i^1];
              f^=1;

            }
          cout<<tree[1]<<En;

      }

 return 0;
}


#include <bits/stdc++.h>
#define clr(x) memset((x), 0, sizeof(x))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define mp make_pair
#define For(i, st, en) for(int i=(st); i<=(int)(en); i++)
#define Ford(i, st, en) for(int i=(st); i>=(int)(en); i--)
#define forn(i, n) for(int i=0; i<(int)(n); i++)
#define ford(i, n) for(int i=(n)-1; i>=0; i--)
#define fori(it, x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define in(x) int (x); input((x));
#define x first
#define y second
#define less(a,b) ((a) < (b) - EPS)
#define more(a,b) ((a) > (b) + EPS)
#define eq(a,b) (fabs((a) - (b)) < EPS)
#define remax(a, b) ((a) = (b) > (a) ? (b) : (a))
#define remin(a, b) ((a) = (b) < (a) ? (b) : (a))
using namespace std;
typedef long double ld; template <class _T> inline _T sqr(const _T& x) {return x * x;} template <class _T> inline string tostr(const _T& a) {ostringstream os(""); os << a; return os.str();} const ld PI = 3.1415926535897932384626433832795L; const double EPS = 1-9; char TEMPORARY_CHAR; typedef long long ll; typedef unsigned long long ull; typedef set < int > SI; typedef vector < int > VI; typedef vector < vector < int > > VVI; typedef map < string, int > MSI; typedef pair < int, int > PII; const int INF = 1e9; inline void input(int &a) {a = 0; while (((TEMPORARY_CHAR = getchar()) > '9' || TEMPORARY_CHAR < '0') && (TEMPORARY_CHAR != '-')){} char neg = 0; if (TEMPORARY_CHAR == '-') {neg = 1; TEMPORARY_CHAR = getchar();} while (TEMPORARY_CHAR <= '9' && TEMPORARY_CHAR >= '0') {a = 10 * a + TEMPORARY_CHAR - '0'; TEMPORARY_CHAR = getchar();} if (neg) a = -a;} inline void out(int a) {if (!a) putchar('0'); if (a < 0) {putchar('-'); a = -a;} char s[10]; int i; for(i = 0; a; ++i) {s[i] = '0' + a % 10; a /= 10;} ford(j, i) putchar(s[j]);} inline int nxt() {in(ret); return ret;}

#define bit(a, pos) ((a >> pos) & 1)

int main()
{
    in(n); in(m);
    n = 1 << n;
    int a[2 * n];
    for(int i = 0; i < n; ++i)
        a[i + n] = nxt();
    int cur = 1;
    for(int i = n - 1; i; --i)
    {
        if (cur)
            a[i] = a[i + i] | a[i + i + 1];
        else
            a[i] = a[i + i] ^ a[i + i + 1];
        if ((i & (i - 1)) == 0) cur ^= 1;
    }
    while(m--)
    {
        in(pos);
        pos = pos + n - 1;
        in(val);
        a[pos] = val;
        pos >>= 1;
        cur = 1;
        while(pos)
        {
            if (cur)
                a[pos] = a[pos + pos] | a[pos + pos + 1];
            else
                a[pos] = a[pos + pos] ^ a[pos + pos + 1];
            cur ^= 1;
            pos >>= 1;
        }
        out(a[1]);
        puts("");
    }
    return 0;
}


#include <iostream>
#include <cmath>
using namespace std;
const int SIZE = 132000;

bool check_power_2(int n){
    return n && !(n & (n - 1));
}

void build(int *a, int size){
    bool XOR = false;
    for (int i = size - 1; i > 0; i--){
        if (!XOR){
            a[i] = a[i*2] | a[i*2 + 1];
        }
        else {
            a[i] = a[i*2] ^ a[i*2 + 1];
        }
        if (check_power_2(i)){
            XOR = !XOR;
        }
    }
}

void modify(int *a, int pos, int value, int size){
    pos += size;
    a[pos] = value;
    bool XOR = false;
    for (int i = pos; i>1; i >>= 1){
        if (!XOR){
            a[i>>1] = a[i] | a[i^1];
        }
        else {
            a[i>>1] = a[i] ^ a[i^1];
        }
        XOR = !XOR;
    }
}

int main(){
    int n, m;
    cin >> n >> m;
    int size;
    size = (int)(pow(2, n));
    int arr[SIZE];
    for (int i = 0; i<SIZE; i++){
        arr[i] = -1;
    }

    for (int i = size; i < 2*size; i++){
        cin >> arr[i];
    }

    build(arr, size);

    while (m > 0){
        m--;
        int p, b;
        cin >> p >> b;
        modify(arr, p-1, b, size);
        cout << arr[1] << "\n";
    }

}


#include <iostream>
#include <cmath>
using namespace std;
const int SIZE = 2 * 132000;

void build(int *a, bool *p, int size){
    for (int i = size - 1; i > 0; i--){
        a[i] = p[i<<1] ? a[i<<1]^a[i<<1|1] : a[i<<1]|a[i<<1|1];
        p[i] = !p[i<<1];
    }
}

void modify(int *a, int pos, bool *p, int value, int size){
    pos += size;
    a[pos] = value;
    for (int i = pos; i>1; i >>= 1){
        a[i>>1] = p[i] ? (a[i]^a[i^1]) : (a[i]|a[i^1]);
    }
}

int main(){
    int n, m;
    cin >> n >> m;
    int arr[SIZE];
    bool p[SIZE];
    for (int i = 0; i<SIZE; i++){
        arr[i] = -1;
    }

    for (int i=0;i<(1<<n);i++) {
        cin >> arr[(1<<n)+i];
    }

    build(arr, p, 1<<n);

    while (m > 0){
        m--;
        int pos, b;
        cin >> pos >> b;
        modify(arr, pos-1, p, b, 1<<n);
        cout << arr[1] << "\n";
    }

}


#include <iostream>
#include <cmath>
using namespace std;
const int SIZE = 132000;

bool check_power_2(int n){
    return n && !(n & (n - 1));
}

void build(int *a, bool *p, int size){
    for (int i = size - 1; i > 0; i--){
        a[i] = p[i<<1] ? a[i<<1]^a[i<<1|1] : a[i<<1]|a[i<<1|1];
        p[i] = !p[i<<1];
    }
}

void modify(int *a, int pos, bool *p, int value, int size){
    pos += size;
    a[pos] = value;
    for (int i = pos; i>1; i >>= 1){
        a[i>>1] = p[i] ? (a[i]^a[i^1]) : (a[i]|a[i^1]);
    }
}

int main(){
    int n, m;
    cin >> n >> m;
    int arr[SIZE];
    bool p[SIZE];
    for (int i = 0; i<SIZE; i++){
        arr[i] = -1;
    }

    for (int i=0;i<(1<<n);i++) {
        cin >> arr[(1<<n)+i];
    }

    build(arr, p, 1<<n);

    while (m > 0){
        m--;
        int pos, b;
        cin >> pos >> b;
        modify(arr, pos-1, p, b, 1<<n);
        cout << arr[1] << "\n";
    }

}


#include <iostream>
#include <cmath>
using namespace std;
const int SIZE = 132000;

bool check_power_2(int n){
    return n && !(n & (n - 1));
}

void build(int *a, int size){
    bool XOR = false;
    for (int i = size - 1; i > 0; i--){
        if (!XOR){
            a[i] = a[i*2] | a[i*2 + 1];
        }
        else {
            a[i] = a[i*2] ^ a[i*2 + 1];
        }
        if (check_power_2(i)){
            XOR = !XOR;
        }
    }
}

void modify(int *a, int pos, int value, int size){
    pos += size;
    a[pos] = value;
    bool XOR = false;
    for (int i = pos; i>1; i >>= 1){
        if (!XOR){
            a[i>>1] = a[i] | a[i^1];
        }
        else {
            a[i>>1] = a[i] ^ a[i^1];
        }
        XOR = !XOR;
    }
}

int main(){
    int n, m;
    cin >> n >> m;
    int arr[SIZE];
    for (int i = 0; i<SIZE; i++){
        arr[i] = -1;
    }

    for (int i=0;i<(1<<n);i++) {
        cin >> arr[(1<<n)+i];
    }

    build(arr, 1<<n);

    while (m > 0){
        m--;
        int p, b;
        cin >> p >> b;
        modify(arr, p-1, b, 1<<n);
        cout << arr[1] << "\n";
    }

}


#include <iostream>
#include <cmath>
using namespace std;
const int SIZE = 2 * 132000;

bool check_power_2(int n){
    return n && !(n & (n - 1));
}

void build(int *a, int size){
    bool XOR = false;
    for (int i = size - 1; i > 0; i--){
        if (!XOR){
            a[i] = a[i*2] | a[i*2 + 1];
        }
        else {
            a[i] = a[i*2] ^ a[i*2 + 1];
        }
        if (check_power_2(i)){
            XOR = !XOR;
        }
    }
}

void modify(int *a, int pos, int value, int size){
    pos += size;
    a[pos] = value;
    bool XOR = false;
    for (int i = pos; i>1; i >>= 1){
        if (!XOR){
            a[i>>1] = a[i] | a[i^1];
        }
        else {
            a[i>>1] = a[i] ^ a[i^1];
        }
        XOR = !XOR;
    }
}

int main(){
    int n, m;
    cin >> n >> m;
    int arr[SIZE];
    for (int i = 0; i<SIZE; i++){
        arr[i] = -1;
    }

    for (int i=(1<<n);i<2*(1<<n);i++) {
        cin >> arr[i];
    }

    build(arr, 1<<n);

    while (m > 0){
        m--;
        int p, b;
        cin >> p >> b;
        modify(arr, p-1, b, 1<<n);
        cout << arr[1] << "\n";
    }

}


#include <iostream>
#include <cmath>
using namespace std;
const int SIZE = 132000;

bool check_power_2(int n){
    return n && !(n & (n - 1));
}

void build(int *a, bool *p, int size){
    for (int i = size - 1; i > 0; i--){
        a[i] = p[i<<1] ? a[i<<1]^a[i<<1|1] : a[i<<1]|a[i<<1|1];
        p[i] = !p[i<<1];
    }
}

void modify(int *a, int pos, int value, int size){
    pos += size;
    a[pos] = value;
    bool XOR = false;
    for (int i = pos; i>1; i >>= 1){
        if (!XOR){
            a[i>>1] = a[i] | a[i^1];
        }
        else {
            a[i>>1] = a[i] ^ a[i^1];
        }
        XOR = !XOR;
    }
}

int main(){
    int n, m;
    cin >> n >> m;
    int arr[SIZE];
    bool p[SIZE];
    for (int i = 0; i<SIZE; i++){
        arr[i] = -1;
    }

    for (int i=0;i<(1<<n);i++) {
        cin >> arr[(1<<n)+i];
    }

    build(arr, p, 1<<n);

    while (m > 0){
        m--;
        int p, b;
        cin >> p >> b;
        modify(arr, p-1, b, 1<<n);
        cout << arr[1] << "\n";
    }

}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second

inline int left(int node){ return node<<1 ;}
inline int right(int node){ return (node<<1)+1;}
int a[200005];
struct data{
	int val;
	bool dist;
};
data tree[4*200005];
void build_tree(int node , int start , int end){
	if(start==end){
		tree[node].val = a[start];
		tree[node].dist = true;
		return;
	}
	else{
		int mid = (start+end)/2;

		build_tree(left(node),start,mid);
		build_tree(right(node),mid+1,end);
		if(tree[left(node)].dist){
			tree[node].val = tree[right(node)].val | tree[left(node)].val;
			tree[node].dist=false;
		}
		else{
			tree[node].val = tree[right(node)].val ^ tree[left(node)].val;
			tree[node].dist=true;
		}
	}
}
void update(int node , int start , int end , int ind , int value){
	if(start > end)return;
	if(start==end && ind==start){
		a[ind]=value;
		tree[node].val = value;
	}
	else{
		int mid = (start+end)/2;
		if(start <= ind && ind <= mid)
			update(left(node),start,mid,ind,value);
		else
			update(right(node),mid+1,end,ind,value);
		if(tree[left(node)].dist){
			tree[node].val = tree[right(node)].val | tree[left(node)].val;
			tree[node].dist=false;
		}
		else{
			tree[node].val = tree[right(node)].val ^ tree[left(node)].val;
			tree[node].dist=true;
		}
	}

}
int main(){

	int n , m  , i , j , k , p , b;
	cin >> n >> m ;
	int x = pow(2.0,n);
	for(i = 0 ; i < x ; i++){
		cin >> a[i];
	}
	build_tree(1,0,x-1);
	while(m--){
		cin >> p >> b;
		update(1,0,x-1,p-1,b);
		cout << tree[1].val << endl;
	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second

inline ll left(ll node){ return node<<1 ;}
inline ll right(ll node){ return (node<<1)+1;}
ll a[100005];
struct data{
	ll val;
	ll dist;
};
data tree[4*100005];
void build_tree(ll node , ll start , ll end){
	if(start==end){
		tree[node].val = a[start];
		tree[node].dist = 0;
		return;
	}
	ll mid = (start+end)/2;

	build_tree(left(node),start,mid);
	build_tree(right(node),mid+1,end);
	if(tree[left(node)].dist==0){
		tree[node].val = tree[right(node)].val | tree[left(node)].val;
		tree[node].dist+=1;
	}
	else{
		tree[node].val = tree[right(node)].val ^ tree[left(node)].val;
		tree[node].dist+=1;
	}
}
void update(ll node , ll start , ll end , ll ind , ll value){
	if(start > end)return;
	if(start==end && ind==start){
		a[ind]=value;
		tree[node].val = value;
		return;
	}
	ll mid = (start+end)/2;
	if(start <= ind && ind <= mid)
		update(left(node),start,mid,ind,value);
	else
		update(right(node),mid+1,end,ind,value);
	if(tree[left(node)].dist==0){
		tree[node].val = tree[right(node)].val | tree[left(node)].val;
		tree[node].dist+=1;
	}
	else{
		tree[node].val = tree[right(node)].val ^ tree[left(node)].val;
		tree[node].dist+=1;
	}

}
int main(){

	ll n , m  , i , j , k , p , b;
	cin >> n >> m ;
	ll x = pow(2.0,n);
	for(i = 0 ; i < x ; i++){
		cin >> a[i];
	}
	build_tree(1,0,x-1);
	while(m--){
		cin >> p >> b;
		update(1,0,x-1,p-1,b);
		cout << tree[1].val << endl;
	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second

inline ll left(ll node){ return node<<1 ;}
inline ll right(ll node){ return (node<<1)+1;}
ll a[200005];
struct data{
	ll val;
	bool dist;
};
data tree[4*200005];
void build_tree(ll node , ll start , ll end){
	if(start==end){
		tree[node].val = a[start];
		tree[node].dist = true;
		return;
	}
	ll mid = (start+end)/2;

	build_tree(left(node),start,mid);
	build_tree(right(node),mid+1,end);
	if(tree[left(node)].dist){
		tree[node].val = tree[right(node)].val | tree[left(node)].val;
		tree[node].dist=false;
	}
	else{
		tree[node].val = tree[right(node)].val ^ tree[left(node)].val;
		tree[node].dist=true;
	}
}
void update(ll node , ll start , ll end , ll ind , ll value){
	if(start > end)return;
	if(start==end && ind==start){
		a[ind]=value;
		tree[node].val = value;
		return;
	}
	ll mid = (start+end)/2;
	if(start <= ind && ind <= mid)
		update(left(node),start,mid,ind,value);
	else
		update(right(node),mid+1,end,ind,value);
	if(tree[left(node)].dist){
		tree[node].val = tree[right(node)].val | tree[left(node)].val;
		tree[node].dist=false;
	}
	else{
		tree[node].val = tree[right(node)].val ^ tree[left(node)].val;
		tree[node].dist=true;
	}

}
int main(){

	ll n , m  , i , j , k , p , b;
	cin >> n >> m ;
	ll x = pow(2.0,n);
	for(i = 0 ; i < x ; i++){
		cin >> a[i];
	}
	build_tree(1,0,x-1);
	while(m--){
		cin >> p >> b;
		update(1,0,x-1,p-1,b);
		cout << tree[1].val << endl;
	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second

inline ll left(ll node){ return node<<1 ;}
inline ll right(ll node){ return (node<<1)+1;}
ll a[200005];
struct data{
	ll val;
	bool dist;
};
data tree[4*200005];
void build_tree(ll node , ll start , ll end){
	if(start==end){
		tree[node].val = a[start];
		tree[node].dist = true;
		return;
	}
	else{
		ll mid = (start+end)/2;

		build_tree(2*node,start,mid);
		build_tree(2*node+1,mid+1,end);
		if(tree[2*node].dist){
			tree[node].val = tree[2*node+1].val | tree[2*node].val;
			tree[node].dist=false;
		}
		else{
			tree[node].val = tree[2*node+1].val ^ tree[2*node].val;
			tree[node].dist=true;
		}
	}
}
void update(ll node , ll start , ll end , ll ind , ll value){
	if(start > end)return;
	if(start==end && ind==start){
		a[ind]=value;
		tree[node].val = value;
	}
	else{
		ll mid = (start+end)/2;
		if(start <= ind && ind <= mid)
			update(2*node,start,mid,ind,value);
		else
			update(2*node+1,mid+1,end,ind,value);
		if(tree[2*node].dist){
			tree[node].val = tree[2*node+1].val | tree[2*node].val;
			tree[node].dist=false;
		}
		else{
			tree[node].val = tree[2*node+1].val ^ tree[2*node].val;
			tree[node].dist=true;
		}
	}

}
int main(){

	ll n , m  , i , j , k , p , b;
	cin >> n >> m ;
	ll x = pow(2.0,n);
	for(i = 0 ; i < x ; i++){
		cin >> a[i];
	}
	build_tree(1,0,x-1);
	while(m--){
		cin >> p >> b;
		update(1,0,x-1,p-1,b);
		cout << tree[1].val << endl;
	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second

inline int left(int node){ return node<<1 ;}
inline int right(int node){ return (node<<1)+1;}
int a[200005];
struct data{
	int val;
	bool dist;
};
data tree[4*200005];
void build_tree(int node , int start , int end){
	if(start==end){
		tree[node].val = a[start];
		tree[node].dist = true;
		return;
	}
	else{
		int mid = (start+end)/2;

		build_tree(left(node),start,mid);
		build_tree(right(node),mid+1,end);
		if(tree[left(node)].dist){
			tree[node].val = tree[right(node)].val | tree[left(node)].val;
			tree[node].dist=false;
		}
		else{
			tree[node].val = tree[right(node)].val ^ tree[left(node)].val;
			tree[node].dist=true;
		}
	}
}
void update(int node , int start , int end , int ind , int value){
	if(start > end)return;
	if(start==end && ind==start){
		a[ind]=value;
		tree[node].val = value;
	}
	else{
		int mid = (start+end)/2;
		if(start <= ind && ind <= mid)
			update(left(node),start,mid,ind,value);
		else
			update(right(node),mid+1,end,ind,value);
		if(tree[left(node)].dist){
			tree[node].val = tree[right(node)].val | tree[left(node)].val;
			tree[node].dist=false;
		}
		else{
			tree[node].val = tree[right(node)].val ^ tree[left(node)].val;
			tree[node].dist=true;
		}
	}

}
int main(){

	int n , m  , i , j , k , p , b;
	scanf("%d %d",&n,&m);
	int x = pow(2.0,n);
	for(i = 0 ; i < x ; i++){
		scanf("%d",&a[i]);
	}
	build_tree(1,0,x-1);
	while(m--){
		scanf("%d %d",&p,&b);
		update(1,0,x-1,p-1,b);
		printf("%d\n",tree[1].val);
	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second

inline ll left(ll node){ return node<<1 ;}
inline ll right(ll node){ return (node<<1)+1;}
ll a[400005];
struct data{
	ll val;
	ll dist;
};
data tree[4*400005];
void build_tree(ll node , ll start , ll end){
	if(start==end){
		tree[node].val = a[start];
		tree[node].dist = 0;
		return;
	}
	ll mid = (start+end)/2;

	build_tree(left(node),start,mid);
	build_tree(right(node),mid+1,end);
	if(tree[left(node)].dist==0){
		tree[node].val = tree[right(node)].val | tree[left(node)].val;
		tree[node].dist+=1;
	}
	else{
		tree[node].val = tree[right(node)].val ^ tree[left(node)].val;
		tree[node].dist+=1;
	}
}
void update(ll node , ll start , ll end , ll ind , ll value){
	if(start > end)return;
	if(start==end && ind==start){
		a[ind]=value;
		tree[node].val = value;
		return;
	}
	ll mid = (start+end)/2;
	if(start <= ind && ind <= mid)
		update(left(node),start,mid,ind,value);
	else
		update(right(node),mid+1,end,ind,value);
	if(tree[left(node)].dist==0){
		tree[node].val = tree[right(node)].val | tree[left(node)].val;
		tree[node].dist+=1;
	}
	else{
		tree[node].val = tree[right(node)].val ^ tree[left(node)].val;
		tree[node].dist+=1;
	}

}
int main(){

	ll n , m  , i , j , k , p , b;
	cin >> n >> m ;
	ll x = pow(2.0,n);
	for(i = 0 ; i < x ; i++){
		cin >> a[i];
	}
	build_tree(1,0,x-1);
	while(m--){
		cin >> p >> b;
		update(1,0,x-1,p-1,b);
		cout << tree[1].val << endl;
	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second

inline int left(int node){ return node<<1 ;}
inline int right(int node){ return (node<<1)+1;}
int a[200005];
struct data{
	int val;
	bool dist;
};
data tree[4*200005];
void build_tree(int node , int start , int end){
	if(start==end){
		tree[node].val = a[start];
		tree[node].dist = true;
		return;
	}
	else{
		int mid = (start+end)/2;

		build_tree(left(node),start,mid);
		build_tree(right(node),mid+1,end);
		if(tree[left(node)].dist){
			tree[node].val = tree[right(node)].val | tree[left(node)].val;
			tree[node].dist=false;
		}
		else{
			tree[node].val = tree[right(node)].val ^ tree[left(node)].val;
			tree[node].dist=true;
		}
	}
}
void update(int node , int start , int end , int ind , int value){
	if(start > end)return;
	if(start==end && ind==start){
		a[ind]=value;
		tree[node].val = value;
	}
	else{
		int mid = (start+end)/2;
		if(start <= ind && ind <= mid)
			update(left(node),start,mid,ind,value);
		else
			update(right(node),mid+1,end,ind,value);
		if(tree[left(node)].dist){
			tree[node].val = tree[right(node)].val | tree[left(node)].val;
			tree[node].dist=false;
		}
		else{
			tree[node].val = tree[right(node)].val ^ tree[left(node)].val;
			tree[node].dist=true;
		}
	}

}
int main(){

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n , m  , i , j , k , p , b;
	cin >> n >> m ;
	int x = pow(2.0,n);
	for(i = 0 ; i < x ; i++){
		cin >> a[i];
	}
	build_tree(1,0,x-1);
	while(m--){
		cin >> p >> b;
		update(1,0,x-1,p-1,b);
		cout << tree[1].val << endl;
	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second

inline int left(int node){ return node<<1 ;}
inline int right(int node){ return (node<<1)+1;}
int a[200005];
struct data{
	int val;
	bool dist;
};
data tree[4*200005];
void build_tree(int node , int start , int end){
	if(start==end){
		tree[node].val = a[start];
		tree[node].dist = true;
		return;
	}
	else{
		int mid = (start+end)/2;

		build_tree(2*node,start,mid);
		build_tree(2*node+1,mid+1,end);
		if(tree[2*node].dist){
			tree[node].val = tree[2*node+1].val | tree[2*node].val;
			tree[node].dist=false;
		}
		else{
			tree[node].val = tree[2*node+1].val ^ tree[2*node].val;
			tree[node].dist=true;
		}
	}
}
void update(int node , int start , int end , int ind , int value){
	if(start > end)return;
	if(start==end && ind==start){
		a[ind]=value;
		tree[node].val = value;
	}
	else{
		int mid = (start+end)/2;
		if(start <= ind && ind <= mid)
			update(2*node,start,mid,ind,value);
		else
			update(2*node+1,mid+1,end,ind,value);
		if(tree[2*node].dist){
			tree[node].val = tree[2*node+1].val | tree[2*node].val;
			tree[node].dist=false;
		}
		else{
			tree[node].val = tree[2*node+1].val ^ tree[2*node].val;
			tree[node].dist=true;
		}
	}

}
int main(){

	int n , m  , i , j , k , p , b;
	cin >> n >> m ;
	int x = pow(2.0,n);
	for(i = 0 ; i < x ; i++){
		cin >> a[i];
	}
	build_tree(1,0,x-1);
	while(m--){
		cin >> p >> b;
		update(1,0,x-1,p-1,b);
		cout << tree[1].val << endl;
	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second

inline ll left(ll node){ return node<<1 ;}
inline ll right(ll node){ return (node<<1)+1;}
ll a[400005];
struct data{
	ll val;
	ll dist;
};
data tree[4*400005];
void build_tree(ll node , ll start , ll end){
	if(start==end){
		tree[node].val = a[start];
		tree[node].dist = 0;
		return;
	}
	ll mid = (start+end)/2;

	build_tree(left(node),start,mid);
	build_tree(right(node),mid+1,end);
	if(tree[left(node)].dist==0){
		tree[node].val = tree[right(node)].val | tree[left(node)].val;
		tree[node].dist+=1;
	}
	else{
		tree[node].val = tree[right(node)].val ^ tree[left(node)].val;
		tree[node].dist=0;
	}
}
void update(ll node , ll start , ll end , ll ind , ll value){
	if(start > end)return;
	if(start==end && ind==start){
		a[ind]=value;
		tree[node].val = value;
		return;
	}
	ll mid = (start+end)/2;
	if(start <= ind && ind <= mid)
		update(left(node),start,mid,ind,value);
	else
		update(right(node),mid+1,end,ind,value);
	if(tree[left(node)].dist==0){
		tree[node].val = tree[right(node)].val | tree[left(node)].val;
		tree[node].dist+=1;
	}
	else{
		tree[node].val = tree[right(node)].val ^ tree[left(node)].val;
		tree[node].dist=0;
	}

}
int main(){

	ll n , m  , i , j , k , p , b;
	cin >> n >> m ;
	ll x = pow(2.0,n);
	for(i = 0 ; i < x ; i++){
		cin >> a[i];
	}
	build_tree(1,0,x-1);
	while(m--){
		cin >> p >> b;
		update(1,0,x-1,p-1,b);
		cout << tree[1].val << endl;
	}

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int Maxn = 1e6;
int n, maxD, arr[Maxn];
int segment[4*Maxn];

void builder(int segnum, int first, int last, int depth)
{
	if (first == last)
	{
		segment[segnum] = arr[first];
		return;
	}

	int mid = (first + last) / 2;
	change(segnum*2, first, mid, depth + 1, place, value);
	change(segnum*2 + 1, mid + 1, last, depth + 1, place, value);

	if ((maxD - depth) & 1)
		segment[segnum] = (segment[segnum*2] | segment[segnum*2 + 1]);
	else
		segment[segnum] = (segment[segnum*2] ^ segment[segnum*2 + 1]);
}

void change(int segnum, int first, int last, int depth, int place, int value)
{
	if (place < first || last < last)
		return;
	if (first == last)
	{
		if (first == place)
			segment[segnum] = value;
		return;
	}

	int mid = (first + last) / 2;
	change(segnum*2, first, mid, depth + 1, place, value);
	change(segnum*2 + 1, mid + 1, last, depth + 1, place, value);
	if ((maxD - depth) & 1)
		segment[segnum] = (segment[segnum*2] | segment[segnum*2 + 1]);
	else
		segment[segnum] = (segment[segnum*2] ^ segment[segnum*2 + 1]);
}

void debugOutput()
{
	for (int i = 1; i <= n; i <<= 1)
	{
		cout << string((n-i) / 2, ' ');
		for (int j = i; j <
			(i<<1); ++j)
			cout << segment[j] << ' ';
		cout << endl;
	}
}

int main()
{
	int m;
	scanf("%d%d", &n, &m);
	maxD = n;
	n = (1<<n);

	for (int i = 1; i <= n; ++i)
		scanf("%d", arr + i);
	builder(1,1,n,0);
	// debugOutput();

	for (int i = 0; i < m; ++i)
	{
		int place, val;
		scanf("%d%d", &place, &val);
		change(1, 1, n, 0, place, val);
		printf("%d\n", segment[1]);
	}

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int Maxn = 1e6;
int n, maxD, arr[Maxn];
int segment[4*Maxn];

void builder(int segnum, int first, int last, int depth)
{
	if (first == last)
	{
		segment[segnum] = arr[first];
		return;
	}

	int mid = (first + last) / 2;
	builder(segnum*2, first, mid, depth + 1);
	builder(segnum*2 + 1, mid + 1, last, depth + 1);

	if ((maxD - depth) & 1)
		segment[segnum] = (segment[segnum*2] | segment[segnum*2 + 1]);
	else
		segment[segnum] = (segment[segnum*2] ^ segment[segnum*2 + 1]);
}

void change(int segnum, int first, int last, int depth, int place, int value)
{
	if (place < first || last < last)
		return;
	if (first == last)
	{
		if (first == place)
			segment[segnum] = value;
		return;
	}

	int mid = (first + last) / 2;
	change(segnum*2, first, mid, depth + 1, place, value);
	change(segnum*2 + 1, mid + 1, last, depth + 1, place, value);
	if ((maxD - depth) & 1)
		segment[segnum] = (segment[segnum*2] | segment[segnum*2 + 1]);
	else
		segment[segnum] = (segment[segnum*2] ^ segment[segnum*2 + 1]);
}

void debugOutput()
{
	for (int i = 1; i <= n; i <<= 1)
	{
		cout << string((n-i) / 2, ' ');
		for (int j = i; j <
			(i<<1); ++j)
			cout << segment[j] << ' ';
		cout << endl;
	}
}

int main()
{
	int m;
	scanf("%d%d", &n, &m);
	maxD = n;
	n = (1<<n);

	for (int i = 1; i <= n; ++i)
		scanf("%d", arr + i);
	builder(1,1,n,0);
	// debugOutput();

	for (int i = 0; i < m; ++i)
	{
		int place, val;
		scanf("%d%d", &place, &val);
		change(1, 1, n, 0, place, val);
		printf("%d\n", segment[1]);
	}

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int Maxn = 1e6;
int n, maxD, arr[Maxn];
int segment[4*Maxn];
int place, val;

void builder(int segnum, int first, int last, bool isOr)
{
	if (first == last)
	{
		segment[segnum] = arr[first];
		return;
	}

	int mid = (first + last) / 2;
	builder(segnum*2, first, mid, !isOr);
	builder(segnum*2 + 1, mid + 1, last, !depth);

	if (isOr)
		segment[segnum] = (segment[segnum*2] | segment[segnum*2 + 1]);
	else
		segment[segnum] = (segment[segnum*2] ^ segment[segnum*2 + 1]);
}

void change(	int segnum, int first, int last, bool isOr)
{
	if (place < first || last < last)
		return;
	if (first == last)
	{
		if (first == place)
			segment[segnum] = value;
		return;
	}

	int mid = (first + last) / 2;
	change(segnum*2, first, mid, !isOr);
	change(segnum*2 + 1, mid + 1, last, !isOr);
	if ((maxD - depth) & 1)
		segment[segnum] = (segment[segnum*2] | segment[segnum*2 + 1]);
	else
		segment[segnum] = (segment[segnum*2] ^ segment[segnum*2 + 1]);
}

// void debugOutput()
// {
// 	for (int i = 1; i <= n; i <<= 1)
// 	{
// 		cout << string((n-i) / 2, ' ');
// 		for (int j = i; j <
// 			(i<<1); ++j)
// 			cout << segment[j] << ' ';
// 		cout << endl;
// 	}
// }

int main()
{
	int m;
	scanf("%d%d", &n, &m);
	maxD = n;
	n = (1<<n);

	for (int i = 1; i <= n; ++i)
		scanf("%d", arr + i);
	builder(1,1,n, n & 1);
	// debugOutput();

	for (int i = 0; i < m; ++i)
	{
		scanf("%d%d", &place, &val);
		change(1, 1, n, n & 1);
		printf("%d\n", segment[1]);
	}

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int Maxn = 1e6;
int n, maxD, arr[Maxn];
int segment[4*Maxn];

void builder(int segnum, int first, int last, int depth)
{
	if (first == last)
	{
		segment[segnum] = arr[first];
		return;
	}

	int mid = (first + last) / 2;
	builder(segnum*2, first, mid, depth + 1);
	builder(segnum*2 + 1, mid + 1, last, depth + 1);

	if ((maxD - depth) & 1)
		segment[segnum] = (segment[segnum*2] | segment[segnum*2 + 1]);
	else
		segment[segnum] = (segment[segnum*2] ^ segment[segnum*2 + 1]);
}

void change(int segnum, int first, int last, int depth, int place, int value)
{
	if (place < first || last < last)
		return;
	if (first == last)
	{
		if (first == place)
			segment[segnum] = value;
		return;
	}

	int mid = (first + last) / 2;
	change(segnum*2, first, mid, depth + 1, place, value);
	change(segnum*2 + 1, mid + 1, last, depth + 1, place, value);
	if ((maxD - depth) & 1)
		segment[segnum] = (segment[segnum*2] | segment[segnum*2 + 1]);
	else
		segment[segnum] = (segment[segnum*2] ^ segment[segnum*2 + 1]);
}

// void debugOutput()
// {
// 	for (int i = 1; i <= n; i <<= 1)
// 	{
// 		cout << string((n-i) / 2, ' ');
// 		for (int j = i; j <
// 			(i<<1); ++j)
// 			cout << segment[j] << ' ';
// 		cout << endl;
// 	}
// }

int main()
{
	int m;
	scanf("%d%d", &n, &m);
	maxD = n;
	n = (1<<n);

	for (int i = 1; i <= n; ++i)
		scanf("%d", arr + i);
	builder(1,1,n,0);
	// debugOutput();

	for (int i = 0; i < m; ++i)
	{
		int place, val;
		scanf("%d%d", &place, &val);
		change(1, 1, n, 0, place, val);
		printf("%d\n", segment[1]);
	}

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int Maxn = 1e6;
int n, maxD, arr[Maxn];
int segment[4*Maxn];
int place, val;

void builder(int segnum, int first, int last, bool isOr)
{
	if (first == last)
	{
		segment[segnum] = arr[first];
		return;
	}

	int mid = (first + last) / 2;
	builder(segnum*2, first, mid, !isOr);
	builder(segnum*2 + 1, mid + 1, last, !isOr);

	if (isOr)
		segment[segnum] = (segment[segnum*2] | segment[segnum*2 + 1]);
	else
		segment[segnum] = (segment[segnum*2] ^ segment[segnum*2 + 1]);
}

void change(int segnum, int first, int last, bool isOr)
{
	if (place < first || last < place)
		return;
	if (first == last)
	{
		if (first == place)
			segment[segnum] = val;
		return;
	}

	int mid = (first + last) / 2;
	change(segnum*2, first, mid, !isOr);
	change(segnum*2 + 1, mid + 1, last, !isOr);
	if (isOr)
		segment[segnum] = (segment[segnum*2] | segment[segnum*2 + 1]);
	else
		segment[segnum] = (segment[segnum*2] ^ segment[segnum*2 + 1]);
}

// void debugOutput()
// {
// 	for (int i = 1; i <= n; i <<= 1)
// 	{
// 		cout << string((n-i) / 2, ' ');
// 		for (int j = i; j <
// 			(i<<1); ++j)
// 			cout << segment[j] << ' ';
// 		cout << endl;
// 	}
// }

int main()
{
	int m;
	scanf("%d%d", &n, &m);
	maxD = n;
	n = (1<<n);

	for (int i = 1; i <= n; ++i)
		scanf("%d", arr + i);
	builder(1,1,n, maxD & 1);
	// debugOutput();

	for (int i = 0; i < m; ++i)
	{
		scanf("%d%d", &place, &val);
		change(1, 1, n, maxD & 1);
		printf("%d\n", segment[1]);
	}

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int Maxn = 1e6;
int n, maxD, arr[Maxn];
int segment[4*Maxn];
int place, val;

void builder(int segnum, int first, int last, bool isOr)
{
	if (first == last)
	{
		segment[segnum] = arr[first];
		return;
	}

	int mid = (first + last) / 2;
	builder(segnum*2, first, mid, !isOr);
	builder(segnum*2 + 1, mid + 1, last, !isOr);

	if (isOr)
		segment[segnum] = (segment[segnum*2] | segment[segnum*2 + 1]);
	else
		segment[segnum] = (segment[segnum*2] ^ segment[segnum*2 + 1]);
}

void change(int segnum, int first, int last, bool isOr)
{
	if (place < first || last < last)
		return;
	if (first == last)
	{
		if (first == place)
			segment[segnum] = value;
		return;
	}

	int mid = (first + last) / 2;
	change(segnum*2, first, mid, !isOr);
	change(segnum*2 + 1, mid + 1, last, !isOr);
	if ((maxD - depth) & 1)
		segment[segnum] = (segment[segnum*2] | segment[segnum*2 + 1]);
	else
		segment[segnum] = (segment[segnum*2] ^ segment[segnum*2 + 1]);
}

// void debugOutput()
// {
// 	for (int i = 1; i <= n; i <<= 1)
// 	{
// 		cout << string((n-i) / 2, ' ');
// 		for (int j = i; j <
// 			(i<<1); ++j)
// 			cout << segment[j] << ' ';
// 		cout << endl;
// 	}
// }

int main()
{
	int m;
	scanf("%d%d", &n, &m);
	maxD = n;
	n = (1<<n);

	for (int i = 1; i <= n; ++i)
		scanf("%d", arr + i);
	builder(1,1,n, maxD & 1);
	// debugOutput();
	cout << "feqfqef" << endl;

	for (int i = 0; i < m; ++i)
	{
		scanf("%d%d", &place, &val);
		change(1, 1, n, maxD & 1);
		printf("%d\n", segment[1]);
	}

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int Maxn = 1e6;
int n;
int segment[4*Maxn];

void change(int segnum, int first, int last, int depth, int place, int value)
{
	if (place < first || last < last)
		return;
	if (first == last)
	{
		if (first == place)
			segment[segnum] = value;
		return;
	}

	int mid = (first + last) / 2;
	change(segnum*2, first, mid, depth + 1, place, value);
	change(segnum*2 + 1, mid + 1, last, depth + 1, place, value);
	if ((n - depth) & 1)
		segment[segnum] = (segment[segnum*2] | segment[segnum*2 + 1]);
	else
		segment[segnum] = (segment[segnum*2] ^ segment[segnum*2 + 1]);
}

void debugOutput()
{
	for (int i = 1; i <= n; i <<= 1)
	{
		cout << string((n-i) / 2, ' ');
		for (int j = i; j <
			(i<<1); ++j)
			cout << segment[j] << ' ';
		cout << endl;
	}
}

int main()
{
	int m;
	scanf("%d%d", &n, &m);
	n = (1<<n);
	for (int i = 1; i <= n; ++i)
	{
		int tmp;
		scanf("%d", &tmp);
		change(1, 1, n, 0, i, tmp);
		// debugOutput();
	}

	for (int i = 0; i < m; ++i)
	{
		int place, val;
		scanf("%d%d", &place, &val);
		change(1, 1, n, 0, place, val);
		printf("%d\n", segment[1]);
	}

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int Maxn = 1e6;
int n, maxD, arr[Maxn];
int segment[4*Maxn];
int place, val;

void builder(int segnum, int first, int last, bool isOr)
{
	if (first == last)
	{
		segment[segnum] = arr[first];
		return;
	}

	int mid = (first + last) / 2;
	builder(segnum*2, first, mid, !isOr);
	builder(segnum*2 + 1, mid + 1, last, !isOr);

	if (isOr)
		segment[segnum] = (segment[segnum*2] | segment[segnum*2 + 1]);
	else
		segment[segnum] = (segment[segnum*2] ^ segment[segnum*2 + 1]);
}

void change(int segnum, int first, int last, bool isOr)
{
	if (place < first || last < last)
		return;
	if (first == last)
	{
		if (first == place)
			segment[segnum] = val;
		return;
	}

	int mid = (first + last) / 2;
	change(segnum*2, first, mid, !isOr);
	change(segnum*2 + 1, mid + 1, last, !isOr);
	if (isOr)
		segment[segnum] = (segment[segnum*2] | segment[segnum*2 + 1]);
	else
		segment[segnum] = (segment[segnum*2] ^ segment[segnum*2 + 1]);
}

// void debugOutput()
// {
// 	for (int i = 1; i <= n; i <<= 1)
// 	{
// 		cout << string((n-i) / 2, ' ');
// 		for (int j = i; j <
// 			(i<<1); ++j)
// 			cout << segment[j] << ' ';
// 		cout << endl;
// 	}
// }

int main()
{
	int m;
	scanf("%d%d", &n, &m);
	maxD = n;
	n = (1<<n);

	for (int i = 1; i <= n; ++i)
		scanf("%d", arr + i);
	builder(1,1,n, maxD & 1);
	// debugOutput();
	cout << "feqfqef" << endl;

	for (int i = 0; i < m; ++i)
	{
		scanf("%d%d", &place, &val);
		change(1, 1, n, maxD & 1);
		printf("%d\n", segment[1]);
	}

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int Maxn = 1e6;
int n, maxD, arr[Maxn];
int segment[4*Maxn];
int place, val;

void builder(int segnum, int first, int last, bool isOr)
{
	if (first == last)
	{
		segment[segnum] = arr[first];
		return;
	}

	int mid = (first + last) / 2;
	builder(segnum*2, first, mid, !isOr);
	builder(segnum*2 + 1, mid + 1, last, !isOr);

	if (isOr)
		segment[segnum] = (segment[segnum*2] | segment[segnum*2 + 1]);
	else
		segment[segnum] = (segment[segnum*2] ^ segment[segnum*2 + 1]);
}

void change(int segnum, int first, int last, bool isOr)
{
	if (place < first || last < last)
		return;
	if (first == last)
	{
		if (first == place)
			segment[segnum] = val;
		return;
	}

	int mid = (first + last) / 2;
	change(segnum*2, first, mid, !isOr);
	change(segnum*2 + 1, mid + 1, last, !isOr);
	if (isOr)
		segment[segnum] = (segment[segnum*2] | segment[segnum*2 + 1]);
	else
		segment[segnum] = (segment[segnum*2] ^ segment[segnum*2 + 1]);
}

// void debugOutput()
// {
// 	for (int i = 1; i <= n; i <<= 1)
// 	{
// 		cout << string((n-i) / 2, ' ');
// 		for (int j = i; j <
// 			(i<<1); ++j)
// 			cout << segment[j] << ' ';
// 		cout << endl;
// 	}
// }

int main()
{
	int m;
	scanf("%d%d", &n, &m);
	maxD = n;
	n = (1<<n);

	for (int i = 1; i <= n; ++i)
		scanf("%d", arr + i);
	builder(1,1,n, maxD & 1);
	// debugOutput();
	if(n==(1<<17))
		cout << "feqfqef" << endl;

	for (int i = 0; i < m; ++i)
	{
		scanf("%d%d", &place, &val);
		change(1, 1, n, maxD & 1);
		printf("%d\n", segment[1]);
	}

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int Maxn = 1e6;
int n, maxD;
int segment[4*Maxn];

void change(int segnum, int first, int last, int depth, int place, int value)
{
	if (place < first || last < last)
		return;
	if (first == last)
	{
		if (first == place)
			segment[segnum] = value;
		return;
	}

	int mid = (first + last) / 2;
	change(segnum*2, first, mid, depth + 1, place, value);
	change(segnum*2 + 1, mid + 1, last, depth + 1, place, value);
	if ((maxD - depth) & 1)
		segment[segnum] = (segment[segnum*2] | segment[segnum*2 + 1]);
	else
		segment[segnum] = (segment[segnum*2] ^ segment[segnum*2 + 1]);
}

void debugOutput()
{
	for (int i = 1; i <= n; i <<= 1)
	{
		cout << string((n-i) / 2, ' ');
		for (int j = i; j <
			(i<<1); ++j)
			cout << segment[j] << ' ';
		cout << endl;
	}
}

int main()
{
	int m;
	scanf("%d%d", &n, &m);
	maxD = n;
	n = (1<<n);
	for (int i = 1; i <= n; ++i)
	{
		int tmp;
		scanf("%d", &tmp);
		change(1, 1, n, 0, i, tmp);
		// debugOutput();
	}

	for (int i = 0; i < m; ++i)
	{
		int place, val;
		scanf("%d%d", &place, &val);
		change(1, 1, n, 0, place, val);
		printf("%d\n", segment[1]);
	}

	return 0;
}


#include <bits/stdc++.h>

#define mp make_pair

using namespace std;
using int64 = long long int;
const int MAXN = 1<<18;
int64 arr[MAXN];
int n,m;

pair<int64,bool> oper(pair<int64,bool> a, pair<int64,bool> b)
{
    if(!a.second)
    {
        return mp(a.first|b.first,true);
    }
    return mp(a.first^b.first,false);
}

struct stree{
    pair<int64,bool> st[4*MAXN];
    void built(int node = 1, int idx = 1, int idy = n)
    {
        if(idx == idy)
        {
            st[node] = mp(arr[idx],false);
            return;
        }
        int med = (idx+idy)/2;
        built(2*node,idx,med);
        built(2*node+1,med+1,idy);
        st[node] = oper(st[2*node],st[2*node+1]);
    }
    void update(int node, int idx, int idy,int pos, int64 val)
    {
        if(pos < idx || pos > idy)return;
        if(idx == idy)
        {
            st[node] = mp(val,false);
            return;
        }
        int med = (idx+idy)/2;
        update(2*node,idx,med,pos,val);
        update(2*node+1,med+1,idy,pos,val);
        st[node] = oper(st[2*node],st[2*node+1]);
    }
    pair<int64,bool> query(int node, int idx, int idy, int qx,int qy)
    {
        if(qy<idx||idy<qx)return mp(0,st[node].second);
        if(idx<=qx&&qy<=idy)return st[node];
        int med = (idx+idy)/2;
        return oper(query(2*node,idx,med,qx,qy),query(2*node+1,med+1,idy,qx,qy));
    }
}s;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    n = (1<<n);
    for(int i = 1; i<=n; i++)
        cin >> arr[i];
    s.built();
    while(m--)
    {
        int x; int64 y; cin >> x >> y;
        s.update(1,1,n,x,y);
        cout << s.query(1,1,n,1,n).first << endl;
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;
const int MAXN = 2e6;
long long int arr[MAXN+5];
int n,m;

pair<long long int,bool> oper(pair<long long int,bool> a, pair<long long int,bool> b)
{
    if(!a.second)
    {
        return make_pair(a.first|b.first,true);
    }
    return make_pair(a.first^b.first,false);
}

struct stree{
    pair<long long int,bool> a[MAXN+5];
    void built(int node = 1, int idx = 1, int idy = n)
    {
        if(idx == idy)
        {
            a[node] = make_pair(arr[idx],false);
            return;
        }
        int med = (idx+idy)/2;
        built(2*node,idx,med);
        built(2*node+1,med+1,idy);
        a[node] = oper(a[2*node],a[2*node+1]);
    }
    void update(int node, int idx, int idy,int pos, long long int val)
    {
        if(pos < idx || pos > idy)return;
        if(idx == idy)
        {
            a[node] = make_pair(val,false);
            return;
        }
        int med = (idx+idy)/2;
        update(2*node,idx,med,pos,val);
        update(2*node+1,med+1,idy,pos,val);
        a[node] = oper(a[2*node],a[2*node+1]);
    }
}s;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    n = (1<<n);
    for(int i = 1; i<=n; i++)
        cin >> arr[i];
    s.built();
    while(m--)
    {
        int x; long long int y; cin >> x >> y;
        s.update(1,1,n,x,y);
        cout << (s.a[1]).first << endl;
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;
const int MAXN = 1<<17;
long long int arr[MAXN+5];
int n,m;

pair<long long int,bool> oper(pair<long long int,bool> a, pair<long long int,bool> b)
{
    if(!a.second)
    {
        return make_pair(a.first|b.first,true);
    }
    return make_pair(a.first^b.first,false);
}

struct stree{
    pair<long long int,bool> a[5*MAXN];
    void built(int node = 1, int idx = 1, int idy = n)
    {
        if(idx == idy)
        {
            a[node] = make_pair(arr[idx],false);
            return;
        }
        int med = (idx+idy)/2;
        built(2*node,idx,med);
        built(2*node+1,med+1,idy);
        a[node] = oper(a[2*node],a[2*node+1]);
    }
    void update(int node, int idx, int idy,int pos, long long int val)
    {
        if(pos < idx || pos > idy)return;
        if(idx == idy)
        {
            a[node] = make_pair(val,false);
            return;
        }
        int med = (idx+idy)/2;
        update(2*node,idx,med,pos,val);
        update(2*node+1,med+1,idy,pos,val);
        a[node] = oper(a[2*node],a[2*node+1]);
    }
}s;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    n = (1<<n);
    for(int i = 1; i<=n; i++)
        cin >> arr[i];
    s.built();
    while(m--)
    {
        int x; long long int y; cin >> x >> y;
        s.update(1,1,n,x,y);
        cout << (s.a[1]).first << endl;
    }

    return 0;
}


#include <bits/stdc++.h>
#define mp make_pair

using namespace std;
typedef long long int int64;
const int MAXN = 1<<17;
int64 arr[MAXN+5];
int n,m;

pair<int64,bool> oper(pair<int64,bool> a, pair<int64,bool> b)
{
    if(!a.second)
    {
        return mp(a.first|b.first,true);
    }
    return mp(a.first^b.first,false);
}

struct stree{
    pair<int64,bool> a[5*MAXN];
    void built(int node = 1, int idx = 1, int idy = n)
    {
        if(idx == idy)
        {
            a[node] = mp(arr[idx],false);
            return;
        }
        int med = (idx+idy)/2;
        built(2*node,idx,med);
        built(2*node+1,med+1,idy);
        a[node] = oper(a[2*node],a[2*node+1]);
    }
    void update(int node, int idx, int idy,int pos, int64 val)
    {
        if(pos < idx || pos > idy)return;
        if(idx == idy)
        {
            a[node] = mp(val,false);
            return;
        }
        int med = (idx+idy)/2;
        update(2*node,idx,med,pos,val);
        update(2*node+1,med+1,idy,pos,val);
        a[node] = oper(a[2*node],a[2*node+1]);
    }
}s;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    n = (1<<n);
    for(int i = 1; i<=n; i++)
        cin >> arr[i];
    s.built();
    while(m--)
    {
        int x; int64 y; cin >> x >> y;
        s.update(1,1,n,x,y);
        cout << s.a[1].first << endl;
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;
long long int arr[1<<18];
int n,m;

pair<long long int,bool> oper(pair<long long int,bool> a, pair<long long int,bool> b)
{
    if(!a.second)
    {
        return make_pair(a.first|b.first,true);
    }
    return make_pair(a.first^b.first,false);
}

struct stree{
    pair<long long int,bool> a[1<<18];
    void built(int node = 1, int idx = 1, int idy = n)
    {
        if(idx == idy)
        {
            a[node] = make_pair(arr[idx],false);
            return;
        }
        int med = (idx+idy)/2;
        built(2*node,idx,med);
        built(2*node+1,med+1,idy);
        a[node] = oper(a[2*node],a[2*node+1]);
    }
    void update(int node, int idx, int idy,int pos, long long int val)
    {
        if(idx == idy)
        {
            a[node] = make_pair(val,false);
            return;
        }
        int med = (idx+idy)/2;
        if(pos <= med)
            update(2*node,idx,med,pos,val);
        else
            update(2*node+1,med+1,idy,pos,val);
        a[node] = oper(a[2*node],a[2*node+1]);
    }
}s;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    n = (1<<n);
    for(int i = 1; i<=n; i++)
        cin >> arr[i];
    s.built();
    while(m--)
    {
        int x; long long int y; cin >> x >> y;
        s.update(1,1,n,x,y);
        cout << (s.a[1]).first << endl;
    }

    return 0;
}


#include <bits/stdc++.h>

#define mp make_pair

using namespace std;
using int64 = long long int;
const int MAXN = 1<<18;
int64 arr[MAXN];
int n,m;

pair<int64,bool> oper(pair<int64,bool> a, pair<int64,bool> b)
{
    if(!a.second)
    {
        return mp(a.first|b.first,true);
    }
    return mp(a.first^b.first,false);
}

struct stree{
    pair<int64,bool> st[5*MAXN];
    void built(int node = 1, int idx = 1, int idy = n)
    {
        if(idx == idy)
        {
            st[node] = mp(arr[idx],false);
            return;
        }
        int med = (idx+idy)/2;
        built(2*node,idx,med);
        built(2*node+1,med+1,idy);
        st[node] = oper(st[2*node],st[2*node+1]);
    }
    void update(int node, int idx, int idy,int pos, int64 val)
    {
        if(pos < idx || pos > idy)return;
        if(idx == idy)
        {
            st[node] = mp(val,false);
            return;
        }
        int med = (idx+idy)/2;
        update(2*node,idx,med,pos,val);
        update(2*node+1,med+1,idy,pos,val);
        st[node] = oper(st[2*node],st[2*node+1]);
    }
    pair<int64,bool> query(int node, int idx, int idy, int qx,int qy)
    {
        if(qy<idx||idy<qx)return mp(0,st[node].second);
        if(idx<=qx&&qy<=idy)return st[node];
        int med = (idx+idy)/2;
        return oper(query(2*node,idx,med,qx,qy),query(2*node+1,med+1,idy,qx,qy));
    }
}st;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    n = (1<<n);
    for(int i = 1; i<=n; i++)
        cin >> arr[i];
    st.built();
    while(m--)
    {
        int x; int64 y; cin >> x >> y;
        st.update(1,1,n,x,y);
        cout << st.query(1,1,n,1,n).first << endl;
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;
long long int arr[1<<18];
int n,m;

long long int oper(long long int a, long long int b,int tam)
{
    if(tam%2)
        return a|b;
    return a^b;
}

struct stree{
    long long int a[1<<18];
    void built(int node = 1, int idx = 1, int idy = (1<<n),int tam = n)
    {
        if(idx == idy)
        {
            a[node] = arr[idx];
            return;
        }
        int med = (idx+idy)/2;
        built(2*node,idx,med,tam-1);
        built(2*node+1,med+1,idy,tam-1);
        a[node] = oper(a[2*node],a[2*node+1],tam);
    }
    void update(int node, int idx, int idy,int pos, long long int val, int tam)
    {
        if(idx == idy)
        {
            a[node] = val;
            return;
        }
        int med = (idx+idy)/2;
        if(pos <= med)
            update(2*node,idx,med,pos,val,tam-1);
        else
            update(2*node+1,med+1,idy,pos,val,tam-1);
        a[node] = oper(a[2*node],a[2*node+1],tam);
    }
}s;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    for(int i = 1; i<=(1<<n); i++)
        cin >> arr[i];
    s.built();
    while(m--)
    {
        int x; long long int y; cin >> x >> y;
        s.update(1,1,1<<n,x,y,n);
        cout << s.a[1] << endl;
    }

    return 0;
}


//Norma Elizabeth Morales Cruz
//A01195888

#include <iostream>
#include <stdio.h>
#include <deque>
#include <algorithm>

using namespace std;
int segmentTree[3000000];

void builTree(long long int n){
	bool flag = true;
	for (long long int i = n-1; i >0 ; i--)
	{
		if (i%2 != 0)
		{
			segmentTree[i] = segmentTree[i << 1] | segmentTree[i << 1 | 1];
		}
		else{
			segmentTree[i] = segmentTree[i << 1] ^ segmentTree[i << 1 | 1];
		}
	}

}

void modificar(long long int n, long long int x){
	segmentTree[n] = x;
	bool par= true;
	while(n >>= 1){
		if (par)
		{
			segmentTree[n] = segmentTree[n << 1] | segmentTree[n << 1 | 1];
		}
		else{
			segmentTree[n] = segmentTree[n << 1] ^ segmentTree[n << 1 | 1];
		}
		par = !par;
	}

}

int main(){
	long long int n, m;
	long long int p, b;
	cin >> n >> m;
	n = 1 << n;
	for (long long int i = 0; i < n; i++)
	{
		cin >> segmentTree[n+i];
	}
	builTree(n);

	for (long long int i = 0; i < m; i++)
	{
		cin >> p >> b;
		p--;
		modificar(p+n, b);
		cout << segmentTree[1]<<endl;
	}

	return 0;
}


//Norma Elizabeth Morales Cruz
//A01195888

#include <iostream>
#include <stdio.h>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <algorithm>

using namespace std;
long long int segmentTree[3000000], siz;

void builTree(long long int n){
	bool flag = true;
	for (long long int i = n-1; i >0 ; i--)
	{
		if (flag)
		{
			segmentTree[i] = segmentTree[i << 1] | segmentTree[i << 1 | 1];
		}
		else{
			segmentTree[i] = segmentTree[i << 1] ^ segmentTree[i << 1 | 1];
		}
		if((i &(i-1)) != 0){
			flag = !flag;
		}

	}

}

void modificar(long long int n, long long int x){
	segmentTree[n] = x;
	bool par= true;
	while(n >>= 1){
		if (par)
		{
			segmentTree[n] = segmentTree[n << 1] | segmentTree[n << 1 | 1];
		}
		else{
			segmentTree[n] = segmentTree[n << 1] ^ segmentTree[n << 1 | 1];
		}
		par = !par;
	}

}

int main(){
	long long int n, m;
	long long int p, b;
	cin >> n >> m;
	n = 1 << n;
	//memset(segmentTree, 0 , sizeof(segmentTree));

	for (long long int i = 0; i < n; i++)
	{
		cin >> segmentTree[n+i];
	}
	builTree(n);
	for (long long int i = 0; i < m; i++)
	{
		cin >> p >> b;
		p--;
		modificar(p+n, b);
		cout << segmentTree[1]<<endl;
	}

	return 0;
}


//Norma Elizabeth Morales Cruz
//A01195888

#include <iostream>
#include <stdio.h>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <algorithm>

using namespace std;
long long int segmentTree[3000000];

void builTree(long long int n){
	bool flag = true;
	for (long long int i = n-1; i >0 ; i--)
	{
		if (flag)
		{
			segmentTree[i] = segmentTree[i << 1] | segmentTree[i << 1 | 1];
		}
		else{
			segmentTree[i] = segmentTree[i << 1] ^ segmentTree[i << 1 | 1];
		}
		if ((i%2!=0) && ((i-1)%2==0))
		 {
		 	flag = !flag;
		 }
	}

}

void modificar(long long int n, long long int x){
	segmentTree[n] = x;
	bool par= true;
	while(n >>= 1){
		if (par)
		{
			segmentTree[n] = segmentTree[n << 1] | segmentTree[n << 1 | 1];
		}
		else{
			segmentTree[n] = segmentTree[n << 1] ^ segmentTree[n << 1 | 1];
		}
		par = !par;
	}

}

int main(){
	long long int n, m;
	long long int p, b;
	cin >> n >> m;
	n = 1 << n;
	memset(segmentTree, 0 , sizeof(segmentTree));

	for (long long int i = 0; i < n; i++)
	{
		cin >> segmentTree[n+i];
	}
	builTree(n);

	for (long long int i = 0; i < m; i++)
	{
		cin >> p >> b;
		p--;
		modificar(p+n, b);
		cout << segmentTree[1]<<endl;
	}

	return 0;
}


//Norma Elizabeth Morales Cruz
//A01195888

#include <iostream>
#include <stdio.h>
#include <deque>
#include <algorithm>

using namespace std;
long long int segmentTree[3000000];

void builTree(long long int n){
	bool flag = true;
	int cont = 0;
	for (long long int i = n-1; i >0 ; i--)
	{
		if (flag)
		{
			segmentTree[i] = segmentTree[i << 1] | segmentTree[i << 1 | 1];
		}
		else{
			segmentTree[i] = segmentTree[i << 1] ^ segmentTree[i << 1 | 1];
		}
		if (cont & 1)
		{
		 	flag = !flag;
		}
		cont++;
	}

}

void modificar(long long int n, long long int x){
	segmentTree[n] = x;
	bool par= true;
	while(n >>= 1){
		if (par)
		{
			segmentTree[n] = segmentTree[n << 1] | segmentTree[n << 1 | 1];
		}
		else{
			segmentTree[n] = segmentTree[n << 1] ^ segmentTree[n << 1 | 1];
		}
		par = !par;
	}

}

int main(){
	long long int n, m;
	long long int p, b;
	cin >> n >> m;
	n = 1 << n;
	for (long long int i = 0; i < n; i++)
	{
		segmentTree[n+i] = 0;
	}

	for (long long int i = 0; i < n; i++)
	{
		cin >> segmentTree[n+i];
	}
	builTree(n);

	for (long long int i = 0; i < m; i++)
	{
		cin >> p >> b;
		p--;
		modificar(p+n, b);
		cout << segmentTree[1]<<endl;
	}

	return 0;
}


/*
                            In the name of Almighty ALLAH

   code from :::::::::::::::::::::
   ******************************* R E S H A D ********************************

    FREE PALESTINE           FREE PALESTINE            FREE PALESTINE           FREE PALESTINE

                 FREE PALESTINE           FREE PALESTINE            FREE PALESTINE

    FREE PALESTINE           FREE PALESTINE            FREE PALESTINE           FREE PALESTINE

                 FREE PALESTINE           FREE PALESTINE            FREE PALESTINE

    FREE PALESTINE           FREE PALESTINE            FREE PALESTINE           FREE PALESTINE

*/

#include <bits/stdc++.h>

#define ll               long long
#define db               double
#define Pi               2*acos(0.0)
#define pb(a)            push_back(a)
#define VI               vector <int>
#define FASTIO           ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ull              unsigned long long
#define all(a)           a.begin(),a.end()
#define loop(i,n)        for(int i=0;i<n;i++)
#define loop1(i,n)       for(int i=1;i<=n;i++)
#define TEST_CASE(t)     for(int z=1;z<=t;z++)
// 90 degree = acos(x)*180/acos(0.0)

using namespace std;

int main() {

    FASTIO;

    ll t;
    cin >> t;
    while(t--){

        ll x1, y1, z1, x2, y2, z2, ans=0, z=0;
        cin >> x1 >> y1 >> z1;
        cin >> x2 >> y2 >> z2;

        ans += (min(z1, y2)*2);

        y2 -= min(z1, y2);
        z1 -= min(z1, y2);

        ans -= 2 * max(0, y1 + z2 - (x1 + y1 + z1));
        cout << ans << endl;
    }

	return 0;
}


/*
                            In the name of Almighty ALLAH

   code from :::::::::::::::::::::
   ******************************* R E S H A D ********************************

    FREE PALESTINE           FREE PALESTINE            FREE PALESTINE           FREE PALESTINE

                 FREE PALESTINE           FREE PALESTINE            FREE PALESTINE

    FREE PALESTINE           FREE PALESTINE            FREE PALESTINE           FREE PALESTINE

                 FREE PALESTINE           FREE PALESTINE            FREE PALESTINE

    FREE PALESTINE           FREE PALESTINE            FREE PALESTINE           FREE PALESTINE

*/

#include <bits/stdc++.h>

#define ll               long long
#define db               double
#define Pi               2*acos(0.0)
#define pb(a)            push_back(a)
#define VI               vector <int>
#define FASTIO           ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ull              unsigned long long
#define all(a)           a.begin(),a.end()
#define loop(i,n)        for(int i=0;i<n;i++)
#define loop1(i,n)       for(int i=1;i<=n;i++)
#define TEST_CASE(t)     for(int z=1;z<=t;z++)
// 90 degree = acos(x)*180/acos(0.0)

using namespace std;

int main() {

    FASTIO;

    ll t;
    cin >> t;
    while(t--){

        ll x1, y1, z1, x2, y2, z2, ans=0, z=0;
        cin >> x1 >> y1 >> z1;
        cin >> x2 >> y2 >> z2;

        ll a = min(z1, y2);
        ans += 2 * a;

        y2 -= a;
        z1 -= a;

        ans -= 2 * max(z, y1 + z2 - (x1 + y1 + z1));
        cout << ans << endl;
    }

	return 0;
}


/*
                            In the name of Almighty ALLAH

   code from :::::::::::::::::::::
   ******************************* R E S H A D ********************************

    FREE PALESTINE           FREE PALESTINE            FREE PALESTINE           FREE PALESTINE

                 FREE PALESTINE           FREE PALESTINE            FREE PALESTINE

    FREE PALESTINE           FREE PALESTINE            FREE PALESTINE           FREE PALESTINE

                 FREE PALESTINE           FREE PALESTINE            FREE PALESTINE

    FREE PALESTINE           FREE PALESTINE            FREE PALESTINE           FREE PALESTINE

*/

#include <bits/stdc++.h>

#define ll               long long
#define db               double
#define Pi               2*acos(0.0)
#define pb(a)            push_back(a)
#define VI               vector <int>
#define FASTIO           ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ull              unsigned long long
#define all(a)           a.begin(),a.end()
#define loop(i,n)        for(int i=0;i<n;i++)
#define loop1(i,n)       for(int i=1;i<=n;i++)
#define TEST_CASE(t)     for(int z=1;z<=t;z++)
// 90 degree = acos(x)*180/acos(0.0)

using namespace std;

int main() {

    FASTIO;

    ll t;
    cin >> t;
    while(t--){

        ll x1, y1, z1, x2, y2, z2, ans=0;
        cin >> x1 >> y1 >> z1;
        cin >> x2 >> y2 >> z2;

        ans += (min(z1, y2)*2);

        y2 -= min(z1, y2);
        z1 -= min(z1, y2);

        if(x1+z1>=z2) cout << ans << endl;
        else{
            z2 -= x1;
            z2 -= z1;
            ans -= (min(z2, y1)*2);
            cout << ans << endl;
        }

    }

	return 0;
}


/*
                            In the name of Almighty ALLAH

   code from :::::::::::::::::::::
   ******************************* R E S H A D ********************************

    FREE PALESTINE           FREE PALESTINE            FREE PALESTINE           FREE PALESTINE

                 FREE PALESTINE           FREE PALESTINE            FREE PALESTINE

    FREE PALESTINE           FREE PALESTINE            FREE PALESTINE           FREE PALESTINE

                 FREE PALESTINE           FREE PALESTINE            FREE PALESTINE

    FREE PALESTINE           FREE PALESTINE            FREE PALESTINE           FREE PALESTINE

*/

#include <bits/stdc++.h>

#define ll               long long
#define db               double
#define Pi               2*acos(0.0)
#define pb(a)            push_back(a)
#define VI               vector <int>
#define FASTIO           ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ull              unsigned long long
#define all(a)           a.begin(),a.end()
#define loop(i,n)        for(int i=0;i<n;i++)
#define loop1(i,n)       for(int i=1;i<=n;i++)
#define TEST_CASE(t)     for(int z=1;z<=t;z++)
// 90 degree = acos(x)*180/acos(0.0)

using namespace std;

int main() {

    FASTIO;

    ll t;
    cin >> t;
    while(t--){

        ll x1, y1, z1, x2, y2, z2, ans=0;
        cin >> x1 >> y1 >> z1;
        cin >> x2 >> y2 >> z2;

        ans += (min(z1, y2)*2);

        y2 -= min(z1, y2);
        z1 -= min(z1, y2);

        if(x1+z1>z2) cout << ans << endl;
        else{
            if(ans>0) ans -= (min(z2, y1)*2);
            cout << ans << endl;
        }

    }

	return 0;
}


/*
                            In the name of Almighty ALLAH

   code from :::::::::::::::::::::
   ******************************* R E S H A D ********************************

    FREE PALESTINE           FREE PALESTINE            FREE PALESTINE           FREE PALESTINE

                 FREE PALESTINE           FREE PALESTINE            FREE PALESTINE

    FREE PALESTINE           FREE PALESTINE            FREE PALESTINE           FREE PALESTINE

                 FREE PALESTINE           FREE PALESTINE            FREE PALESTINE

    FREE PALESTINE           FREE PALESTINE            FREE PALESTINE           FREE PALESTINE

*/

#include <bits/stdc++.h>

#define ll               long long
#define db               double
#define Pi               2*acos(0.0)
#define pb(a)            push_back(a)
#define VI               vector <int>
#define FASTIO           ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ull              unsigned long long
#define all(a)           a.begin(),a.end()
#define loop(i,n)        for(int i=0;i<n;i++)
#define loop1(i,n)       for(int i=1;i<=n;i++)
#define TEST_CASE(t)     for(int z=1;z<=t;z++)
// 90 degree = acos(x)*180/acos(0.0)

using namespace std;

int main() {

    FASTIO;

    ll t;
    cin >> t;
    while(t--){
        ll x1, y1, z1, x2, y2, z2, ans=0;
        cin >> x1 >> y1 >> z1;
        cin >> x2 >> y2 >> z2;

        ans += (min(z1, y2)*2);

        y2 -= min(z1, y2);
        z1 -= min(z1, y2);

        if(x1+z1>z2) cout << ans << endl;
        else{
            ans -= (min(z2, y1)*2);
            cout << ans << endl;
        }

    }

	return 0;
}


/*
                            In the name of Almighty ALLAH

   code from :::::::::::::::::::::
   ******************************* R E S H A D ********************************

    FREE PALESTINE           FREE PALESTINE            FREE PALESTINE           FREE PALESTINE

                 FREE PALESTINE           FREE PALESTINE            FREE PALESTINE

    FREE PALESTINE           FREE PALESTINE            FREE PALESTINE           FREE PALESTINE

                 FREE PALESTINE           FREE PALESTINE            FREE PALESTINE

    FREE PALESTINE           FREE PALESTINE            FREE PALESTINE           FREE PALESTINE

*/

#include <bits/stdc++.h>

#define ll               long long
#define db               double
#define Pi               2*acos(0.0)
#define pb(a)            push_back(a)
#define VI               vector <int>
#define FASTIO           ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ull              unsigned long long
#define all(a)           a.begin(),a.end()
#define loop(i,n)        for(int i=0;i<n;i++)
#define loop1(i,n)       for(int i=1;i<=n;i++)
#define TEST_CASE(t)     for(int z=1;z<=t;z++)
// 90 degree = acos(x)*180/acos(0.0)

using namespace std;

int main() {

    FASTIO;

    ll t;
    cin >> t;
    while(t--){

        ll x1, y1, z1, x2, y2, z2, ans=0, z=0;
        cin >> x1 >> y1 >> z1;
        cin >> x2 >> y2 >> z2;

        ans += (min(z1, y2)*2);

        y2 -= min(z1, y2);
        z1 -= min(z1, y2);

        ans -= 2*max(z, (z2-x1-z1));

        cout << ans << endl;
    }

	return 0;
}


/*
                            In the name of Almighty ALLAH

   code from :::::::::::::::::::::
   ******************************* R E S H A D ********************************

    FREE PALESTINE           FREE PALESTINE            FREE PALESTINE           FREE PALESTINE

                 FREE PALESTINE           FREE PALESTINE            FREE PALESTINE

    FREE PALESTINE           FREE PALESTINE            FREE PALESTINE           FREE PALESTINE

                 FREE PALESTINE           FREE PALESTINE            FREE PALESTINE

    FREE PALESTINE           FREE PALESTINE            FREE PALESTINE           FREE PALESTINE

*/

#include <bits/stdc++.h>

#define ll               long long
#define db               double
#define Pi               2*acos(0.0)
#define pb(a)            push_back(a)
#define VI               vector <int>
#define FASTIO           ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ull              unsigned long long
#define all(a)           a.begin(),a.end()
#define loop(i,n)        for(int i=0;i<n;i++)
#define loop1(i,n)       for(int i=1;i<=n;i++)
#define TEST_CASE(t)     for(int z=1;z<=t;z++)
// 90 degree = acos(x)*180/acos(0.0)

using namespace std;

int main() {

    FASTIO;

    ll t;
    cin >> t;
    while(t--){

        ll x1, y1, z1, x2, y2, z2, ans=0;
        cin >> x1 >> y1 >> z1;
        cin >> x2 >> y2 >> z2;

        ans += (min(z1, y2)*2);

        y2 -= min(z1, y2);
        z1 -= min(z1, y2);

        if(x1+z1>=z2) cout << ans << endl;
        else{
            if(ans>0) ans -= (min(z2, y1)*2);
            cout << ans << endl;
        }

    }

	return 0;
}


/*
                            In the name of Almighty ALLAH

   code from :::::::::::::::::::::
   ******************************* R E S H A D ********************************

    FREE PALESTINE           FREE PALESTINE            FREE PALESTINE           FREE PALESTINE

                 FREE PALESTINE           FREE PALESTINE            FREE PALESTINE

    FREE PALESTINE           FREE PALESTINE            FREE PALESTINE           FREE PALESTINE

                 FREE PALESTINE           FREE PALESTINE            FREE PALESTINE

    FREE PALESTINE           FREE PALESTINE            FREE PALESTINE           FREE PALESTINE

*/

#include <bits/stdc++.h>

#define ll               long long
#define db               double
#define Pi               2*acos(0.0)
#define pb(a)            push_back(a)
#define VI               vector <int>
#define FASTIO           ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ull              unsigned long long
#define all(a)           a.begin(),a.end()
#define loop(i,n)        for(int i=0;i<n;i++)
#define loop1(i,n)       for(int i=1;i<=n;i++)
#define TEST_CASE(t)     for(int z=1;z<=t;z++)
// 90 degree = acos(x)*180/acos(0.0)

using namespace std;

int main() {

    FASTIO;

    ll t;
    cin >> t;
    while(t--){

        ll x1, y1, z1, x2, y2, z2, ans=0;
        cin >> x1 >> y1 >> z1;
        cin >> x2 >> y2 >> z2;

        ll a = min(z1, y2);
        ans += 2 * a;

        y2 -= a;
        z1 -= a;

        if(x1+z1>=z2) cout << ans << endl;
        else{
            z2 -= x1;
            z2 -= z1;
            ans -= (min(z2, y1)*2);
            cout << ans << endl;
        }
    }

	return 0;
}