/*  n = list(map(int,input()))[::-1]
    n.append(0)

    for i in range(len(n)):
        if n[i] >= 6 or (n[i] == 5 and n[i+1] >= 5):
            n[i] = 10 - n[i]
            n[i+1] += 1

    print(sum(n)) */

    #include <bits/stdc++.h>
    using namespace std;

    struct Unionfind {
      // tree number
      vector<int> par;
      // tree rank
      vector<int> treerank;
      // constructor
      Unionfind(int n = 1) { stree(n + 1); }
      // make and initialization
      void stree(int n = 1) {
        par.assign(n, -1);
        treerank.assign(n, 0);
      }
      // search root
      int root(int x) {
        if(par[x] < 0) return x;
        return par[x] = root(par[x]);
      }
      // is same?
      bool issame(int x, int y) { return root(x) == root(y); }

      // add
      // already added, return 0
      bool uni(int x, int y) {
        x = root(x);
        y = root(y);
        if(x == y) return 0;
        if(treerank[x] > treerank[y]) swap(x, y);
        if(treerank[x] == treerank[y]) ++treerank[y];
        par[y] -= size(x);
        par[x] = y;
        return 1;
      }
      int size(int x) { return -par[root(x)]; }
    };

    struct bomb {
      int a;
      bool b;
      bomb(int _a = 0, bool _b = 0) : a(_a), b(_b) {}
      bool operator<(const bomb& r) const { return a < r.a; }
    };

    struct cod {
      int l, r;
    };

    int n, m;
    vector<bomb> bombs;
    vector<cod> v;
    vector<bool> dif, used;
    vector<int> res;
    vector<vector<int>> edges;
    Unionfind uf;

    bool solve();
    bool dfs(int now);

    int main() {
      cin >> n >> m;
      bombs.resize(n);
      for(int i = 0; i < n; ++i)
        cin >> bombs[i].a >> bombs[i].b;
      bombs.push_back({-1, 0});
      sort(bombs.begin(), bombs.end());
      bombs.push_back({(int)1e9 + 1, 0});
      v.resize(m);
      for(int i = 0; i < m; ++i) {
        int l, r;
        cin >> l >> r;
        l = lower_bound(bombs.begin(), bombs.end(),
                        bomb(l, 0)) -
            bombs.begin();
        r = upper_bound(bombs.begin(), bombs.end(),
                        bomb(r, 1)) -
            bombs.begin();
        v[i] = {l - 1, r - 1};
      }
      for(int i = 0; i < bombs.size() - 1; ++i)
        dif.push_back(bombs[i].b ^ bombs[i + 1].b);
      if(solve()) {
        cout << res.size() << endl;
        for(int i = 0; i < res.size(); ++i) {
          if(i != 0) cout << " ";
          cout << res[i] + 1;
        }
        cout << endl;
      }
      else
        cout << -1 << endl;
      return 0;
    }

    bool solve() {
      n = dif.size();
      uf = Unionfind(n);
      edges.resize(n);
      for(int i = 0; i < m; ++i)
        if(!uf.issame(v[i].l, v[i].r)) {
          uf.uni(v[i].l, v[i].r);
          edges[v[i].l].push_back(i);
          edges[v[i].r].push_back(i);
        }
      used.assign(n, 0);
      for(int i = 0; i < n; ++i)
        used[uf.root(i)] = used[uf.root(i)] ^ dif[i];
      for(int i = 0; i < n; ++i)
        if(used[i]) return 0;
      for(int i = 0; i < n; ++i)
        if(!used[i]) {
          used[i] = 1;
          dfs(i);
        }
      sort(res.begin(), res.end());
      return 1;
    }

    bool dfs(int now) {
      for(auto e : edges[now]) {
        int nextp;
        if(v[e].l == now)
          nextp = v[e].r;
        else
          nextp = v[e].l;
        if(used[nextp]) continue;
        used[nextp] = 1;
        if(dfs(nextp)) {
          res.push_back(e);
          dif[now] = dif[now] ^ 1;
        }
      }
      return dif[now];
    }


Measured memory_bytes: 9712