#include <bits/stdc++.h>

using namespace std;

using i64 = int64_t;

const i64 MOD = 1e9 + 7;


struct BIT{
    vector<i64> elm;
    BIT(i64 n) : elm(n + 1, 0){}
    i64 sum(i64 x){
        i64 val = 0;
        for(; x > 0; x -= x & -x)
            val += elm[x];
        return val;
    }
    void add(i64 x, i64 val){
        for(++x; x < elm.size(); x += x & -x)
            elm[x] += val;
    }
};

struct Segtree{
    i64 n, m;
    vector<i64> elm, lazy;
    Segtree(i64 n, i64 m) : n(n), m(m), elm(2 * n, 0), lazy(2 * n, 1){}
    vector<i64> get_list(i64 x, i64 y){
        vector<i64> ret_list;
        for(x += n, y += n - 1; x; x >>= 1, y >>= 1){
            ret_list.emplace_back(x);
            if(x != y)
                ret_list.emplace_back(y);
        }
        return ret_list;
    }
    void eval(i64 x){
        elm[x] *= lazy[x];
        if(x < n){
            lazy[2 * x] *= lazy[x];
            lazy[2 * x + 1] *= lazy[x];
        }
        lazy[x] = 1;
    }
    void update(i64 x){
        i64 y = n;
        vector<i64> index_list = get_list(x, y);
        for(i64 i = index_list.size() - 1; i >= 0; --i)
            eval(index_list[i]);
        for(x += n, y += n - 1; x <= y; x >>= 1, y >>= 1){
            if(x & 1){
                lazy[x] *= -1;
                eval(x++);
            }
            if(!(y & 1)){
                lazy[y] *= -1;
                eval(y--);
            }
        }
        for(auto& index : index_list){
            if(index < n){
                eval(2 * index);
                eval(2 * index + 1);
                elm[index] = elm[2 * index] + elm[2 * index + 1];
            }
        }
    }
    i64 get(){
        i64 x = 0, y = n;
        vector<i64> index_list = get_list(x, y);
        for(i64 i = index_list.size() - 1; i >= 0; --i)
            eval(index_list[i]);
        i64 l = 0, r = 0;
        for(x += n, y += n - 1; x <= y; x >>= 1, y >>= 1){
            if(x & 1){
                eval(x);
                i64 val = elm[x++];
                val = val >= 0 ? val % m : m - (abs(val) % m);
                l += val;
                l %= m;
            }
            if(!(y & 1)){
                eval(y);
                i64 val = elm[y--];
                val = val >= 0 ? val % m : m - (abs(val) % m);
                r += val;
                r %= m;
            }
        }
        return (l + r) % m;
    }
    void set(i64 pos, i64 val){
        vector<i64> index_list = get_list(pos, pos + 1);
        for(i64 i = index_list.size() - 1; i >= 0; --i)
            eval(index_list[i]);
        elm[pos + n] = val;
        lazy[pos + n] = 1;
        for(auto& index : index_list){
            if(index < n){
                eval(2 * index);
                eval(2 * index + 1);
                elm[index] = elm[2 * index] + elm[2 * index + 1];
            }
        }
    }
};

signed main(){
    i64 k, n, q;
    cin >> k >> n >> q;
    vector<i64> v(n);
    for(auto& x : v){
        cin >> x;
        x *= -1;
    }
    vector<pair<i64,i64>> query;
    for(i64 i = 0; i < q; ++i){
        i64 a, b;
        cin >> a >> b;
        --a, --b;
        query.emplace_back(a, b);
    }

    BIT zero_cnt(n);
    Segtree seg(n, k);
    for(i64 i = 0; i < n; ++i){
        if(v[i] == 0){
            zero_cnt.add(i, 1);
            seg.update(i);
        }else{
            seg.set(i, v[i] * ((zero_cnt.sum(i)) % 2 == 0 ? 1 : -1));
        }
    }


    auto replace = [&](i64 pos, i64 val){
        if(v[pos] == 0){
            zero_cnt.add(pos, 1);
            seg.update(pos);
        }
        if(val == 0){
            zero_cnt.add(pos, 1);
            seg.update(pos);
        }
        seg.set(pos, val * ((zero_cnt.sum(pos)) % 2 == 0 ? 1 : -1));
        v[pos] = val;
    };

    /*
    i64 ret = seg.get();
    cout << "real : " << ret << endl << "answer : ";
    cout << (zero_cnt.sum(n) % 2 == 0 ? 1 : -1) * ((ret % n) + 1) << endl;
    */

    for(auto& q : query){
        i64 a, b;
        tie(a, b) = q;
        i64 a_val = v[a], b_val = v[b];

        // v[a] to v[b]
        replace(a, b_val);
        // v[b] to v[a]
        replace(b, a_val);

        i64 ret = seg.get();
        // cout << "real : " << ret << endl << "answer : ";
        cout << (zero_cnt.sum(n) % 2 == 0 ? 1 : -1) * ((ret % k) + 1) << endl;
    }
}



Measured memory_bytes: 8536