#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <climits>
using namespace std;

#define ALL(v) begin(v),end(v)

typedef pair<int,int> pii;

vector<int> tgt;
vector<vector<pii>> G;
vector<int> vis;
vector<int> ans;

int dfs(int u){
	vis[u] = 1;
	int ret = tgt[u];
	for(const auto &e : G[u]){
		int v = e.first;
		if(vis[v]){ continue; }
		int r = dfs(v);
		if(r){
			ret ^= 1;
			ans.push_back(e.second);
		}
	}
	return ret;
}

int main(){
	int n, m;
	scanf("%d%d", &n, &m);
	vector<pii> as(n + 1);
	for(int i = 0; i < n; ++i){
		scanf("%d%d", &as[i].first, &as[i].second);
	}
	as[n].first = INT_MAX;
	sort(ALL(as));

	tgt.resize(n + 1);
	int prv = 0;
	for(int i = 0; i <= n; ++i){
		tgt[i] = as[i].second ^ prv;
		prv = as[i].second;
	}
	
	G.resize(n + 1);
	for(int i = 1; i <= m; ++i){
		int x, y;
		scanf("%d%d", &x, &y);
		int l = lower_bound(ALL(as), pii(x, -1)) - as.begin();
		int r = lower_bound(ALL(as), pii(y, 9)) - as.begin();
		if(l < r){
			G[l].emplace_back(r, i);
			G[r].emplace_back(l, i);
		}
	}

	vis.assign(n + 1, 0);
	for(int i = 0; i < n; ++i){
		if(!vis[i]){
			int r = dfs(i);
			if(r){
				puts("-1");
				return 0;
			}
		}
	}

	sort(ALL(ans));
	printf("%zu\n", ans.size());
	const char *spl = "";
	for(int x : ans){
		printf("%s%d", spl, x);
		spl = " ";
	}
	puts("");
}
