#include <bits/stdc++.h>
using namespace std;
const uint64_t seed = std::chrono::system_clock::now().time_since_epoch().count();
mt19937_64 rnd(seed);
const int MOD = 998244353;

#ifdef VIPJML_LOCAL
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << "{";
    for (typename vector<T>::const_iterator vi = v.begin(); vi != v.end(); ++vi)
    {
        if (vi != v.begin())
            os << ", ";
        os << *vi;
    }
    os << "}";
    return os;
}
template <typename A, typename B>
ostream &operator<<(ostream &os, const vector<pair<A, B>> &v)
{
    os << "{";
    for (typename vector<pair<A, B>>::const_iterator vi = v.begin(); vi != v.end(); ++vi)
    {
        if (vi != v.begin())
            os << ", ";
        os << '(' << vi->first << " " << vi->second << ")";
    }
    os << "}";
    return os;
}

template <typename A, typename B>
ostream &operator<<(ostream &os, const pair<A, B> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

void dbg_out() { cerr << endl; }
template <typename Head, typename... Tail>
void dbg_out(Head H, Tail... T)
{
    cerr << ' ' << H;
    dbg_out(T...);
}
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif
using LL = long long;

struct Mint
{
    long long v;
    Mint() : v(0) {}
    Mint(long long t)
    {
        v = t % MOD;
        if (v < 0)
            v += MOD;
    }

    Mint pow(long long k)
    {
        Mint res(1), tmp(v);
        while (k)
        {
            if (k & 1)
                res *= tmp;
            tmp *= tmp;
            k >>= 1;
        }
        return res;
    }

    Mint inv() { return pow(MOD - 2); }

    Mint &operator+=(Mint a)
    {
        v += a.v;
        if (v >= MOD)
            v -= MOD;
        return *this;
    }
    Mint &operator-=(Mint a)
    {
        v += MOD - a.v;
        if (v >= MOD)
            v -= MOD;
        return *this;
    }
    Mint &operator*=(Mint a)
    {
        v = v * a.v % MOD;
        return *this;
    }
    Mint &operator/=(Mint a) { return (*this) *= a.inv(); }

    Mint operator+(Mint a) const { return Mint(v) += a; }
    Mint operator-(Mint a) const { return Mint(v) -= a; }
    Mint operator*(Mint a) const { return Mint(v) *= a; }
    Mint operator/(Mint a) const { return Mint(v) /= a; }

    Mint operator-() const { return v ? Mint(MOD - v) : Mint(v); }

    bool operator==(const Mint a) const { return v == a.v; }
    bool operator!=(const Mint a) const { return v != a.v; }
    bool operator<(const Mint a) const { return v < a.v; }

    static Mint comb(long long n, int k)
    {
        Mint num(1), dom(1);
        for (int i = 0; i < k; i++)
        {
            num *= Mint(n - i);
            dom *= Mint(i + 1);
        }
        return num / dom;
    }

    static Mint inv(int n)
    {
        return Mint(n).inv();
    }

    static vector<Mint> getInvArray(int N)
    {
        vector<Mint> inv(N + 1, 1);
        for (int i = 2; i <= N; i++)
            inv[i] = inv[MOD % i] * (MOD - MOD / i);
        return inv;
    }
};

ostream &operator<<(ostream &os, Mint m)
{
    os << m.v;
    return os;
}

void solve(int caseNum)
{
    int n1, n2, m;
    cin >> n1 >> n2 >> m;
    int n = n1 + n2;
    vector<pair<int, int>> e;
    vector<vector<int>> g(n);
    for (int i = 0; i < m; i++)
    {
        int x, y;
        cin >> x >> y;
        x--, y--;
        y += n1;
        g[x].push_back(i);
        g[y].push_back(i);
        e.push_back({x, y});
        //dbg(x, y);
    }

    struct EPATH
    {
        unordered_set<int> e1;
        unordered_set<int> e2;
        Mint total = 0;
        Mint cur = 0;
        int cnt = 0;
        int startP;
        int lastP;
        EPATH()
        {
        }
    };
    Mint ans = 0;
    vector<Mint> pp(4e5 + 1, 1);
    for (int i = 1; i <= 4e5; i++)
    {
        pp[i] = pp[i - 1] * 2;
    }

    vector<int> cur(n, 0);
    vector<bool> used(m, false);
    vector<int> ecnt(n);
    for (int i = 0; i < n; i++)
        ecnt[i] = g[i].size();

    vector<EPATH> path;
    function<void(int, int)> dfs = [&](int c, int i) {
        for (; cur[c] < g[c].size(); cur[c]++)
        {
            int ei = g[c][cur[c]];
            if (used[ei])
                continue;
            used[ei] = true;
            ecnt[e[ei].first]--;
            ecnt[e[ei].second]--;
            path[i].cnt++;
            path[i].total += pp[ei + 1];
            if (path[i].cnt % 2 == 0)
            {
                path[i].cur += pp[ei + 1];
                path[i].e2.insert(ei);
            }
            else
            {
                path[i].e1.insert(ei);
            }
            if (path[i].cnt == 1)
                path[i].startP = c;
            dfs(c ^ e[ei].first ^ e[ei].second, i);
            return;
        }
        path[i].lastP = c;
    };
    for (int i = 0; i < n; i++)
    {
        if (ecnt[i] % 2 == 1)
        {
            path.emplace_back();
            dfs(i, path.size() - 1);
        }
    }
    int ps = path.size();
    for (int i = 0; i < n; i++)
    {
        if (ecnt[i] != 0)
        {
            path.emplace_back();
            dfs(i, path.size() - 1);
        }
    }
    dbg(ps, path.size());
    auto reversePath = [&](int i) {
        swap(path[i].startP, path[i].lastP);
        if (path[i].cnt % 2 == 0)
        {
            ans -= path[i].cur;
            path[i].cur = path[i].total - path[i].cur;
            ans += path[i].cur;
            swap(path[i].e1, path[i].e2);
        }
    };
    unordered_map<int, int> pMap;
    for (int i = 0; i < path.size(); i++)
    {
        EPATH &ep = path[i];
        if (i < ps)
        {
            pMap[ep.startP] = i;
            pMap[ep.lastP] = i;
        }
        ans += ep.cur;
    }
    auto dbgPath = [&]() {
        for (auto t : path)
        {
            dbg(vector<int>(t.e1.begin(), t.e1.end()));
            dbg(vector<int>(t.e2.begin(), t.e2.end()));
        }
    };
    //dbgPath();
    int q;
    cin >> q;
    for (int i = 0; i < q; i++)
    {
        int t, u, v;
        cin >> t;
        if (t == 1)
        {
            cin >> u >> v;
            u--, v--;
            v += n1;
            int p1 = -1, p2 = -1;
            if (pMap.find(u) != pMap.end())
                p1 = pMap[u];
            if (pMap.find(v) != pMap.end())
                p2 = pMap[v];

            if (p1 == -1 && p2 == -1)
            {
                path.emplace_back();
                path.back().e1.insert(m);
                path.back().cnt = 1;
                path.back().cur = 0;
                path.back().total = pp[m + 1];
                path.back().startP = u;
                path.back().lastP = v;
                pMap[u] = path.size() - 1;
                pMap[v] = path.size() - 1;
            }
            else
            {
                if (p2 == -1)
                {
                    swap(p1, p2);
                    swap(u, v);
                }

                if (p1 == -1)
                {
                    if (path[p2].startP == v)
                        reversePath(p2);
                    path[p2].cnt++;
                    path[p2].total += pp[m + 1];
                    pMap.erase(v);
                    pMap[u] = p2;

                    if (path[p2].cnt % 2 == 0)
                    {
                        path[p2].cur += pp[m + 1];
                        path[p2].e2.insert(m);
                        ans += pp[m + 1];
                    }
                    else
                    {
                        path[p2].e1.insert(m);
                    }
                    path[p2].lastP = u;
                }
                else
                {
                    pMap.erase(u);
                    pMap.erase(v);
                    if (p1 == p2)
                    {
                        path[p2].cnt++;
                        path[p2].total += pp[m + 1];
                        path[p2].cur += pp[m + 1];
                        ans += pp[m + 1];
                        path[p2].e2.insert(m);
                        path[p2].lastP = path[p2].startP;
                    }
                    else
                    {
                        if (path[p1].e1.size() < path[p2].e1.size())
                        {
                            swap(p1, p2);
                            swap(u, v);
                        }
                        if (path[p1].startP == u)
                            reversePath(p1);
                        if (path[p2].lastP == v)
                            reversePath(p2);
                        path[p1].total += pp[m + 1] + path[p2].total;
                        if (path[p1].cnt % 2 == 1)
                        {
                            path[p1].e2.insert(m);
                            path[p1].e1.insert(path[p2].e1.begin(), path[p2].e1.end());
                            path[p1].e2.insert(path[p2].e2.begin(), path[p2].e2.end());
                            path[p1].cur += pp[m + 1] + path[p2].cur;
                            ans += pp[m + 1];
                        }
                        else
                        {
                            path[p1].e1.insert(m);
                            path[p1].e1.insert(path[p2].e2.begin(), path[p2].e2.end());
                            path[p1].e2.insert(path[p2].e1.begin(), path[p2].e1.end());
                            ans -= path[p1].cur + path[p2].cur;
                            path[p1].cur += path[p2].total - path[p2].cur;
                            ans += path[p1].cur;
                        }
                        path[p1].lastP = path[p2].lastP;
                        pMap[path[p2].lastP] = p1;
                        path[p1].cnt += 1 + path[p2].cnt;
                        path[p2].e1.clear();
                        path[p2].e2.clear();
                    }
                }
            }
            m++;
            cout << ans << endl;
            //dbgPath();
        }
        else
        {
            vector<int> res;
            for (auto &ep : path)
            {
                for (int ei : ep.e2)
                {
                    res.push_back(ei);
                }
            }
            cout << res.size() << " ";
            for (int r : res)
                cout << r + 1 << " ";
            cout << endl;
        }
    }
}

int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(10);
    int T = 1;
    //cin >> T;
    for (int i = 1; i <= T; i++)
    {
        solve(i);
    }
    cout.flush();
    return 0;
}
