//Link : https://atcoder.jp/contests/abc155/tasks/abc155_f

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 200005

pair<int,int> in[N];
int bit[N];
vector<pair<int,int> >adj[N];
vector<int> out;
bool vis[N];
int parity[N];
int dfs(int node) {
  parity[node] = bit[node];
  vis[node] = true;
  for(pair<int,int> ch : adj[node]) {
    if(!vis[ch.first]) {
      dfs(ch.first);
      parity[node] ^= parity[ch.first];

      if(parity[ch.first]==1) {
        out.push_back(ch.second);
      }
    }
  }
  return parity[node];
}

int ar[N];
void solve() {
  int n,m;scanf("%d %d ", &n,&m);

  vector<int> xs;
  for(int i=0;i<n;++i) {
    scanf("%d %d ", &in[i].first,&in[i].second);
    ar[i] = in[i].first;
  }
  in[n].first = 2e9;
  sort(in,in+n);
  bit[0] = in[0].second;
  for(int i=n;i;--i) {
    in[i].second^= in[i-1].second;
    bit[i] = in[i].second;
  }
  for(int i=0;i<m;++i) {
    int x,y;
    scanf("%d %d ", &x,&y);
    int l = lower_bound(in,in+n+1,make_pair(x,-15)) - in;
    int r = lower_bound(in,in+n+1,make_pair(y+1,-15))-in;
    if(l!=r) {
      adj[r].push_back(make_pair(l,i+1));
      adj[l].push_back(make_pair(r,i+1));
    }
  }

  for(int i=0;i<=n;++i) {
    if(!vis[i]) {
      if(dfs(i)) {
        printf("-1\n");
        return;
      }
    }
  }
  printf("%d\n", out.size());
  sort(out.begin(),out.end());
  for(int edge : out) {
    printf("%d ", edge);
  }
  putchar('\n');
}

int main() {
    //freopen("input.txt","r",stdin);
    solve();
    return 0;
}
