// ====================================================================================================================
// C++ includes used for precompiling -*- C++ -*-

// Copyright (C) 2003-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library.  This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.

// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.

// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
// <http://www.gnu.org/licenses/>.

/** @file stdc++.h
 *  This is an implementation file for a precompiled header.
 */

 // 17.4.1.2 Headers

 // C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

// ここより↑は触らない(#include <bits/stdc++.h>の部分)
// ====================================================================================================================

#define rep(i,n) for (int i = 0; i < (n); ++i)

using namespace std;
using ll = long long;
using P = pair<int, int>;

const int MX = 100005;

vector<P> g[MX];
int x[MX];
bool used[MX];

vector<int> ans;

// dfs(深さ優先探索)
int dfs(int v) {
	// 使いました
	used[v] = true;

	// 状態
	int res = x[v];

	// 影響を与える範囲データ分処理
	for (P e : g[v]) {
		// 使ってたら次へ
		if (used[e.first]) {
			continue;
		}

		// 深さ優先なので処理＆結果取得
		int r = dfs(e.first);

		// 状態がtrueだったら使わざるを得ないので答えに追加
		if (r) {
			ans.push_back(e.second);
		}

		// xor
		res ^= r;
	}
	return(res);
}

int main(void) {
	// NとMの入力
	int n, m;
	cin >> n >> m;

	// 位置&フラグ情報入力
	vector<P> a(n);
	rep(i, n) {
		cin >> a[i].first >> a[i].second;
	}

	// 座標でソート
	sort(a.begin(), a.end());

	// 隣との差を調べて代入していく
	x[0] = a[0].second;
	rep(i, n - 1) {
		x[i + 1] = a[i].second ^ a[i + 1].second;
	}
	x[n] = a[n - 1].second;

	// 操作範囲入力
	rep(i, m) {
		// 位置入力
		int l, r;
		cin >> l >> r;

		// 差の配列インデックスに変換する(位置の左側なのでlower_bound、位置の右側なのでupper_bound)
		l = lower_bound(a.begin(), a.end(), P(l, 0)) - a.begin();
		r = upper_bound(a.begin(), a.end(), P(r, 1)) - a.begin();

		// 末尾に追加する
		g[l].emplace_back(r, i + 1);
		g[r].emplace_back(l, i + 1);
	}

	// 位置数分ループ
	rep(i, n + 1) {
		// もう使われてるときは次へ
		if (used[i]) {
			continue;
		}

		// dfs処理
		if (dfs(i)) {
			cout << -1 << endl;
			return 0;
		}
	}

	// ソート
	sort(ans.begin(), ans.end());

	// 答え出力
	cout << ans.size() << endl;
	rep(i, ans.size()) {
		printf("%d ", ans[i]);
	}
	cout << endl;

	return(0);
}


Measured memory_bytes: 15228