#include <cassert>
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <cstdint>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
#include <limits>
#include "limits.h"
 
#define rep(i, a, b) for (long long (i) = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if(b==0)return 1;
  if ((a == 0)||(mod!=-1&&(a+mod)%mod==0)) {
    return 0;
  }
  long long x = 1;
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}

// const long long MOD = 998244353;
const long long MOD = 1e9 + 7;

using ll = long long;
using P=std::pair<long long,long long>;

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  ll n,m;
  std::cin>>n>>m;

  std::vector<P> bomb(n+2);

  rep(i,0,n)std::cin>>bomb[i].first>>bomb[i].second;

  bomb[n]={0,0};
  bomb[n+1]={MOD,0};//番兵を入れる

  std::sort(all(bomb));//座標順ソート

  std::vector<ll> diff(n+2,0);
  rep(i,0,n+1){
    if(bomb[i].second!=bomb[i+1].second)diff[i]=1;
  }

  std::vector<P> code(m);
  rep(i,0,m)std::cin>>code[i].first>>code[i].second;
  
  auto comp=[](const P& a,const P& b)->bool{
    return a.first<b.first;
  };

  rep(i,0,m){
    code[i].first=std::lower_bound(all(bomb),P(code[i].first,0),comp)-bomb.begin()-1;
    code[i].second=std::upper_bound(all(bomb),P(code[i].second,1),comp)-bomb.begin()-1;
  }

  std::vector<std::vector<P>> graph(n+2);

  rep(i,0,m){
    if(code[i].first==code[i].second)continue;
    graph[code[i].first].emplace_back(code[i].second,i);
    graph[code[i].second].emplace_back(code[i].first,i);
  }

  std::vector<ll> visit(n+2,0);

  std::vector<ll> ans;

  auto dfs=[&](auto f,ll now,ll par)->ll{
    visit[now]=1;
    ll ret=0;
    for(auto e:graph[now]){
      if(e.first==par||visit[e.first])continue;
      ll val=f(f,e.first,now);
      ret+=val;
      if(val%2==1){
        ans.push_back(e.second);
        if(diff[e.first]==1)ret--;
        diff[e.first]^=1;
        diff[now]^=1;
      }
    }
    if(diff[now]==1)ret++;
    return ret;
  };

  rep(i,0,n+2){
    if(visit[i]==0){
      dfs(dfs,i,-1);
    }
    if(diff[i]!=0){
      std::cout<<-1<<"\n";
      return 0;
    }
  }

  std::sort(all(ans));
  std::cout<<ans.size()<<"\n";
  for(auto e:ans)std::cout<<e+1<<" ";
  std::cout<<"\n";

  return 0;
}


Measured memory_bytes: 26108