#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k, q;
    cin >> n >> k >> q;
    int B = 500;
    vector<int> a(k), b(k);
    for (int i = 0; i < k; i++) {
        cin >> a[i] >> b[i];
        --a[i];
        --b[i];
    }
    int bc = k / B + (k % B > 0);
    vector<vector<int>> tol(bc, vector<int>(n));
    vector<vector<int>> tor = tol;
    for (int i = 0; i < bc; i++) {
        int l = i * B, r = min(k - 1, i * B + B - 1);
        iota(all(tol[i]), 0);
        iota(all(tor[i]), 0);
        vector<int> idx(n);
        iota(all(idx), 0);
        for (int j = l; j <= r; j++) {
            swap(tol[i][idx[a[j]]], tol[i][idx[b[j]]]);
            swap(idx[a[j]], idx[b[j]]);
        }
        iota(all(idx), 0);
        for (int j = r; j >= l; j--) {
            swap(tor[i][idx[a[j]]], tor[i][idx[b[j]]]);
            swap(idx[a[j]], idx[b[j]]);
        }
    }
    for (int i = 0; i < q; i++) {
        int tt, s, t, x;
        cin >> tt >> s >> t >> x;
        --s;
        --t;
        --x;
        int tl = s / B + 1, tr = t / B;
        if (s % B == 0) {
            tl--;
        }
        if (t % B == B - 1) {
            tr++;
        }
        if (tt == 1) {
            if (s / B == t / B) {
                for (int j = t; j >= s; j--) {
                    if (x == a[j]) {
                        x = b[j];
                    } else if (x == b[j]) {
                        x = a[j];
                    }
                }
                cout << x + 1 << endl;
                continue;
            }
            for (int j = t; j >= tr * B; j--) {
                if (x == a[j]) {
                    x = b[j];
                } else if (x == b[j]) {
                    x = a[j];
                }
            }
            for (int j = tr - 1; j >= tl; j--) {
                x = tor[j][x];
            }
            for (int j = tl * B - 1; j >= s; j--) {
                if (x == a[j]) {
                    x = b[j];
                } else if (x == b[j]) {
                    x = a[j];
                }
            }
        } else {
            if (s / B == t / B) {
                for (int j = s; j <= t; j++) {
                    if (x == a[j]) {
                        x = b[j];
                    } else if (x == b[j]) {
                        x = a[j];
                    }
                }
                cout << x + 1 << endl;
                continue;
            }
            for (int j = s; j < tl * B; j++) {
                if (x == a[j]) {
                    x = b[j];
                } else if (x == b[j]) {
                    x = a[j];
                }
            }
            for (int j = tl; j < tr; j++) {
                x = tol[j][x];
            }
            for (int j = tr * B; j <= t; j++) {
                if (x == a[j]) {
                    x = b[j];
                } else if (x == b[j]) {
                    x = a[j];
                }
            }
        }
        cout << x + 1 << endl;
    }
}
/*
各バケットについて、「開始時に左からi番目のものが終了時に何番目にあるか」
「終了時に〜」
を求めておく。
[i*b,min(k-1,i*b+b-1)]
toli:i番目のものの現時点の位置
idxi:いまi番目にいるやつ

*/


Measured memory_bytes: 160632