#include <cstdio>
#include <cstring>

using namespace std;

#define rei register int
#define rep(i, l, r) for(rei i = l, i##end = r; i <= i##end; ++i)
#define per(i, r, l) for(rei i = r, i##end = l; i >= i##end; --i)
inline void chmax(int &x, const int y) { if(x < y) x = y; }
const int N = 105;
inline int read() {
	int res = 0; char ch = getchar(); bool f = true;
	for(; ch < '0' || ch > '9'; ch = getchar())
		if(ch == '-') f = false;
	for(; ch >= '0' && ch <= '9'; ch = getchar())
		res = res * 10 + (ch ^ 48);
	return f ? res : -res;
}
int n, m, ans, sum, k, a[N], b[N], c[N][2];
bool buc[N];

signed main() {
	n = read(); m = read();
	rep(i, 1, m) a[i] = read(), b[i] = read();
	k = read();
	rep(i, 1, k) c[i][0] = read(), c[i][1] = read(); 
	rep(s, 0, (1 << k) - 1) {
		sum = 0;
		memset(buc, 0, sizeof(buc));
		rep(i, 1, k) buc[c[i][(s >> i - 1) & 1]] = 1;
		rep(i, 1, m) if(buc[a[i]] && buc[b[i]]) sum ++;
		chmax(ans, sum);
	}
	printf("%d\n", ans);
	return 0;
}
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
using namespace std;
using namespace __gnu_pbds; 

#define pb          push_back
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define endl        "\n"
#define fast        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int         long long int
#define mod         1000000007
#define MAXN        1000005

typedef tree<int, null_type, 
     less_equal<int>, rb_tree_tag,
          tree_order_statistics_node_update> 
    Ordered_set; 
// s.find_by_order(idx) find using index..!
// s.order_of_key(val) Gives iterator to the key..! 

/* First solve then try Writing Code.. And be cool ^_^ and calm. */

int n, q, a[MAXN], BIT[MAXN];

void update(int idx, int val)
{
    while(idx <= n)
    {
        BIT[idx] ^= val;
        idx += (idx&(-idx)); 
    }
}

int getAns(int idx)
{
    int ans = 0;
    while(idx > 0)
    {
        ans ^= BIT[idx];
        idx -= (idx & (-idx));
    }
    return ans;
}

void solve(){

    cin>>n>>q;
    for(int i=1;i<=n;i++)
        cin>>a[i];

    for(int i=1;i<=n;i++)
    {
        update(i, a[i]);
    }

    while(q--)
    {
        int ch;cin>>ch;
        if(ch == 1)
        {
            int l,r;cin>>l>>r;
            update(l, r);
        }
        else
        {
            int l, r; cin>>l>>r;
            cout<<(getAns(r)^getAns(l-1))<<endl;
        }
    }
}

// 12 - 12 + 11 c 
int32_t main()
{   
    fast; 
    int t=1;
    // cin>>t;
    while(t--) solve();
    
    return 0;
}
