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

typedef long long ll;

ll N, M;
vector<pair<ll, ll>> AB;
vector<ll> B;
vector<vector<pair<ll, ll>>> Adj;
vector<bool> Seen;
set<ll> Res;
ll pos(ll x) {
  return lower_bound(AB.begin(), AB.end(), make_pair(x, -1ll)) - AB.begin();
}
void dfs(ll v) {
  Seen[v] = true;
  for (auto wi : Adj[v]) {
    ll w, i;
    tie(w, i) = wi;
    if (Seen[w]) continue;
    dfs(w);
    if (B[w]) {
      B[w] = 0;
      B[v] = 1 - B[v];
      Res.insert(i);
    }
  }
}
bool check() {
  Seen.resize(N + 1);
  for (ll i = 0; i <= N; ++i) {
    if (Seen[i]) continue;
    dfs(i);
    if (B[i]) return false;
  }
  return true;
}
int main() {
  cin >> N >> M;
  AB.resize(N);
  for (ll i = 0; i < N; ++i) {
    ll a, b;
    cin >> a >> b;
    AB[i] = make_pair(a, b);
  }
  sort(AB.begin(), AB.end());
  B.resize(N + 1);
  for (ll i = 0; i <= N; ++i) {
    B[i] =
        ((i == N ? 0 : AB[i].second) + 2 - (i == 0 ? 0 : AB[i - 1].second)) % 2;
  }
  Adj.resize(N + 1);
  for (ll i = 0; i < M; ++i) {
    ll l, r;
    cin >> l >> r;
    ++r;
    l = pos(l);
    r = pos(r);
    if (l == r) continue;
    Adj[l].emplace_back(r, i);
    Adj[r].emplace_back(l, i);
  }
  if (!check())
    cout << -1 << endl;
  else {
    cout << Res.size() << endl;
    bool first = true;
    for (ll r : Res) {
      cout << (first ? "" : " ") << r + 1;
      first = false;
    }
    cout << endl;
  }
  return 0;
}
