#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T & a, U & ... b) { cin >> a; IN_(b ...); };
template<typename T> void OUT(T && a) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

class UnionFind {
private:
	int n, s;
	vector<int> t;
	vector<vector<int>> v;
public:
	UnionFind(int arg_n = 0) { init(arg_n); }
	void init(int arg_n) {
		n = s = arg_n;
		t.clear();
		v.clear();
		inc(i, n) { t.PB(i); v.EB(1, i); }
	}
	int get_n() { return n; }
	int size() { return s; }
	int id(int x) { return t.at(x); }
	const vector<vector<int>> & get_v() { return v; }
	bool unite(int x, int y) {
		x = id(x);
		y = id(y);
		if(x == y) { return false; }
		if(v[x].size() < v[y].size()) { swap(x, y); }
		for(auto & e: v[y]) { v[x].PB(e); t[e] = x; }
		v[y].clear();
		s--;
		return true;
	}
	bool same(int x, int y) { return (id(x) == id(y)); }
	const vector<int> & operator[](int x) { return v[id(x)]; }
	friend ostream & operator<<(ostream & os, const UnionFind & uf) {
		inc(i, uf.n) { os << i << ": "; for(auto & e: uf.v[i]) { os << e << " "; } os << "\n"; }
		return os;
	}
};

// ---- ----

template<typename T> istream & operator>>(istream & s, vector<T> & v) { RF(e, v) { s >> e; } return s; }
template<typename T> ostream & operator<<(ostream & s, vector<T> const & v) {
	inc(i, SI(v)) { s << (i == 0 ? "" : " ") << v[i]; }
	return s;
}

template<typename T, typename U> istream & operator>>(istream & s, pair<T, U> & p) { return (s >> p.FI >> p.SE); }
template<typename T, typename U> ostream & operator<<(ostream & s, pair<T, U> const & p) { return (s << p.FI << " " << p.SE); }

#define LB(v, x) (lower_bound(ALL(v), x) - v.begin())
#define UB(v, x) (upper_bound(ALL(v), x) - v.begin())

int main() {
	IN(int, n, m);
	vector<pair<int, int>> ab(n), lr(m);
	cin >> ab >> lr;
	sort(ALL(ab));
	vector<int> a, b;
	RF(e, ab) {
		a.PB(e.FI);
		b.PB(e.SE);
	}
	RF(e, lr) {
		e.FI = LB(a, e.FI);
		e.SE = UB(a, e.SE);
	}
	
	vector<vector<pair<int, int>>> g(n + 1);
	auto add = [&](int x, int y, int i) {
		g[x].EB(y, i);
		g[y].EB(x, i);
	};
	
	UnionFind uf(n + 1);
	inc(i, m) {
		if(uf.unite(lr[i].FI, lr[i].SE)) { add(lr[i].FI, lr[i].SE, i); }
	}
	
	bool ok = true;
	vector<int> s(n + 1);
	b.PB(0);
	inc(i, n) {
		if(b[i] == 0) { continue; }
		int j = i;
		until(b[j] == 0) { j++; }
		ok &= uf.same(i, j);
		s[i] ^= 1;
		s[j] ^= 1;
		i = j - 1;
	}
	if_not(ok) { OUT(-1); return 0; }
	
	vector<int> vis(n + 1), ans;
	function<int(int, int)> dfs = [&](int v, int pe) {
		if(vis[v] == 1) { return 0; }
		vis[v] = 1;
		RF(e, g[v]) {
			s[v] ^= dfs(e.FI, e.SE);
		}
		if(s[v] == 1) { ans.PB(pe + 1); }
		return s[v];
	};
	inc(i, n + 1) { dfs(i, -1); }
	sort(ALL(ans));
	
	OUT(SI(ans));
	OUT(ans);
}


Measured memory_bytes: 19176