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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define pb                    push_back
#define ll                    long long
#define ld                    long double
#define sz(x)                 (ll)x.size()
#define vll                   vector<long long>

#define infi                  INT_MAX
#define infl                  LONG_LONG_MAX
#define infd                  LDBL_MAX
#define f(i,a,b)              for(ll i=a;i<b;i++)
#define fi(i,a,b)             for(ll i=(b-1);i>=a;i--)
#define F                     first
#define S                     second
#define G(a,b)                get<a>(b)
#define MP                    make_pair
#define MT                    make_tuple
#define pll                   pair<ll,ll>
#define endl                  "\n"
#define ALL(v)                v.begin(),v.end()
#define nl                    cout<<"\n";
#define pr(x)                 cout<<x;
#define pr1(x)                cout<<x<<" ";
#define pr2(x,y)              cout<<x<<" "<<y;
#define pr3(x,y,z)            cout<<x<<" "<<y<<" "<<z;
#define pr4(x,y,z,w)          cout<<x<<" "<<y<<" "<<z<<" "<<w;
#define deb                   cout<<"***************************************************************************************\n";
#define moshi                 cout<<"moshi moshi ! \n";
#define hi                    cout<<"hi ! \n";
#define bye                   cout<<"bye bye ! \n";
#define kawai                 cout<<"O kawai koto ! \n";
#define o_set                 tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define number_of_set_bits  __builtin_popcountll
#define eb                    emplace_back
const ld PI=3.1415926535897932384626433;


auto clk=clock();
mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 <<"\n";
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

//**********************************************************  Code begins  ***********************************************

const ll N=2e5+5;
ll n,m,a[N],dp[N];
vll adj[N];


void solve()
{
  cin>>n>>m;
  f(i,1,n+1) cin>>a[i];
  f(i,1,m+1)
  {
    ll x,y;
    cin>>x>>y;
    adj[x].pb(y);
  }

  ll ans=-infl;
  fi(i,1,n+1)
  {
    dp[i]=-infl;
    for(auto &j:adj[i])
    {
        dp[i]=max(dp[i],max(a[j],dp[j]));
    }

    if(dp[i]!=-infl)  ans=max(ans,dp[i]-a[i]);
  }
  if(ans!=-infl) cout<<ans<<"\n";
  else cout<<"0\n";
}


int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    cout<<fixed<<setprecision(8);

    ll test_cases=1;
    //cin>>test_cases;

    f(i,1,test_cases+1)
    {
        solve();
        //clr();
    }


    #ifdef rd
    cout<<endl<<endl<<endl<<endl<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
    #endif

    return 0;
}


// #pragma GCC optimise ("O1")
#include<bits/stdc++.h>
using namespace std;
#define ll           long long
#define rep(i,j,n)   for(ll i=j;i<n;i++)
#define _rep(i,n)   for(ll i=n-1;i>=1;i--)
#define scn(a)       scanf("%lld",&a)
#define scns(a,b)    scanf("%lld %lld",&a,&b)
#define print(a)     printf("%lld",a)
#define vec          vector<ll>
#define pb           push_back    
#define pairs        pair<ll,ll>
#define f            first
#define s            second
#define all(v)       v.begin(),v.end()
#define srt(v)       sort(v.begin(),v.end())
#define read(a)       for(auto &it:a) cin>>it;
#define write(a)      for(auto it:a) cout<<it<<" ";
#define yeS(GOOD)      GOOD ? cout<<"YES\n" : cout<<"NO\n"
#define mem(a,b)     memset(a,b,sizeof(a))
#define nl           printf("\n")
#define inf          1e9
#define zer          INT_MIN
#define fast         ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll N=3e5+5;
int n,a[N];

int tree[4*N];

void build(int st,int se,int node)
{
    if(st==se)
    {
        tree[node] = a[st];

        return;
    }

    int mid=(st+se)/2;

    build(st,mid,2*node);
    build(mid+1,se,2*node+1);

    tree[node] = tree[2*node]^tree[2*node+1];
}

void update(int st,int se,int ind,int val,int node)
{
    if(st == se)
    {
        tree[node]^= val; 
		a[ind]^= val; 
        
        return;
    }
    
    int mid = st+(se-st)/2;
    
    if(ind <= mid)
    update(st,mid,ind,val,2*node);
    else
    update(mid+1,se,ind,val,2*node+1);
    
    tree[node] = tree[2*node]^tree[2*node+1];
}

int get(int st,int se,int qs,int qe,int node)
{
    if(st>qe || se<qs)
    return 0;

    if(st>=qs && se<=qe)
    return tree[node];

    int mid=(st+se)/2;

    return get(st,mid,qs,qe,2*node)^get(mid+1,se,qs,qe,2*node+1);
}


void f()
{
	// saafsafai();
	ll q;
	cin>>n>>q;

  	rep(i,0,n)
	cin>>a[i];


	build(0,n-1,1);

    ll ans=0;

    while(q--)
    {
        int type,x,y; cin>>type>>x>>y;

        if(type == 1)
        {
            update(0,n-1,x-1,y,1);
        }
        else
        {
            int ans = get(0,n-1,x-1,y-1,1);

            cout<<ans<<endl;
        }
    }
   	
   	// cout<<solve(1,n);
}
 
int main()
{
	  int queries=1; 
	  // cin>>queries;
	  while(queries--)
	  {
	    f();
	  }
}