macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        m: usize,
        mut v: [(usize, usize); n],
        cs: [(usize, usize); m],
    }
    v.sort_by_key(|x| x.0);
    let mut w = vec![0; n + 1];
    if v[0].1 == 1 {
        w[0] = 1;
    }
    for i in 1..n {
        if v[i - 1].1 != v[i].1 {
            w[i] = 1;
        }
    }
    if v[n - 1].1 == 1 {
        w[n] = 1;
    }
    let mut g = vec![vec![]; n + 1];
    for i in 0..m {
        let a = match v.binary_search_by_key(&(cs[i].0 - 1), |x| x.0) {Ok(j) => j + 1, Err(j) => j};
        let b = match v.binary_search_by_key(&cs[i].1, |x| x.0) {Ok(j) => j + 1, Err(j) => j};
        g[a].push((b, i + 1));
        g[b].push((a, i + 1));
    }
    let mut ans: Vec<usize> = vec![];
    let mut done = vec![false; n + 1];
    for i in 0..n + 1 {
        if done[i] {
            continue;
        }
        if dfs(i, &g, &w, &mut done, &mut ans) % 2 != 0 {
            println!("-1");
            return;
        }
    }
    if ans.len() == 0 {
        println!("0");
        return;
    }
    ans.sort();
    println!("{}", ans.len());
    print!("{}", ans[0]);
    for i in 1..ans.len() {
        print!(" {}", ans[i]);
    }
    println!("");
}

fn dfs(r: usize, g: &Vec<Vec<(usize, usize)>>, w: &Vec<usize>, done: &mut Vec<bool>, ans: &mut Vec<usize>) -> usize {
    let mut ret = w[r];
    done[r] = true;
    for &(v, i) in &g[r] {
        if done[v] {
            continue;
        }
        let sub = dfs(v, g, w, done, ans);
        if sub % 2 == 1 {
            ans.push(i);
        }
        ret += sub;
    }
    ret
}


Measured memory_bytes: 32508