#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n, c, T, m, q, a[N], b[N], head[N], ecnt, ans;
bool vis[N];
struct Edge{
int to, nxt;
}e[N << 1];
void addedge(int u, int v) {
e[++ecnt] = {v, head[u]};
head[u] = ecnt;
}
void dfs(int x, int l, int r) {
if(a[x] >= l && a[x] <= r) ans = max(ans, b[x]);
vis[x] = true;
for(int i = head[x], y; i; i = e[i].nxt) {
y = e[i].to;
if(!vis[y]) dfs(y, l, r);
}
}
int main(){
freopen("recall.in", "r", stdin);
freopen("recall.out", "w", stdout);
scanf("%d%d", &c, &T);
while(T--) {
ecnt = 0;
scanf("%d%d%d", &n, &m, &q);
for(int i = 1; i <= n; i++) head[i] = 0;
for(int i = 1, x, y; i <= m; i++) {
scanf("%d%d", &x, &y);
addedge(x, y);
}
for(int i = 1; i <= n; i++)
scanf("%d", a + i);
for(int i = 1; i <= n; i++)
scanf("%d", b + i);
while(q--) {
int o;
scanf("%d", &o);
if(o == 1) {
int x, y;
scanf("%d%d", &x, &y);
swap(a[x], a[y]);
}
if(o == 2) {
int x, y;
scanf("%d%d", &x, &y);
swap(b[x], b[y]);
}
if(o == 3) {
int x, l, r;
scanf("%d%d%d", &x, &l, &r);
for(int i = 1; i <= n; i++)
vis[i] = false;
ans = 0;
dfs(x, l, r);
printf("%d\n", ans);
}
}
}
return 0;
}