#include <bits/stdc++.h>
#define ull unsigned long long
#define lowbit(x) (x & - (x))
#define pii pair<int, int>
#define pb push_back
#define ll long long
#define fir first
#define sec second
using namespace std;
namespace fast_IO {
template<typename T> inline void read(T &x, bool g = 0) {
x = 0; bool f = 0; char ch = getchar();
while (! isdigit(ch)) f |= (ch == '-'), ch = getchar();
while (isdigit(ch)) {
x = (x << 3) + (x << 1) + ch - '0', ch = getchar();
if (g) break;
}
if (f) x = - x;
}
template<typename T, typename... Args> inline void read(T &first, Args& ... args) {
read(first);
read(args...);
}
template<typename T> inline void write(T x, int f = -1) {
if (x < 0) x = - x, putchar('-'); static short Stack[50], top(0);
do Stack[++ top] = x % 10, x /= 10; while (x);
while (top) putchar(Stack[top --] | 48);
if (~ f) putchar(f ? '\n' : ' ');
}
} using namespace fast_IO;
const int N = 1e5 + 5;
int n, m, q, ans, top, a[N], b[N], stk[N];
vector<int> e[N];
bool vis[N];
void dfs(int u, int l, int r) {
if (a[u] >= l && a[u] <= r) ans = max(ans, b[u]);
vis[u] = 1; stk[++ top] = u;
for (int i : e[u]) if (! vis[i]) dfs(i, l, r);
}
void clr() { while (top) vis[stk[top --]] = 0; }
void solve() {
read(n, m, q);
for (int i = 1; i <= n; i ++)
e[i].clear();
for (int i = 1; i <= m; i ++) {
int u, v; read(u, v);
e[u].pb(v);
}
for (int i = 1; i <= n; i ++)
read(a[i]);
for (int i = 1; i <= n; i ++)
read(b[i]);
while (q --) {
int o, x, y, z; read(o, x, y);
if (o == 1) swap(a[x], a[y]);
else if (o == 2) swap(b[x], b[y]);
else read(z), ans = top = 0, dfs(x, y, z), write(ans, 1), clr();
}
}
signed main() {
freopen("recall.in", "r", stdin);
freopen("recall.out", "w", stdout);
int c, t; read(c, t);
while (t --) solve();
return 0;
}