#include <iostream>
#include <algorithm>
#include <utility>
#include <numeric>
#include <vector>
#include <array>
#include <map>

template <class T, class U>
inline bool chmin(T &lhs, const U &rhs) {
  if (lhs > rhs) { lhs = rhs; return true; }
  return false;
}

template <class T, class U>
inline bool chmax(T &lhs, const U &rhs) {
  if (lhs < rhs) { lhs = rhs; return true; }
  return false;
}

struct range {
  using itr = int64_t;
  struct iterator {
    itr i;
    constexpr iterator(itr i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr itr operator * () const { return i; }
    constexpr bool operator != (iterator x) const { return i != x.i; }
  };
  const iterator l, r;
  constexpr range(itr l_, itr r_): l(l_), r(std::max(l_, r_)) { }
  constexpr iterator begin() const { return l; }
  constexpr iterator end() const { return r; }
};

struct revrange {
  using itr = int64_t;
  struct iterator {
    itr i;
    constexpr iterator(itr i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr itr operator * () const { return i; }
    constexpr bool operator != (iterator x) const { return i != x.i; }
  };
  const iterator l, r;
  constexpr revrange(itr l_, itr r_): l(l_ - 1), r(std::max(l_, r_) - 1) { }
  constexpr iterator begin() const { return r; }
  constexpr iterator end() const { return l; }
};

using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;

constexpr i32 inf32 = (i32(1) << 30) - 1;
constexpr i64 inf64 = (i64(1) << 62) - 1;

template <class T>
struct fix_point: private T {
  explicit constexpr fix_point(T &&func): T(std::forward<T>(func)) { }
  template <class... Args>
  constexpr decltype(auto) operator () (Args &&... args) const {
    return T::operator()(*this, std::forward<Args>(args)...);
  }
};

template <class T>
constexpr decltype(auto) make_fix_point(T &&func) {
  return fix_point<T>{std::forward<T>(func)};
}

int main() {
  size_t N, M;
  std::cin >> N >> M;
  std::vector<std::pair<i32, i32>> lamp(N);
  for (auto i: range(0, N)) {
    std::cin >> lamp[i].first >> lamp[i].second;
  }
  std::vector<i32> L(M), R(M);
  for (auto i: range(0, M)) {
    std::cin >> L[i] >> R[i];
  }
  std::sort(lamp.begin(), lamp.end());
  std::vector<i32> A(N), B(N);
  for (auto i: range(0, N)) {
    A[i] = lamp[i].first;
    B[i] = lamp[i].second;
  }
  for (auto &x: L) {
    x = std::lower_bound(A.cbegin(), A.cend(), x) - A.cbegin();
  }
  for (auto &x: R) {
    x = std::upper_bound(A.cbegin(), A.cend(), x) - A.cbegin();
  }
  std::vector<std::vector<i32>> graph(N + 1);
  std::vector<i32> cur(N + 1);
  cur.front() = B.front();
  cur.back() = B.back();
  for (auto i: range(1, N)) {
    cur[i] = B[i - 1] ^ B[i];
  }
  for (auto i: range(0, M)) {
    if (L[i] == R[i]) continue;
    graph[L[i]].push_back(R[i]);
    graph[R[i]].push_back(L[i]);
  }
  std::map<std::pair<i32, i32>, i32> map;
  for (auto i: range(0, M)) {
    map[std::minmax(L[i], R[i])] = i;
  }
  std::vector<bool> visited(N);
  std::vector<bool> use(M);
  auto dfs = make_fix_point([&](auto dfs, i32 u, i32 p) -> void {
    if (p != -1) {
      use[map[std::minmax(u, p)]] = true;
      cur[u] ^= 1;
      cur[p] ^= 1;
    }
    visited[u] = true;
    for (auto v: graph[u]) {
      if (!visited[v]) {
        dfs(v, u);
      }
    }
    if (cur[u] && p == -1) {
      std::cout << "-1\n";
      std::exit(EXIT_SUCCESS);
    }
    if (cur[u]) {
      use[map[std::minmax(u, p)]] = false;
      cur[u] ^= 1;
      cur[p] ^= 1;
    }
  });
  for (auto i: range(0, N)) {
    if (!visited[i]) {
      dfs(i, -1);
    }
  }
  std::vector<i32> ans;
  for (auto i: range(0, M)) {
    if (use[i]) {
      ans.push_back(i + 1);
    }
  }
  std::cout << ans.size() << '\n';
  for (auto i: range(0, ans.size())) {
    std::cout << ans[i] << (i + 1 == ans.size() ? '\n' : ' ');
  }
  return 0;
}


Measured memory_bytes: 33276