#pragma region Header
#ifdef DEBUG
#include "debug.hpp"
#else
#define NDEBUG
#define debug(...)
#define IFD(...)
#endif
#include <utility>
#include <cstdint>
#include <cmath>
#include <vector>
#include <array>
#include <deque>
#include <queue>
#include <stack>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <string>
#include <functional>
#include <algorithm>
#include <numeric>
#include <stdexcept>
#include <iostream>
#include <iomanip>
using namespace std;
using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;
#define rep(i, n) for (int i = 0; i < static_cast<int>(n); ++i)
#define repd(i, n) for (int i = static_cast<int>(n) - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = static_cast<int>(a); i <= static_cast<int>(b); ++i)
#define FORD(i, b, a) for (int i = static_cast<int>(b); i >= static_cast<int>(a); --i)
template <typename T>
int SZ(T const &x)
{
    return static_cast<int>(x.size());
}
template <class T>
bool chmax(T &a, T const &b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, T const &b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}
#pragma endregion

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);

    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> ab_s(n);
    rep(i, n)
    {
        cin >> ab_s[i].first >> ab_s[i].second;
        --ab_s[i].first;
    }
    sort(ab_s.begin(), ab_s.end());
    vector adjs(n + 1, vector<pair<int, int>>());
    rep(i, m)
    {
        int l, r;
        cin >> l >> r;
        --l;
        // ここの書き方注意
        int l_ = lower_bound(ab_s.begin(), ab_s.end(), make_pair(l, -1)) - ab_s.begin();
        int r_ = lower_bound(ab_s.begin(), ab_s.end(), make_pair(r, -1)) - ab_s.begin();
        if (l_ == r_)
        {
            continue;
        }
        adjs[l_].push_back({i, r_});
        adjs[r_].push_back({i, l_});
    }
    IFD(clog << adjs << endl);

    vector used(n + 1, false), cut(m, false);
    auto dif = [&](int v) {
        if (v == 0)
        {
            return ab_s[0].second;
        }
        if (v == n)
        {
            return ab_s[n - 1].second; // dont care
        }
        return ab_s[v].second ^ ab_s[v - 1].second;
    };
    IFD(rep(i, n + 1) { debug(dif(i)); })
    auto dfs = [&](auto self, int v) -> int {
        used[v] = true;
        int ret = dif(v);
        for (auto &[i, u] : adjs[v])
        {
            if (used[u])
            {
                continue;
            }
            if (self(self, u))
            {
                cut[i] = true;
                ret = 1 - ret;
            }
        }
        debug(v, ret);
        return ret;
    };
    dfs(dfs, n);
    rep(v, n)
    {
        if (used[v])
        {
            continue;
        }
        if (dfs(dfs, v))
        {
            cout << -1 << "\n";
            return 0;
        }
    }
    int cnt = accumulate(cut.begin(), cut.end(), 0);
    cout << cnt << '\n';
    rep(i, m)
    {
        if (cut[i])
        {
            cout << i + 1 << ' ';
        }
    }

    return 0;
}


Measured memory_bytes: 18156