#include using namespace std; using ll = long long; using vl = vector; using vvl = vector; using vvvl = vector; #define rep(i, n) for (int i = 0; i < n; i++) #define all(x) x.begin(), x.end() constexpr ll dx[] = {1, 0, -1, 0, 1, -1, -1, 1}; constexpr ll dy[] = {0, 1, 0, -1, 1, 1, -1, -1}; struct Init { Init() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(15); } } init; template ostream& operator<<(ostream& os, const pair& pair_var) { os << "(" << pair_var.first << ", " << pair_var.second << ")"; return os; } template ostream& operator<<(ostream& os, const vector& vec) { os << "["; rep(i, vec.size()) { os << vec[i]; if (i != vec.size() - 1) os << ", "; } os << "]"; return os; } template ostream& operator<<(ostream& os, const vector>& vec) { os << "["; rep(i, vec.size()) { os << vec[i]; if (i != vec.size() - 1) os << ", "; } os << "]"; return os; } #include using namespace atcoder; using mint = modint998244353; vl f(vl& a1, vl& a2) { vl nex = {}; rep(i, a1.size()) { nex.push_back(a2[a1[i] - 1]); } return nex; } const ll BLOCK_SIZE = 500; vvl cache = {}; vector> items; vl getArrM(ll x) { vl res = cache[x / BLOCK_SIZE]; for (int i = x / BLOCK_SIZE * BLOCK_SIZE; i < x; i++) { swap(res[items[i].first - 1], res[items[i].second - 1]); } return res; }; int main() { ll n, m, q; cin >> n >> m >> q; items.resize(m); rep(i, m) cin >> items[i].first >> items[i].second; vl last(n); rep(i, n) last[i] = i + 1; rep(i, m) { if (i % BLOCK_SIZE == 0) { cache.push_back(last); } swap(last[items[i].first - 1], last[items[i].second - 1]); } vvl db = {last}; rep(i, 60) { db.push_back(f(db.back(), db.back())); } rep(i, q) { ll t, x; cin >> t >> x; ll rest = t % m; ll now = (t - rest) / m; vl a(n); rep(i, n) a[i] = i + 1; rep(i, 60) { if (now % 2) { a = f(db[i], a); } now /= 2; } vl res = getArrM(rest); cout << f(res, a)[x - 1] << endl; } return 0; }