#include <bits/stdc++.h>
using namespace std;
const int N = 300010;
queue<pair<pair<int, int>, int> > Q;
struct recc {
  int a, b, c, d, e;
};
int n;
int f[N], g[N];
pair<int, int> t[N * 4];
recc a[N];
void print(int n) {
  if (f[n] != 0) print(g[n]);
  printf("%d ", a[n].e);
}
void build(int i, int l, int r) {
  int mid = (l + r) >> 1;
  if (l == r) {
    t[i] = make_pair(a[l].b, l);
    return;
  }
  build(i * 2, l, mid);
  build(i * 2 + 1, mid + 1, r);
  t[i] = min(t[i * 2], t[i * 2 + 1]);
}
void change(int i, int l, int r, int k) {
  if (l == r) {
    t[i] = make_pair(2000000000, 0);
    return;
  }
  int mid = (l + r) >> 1;
  if (k <= mid) change(i * 2, l, mid, k);
  if (k > mid) change(i * 2 + 1, mid + 1, r, k);
  t[i] = min(t[i * 2], t[i * 2 + 1]);
}
pair<int, int> query(int i, int l, int r, int ll, int rr) {
  if (ll <= l && r <= rr) return t[i];
  int mid = (l + r) >> 1;
  pair<int, int> res = make_pair(2000000000, 0);
  if (ll <= mid) res = min(res, query(i * 2, l, mid, ll, rr));
  if (rr > mid) res = min(res, query(i * 2 + 1, mid + 1, r, ll, rr));
  return res;
}
int cmp(recc a, recc b) { return a.a < b.a || (a.a == b.a && a.b < b.b); }
int find(int p) {
  int l = 1, r = n;
  while (l < r) {
    int mid = (l + r + 1) >> 1;
    if (a[mid].a <= p)
      l = mid;
    else
      r = mid - 1;
  }
  return l;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    scanf("%d%d%d%d", &a[i].a, &a[i].b, &a[i].c, &a[i].d), a[i].e = i;
  int tmpx = a[n].a, tmpy = a[n].b;
  sort(a + 1, a + 1 + n, cmp);
  build(1, 1, n);
  for (int i = 1; i <= n; i++) f[i] = -1;
  for (int i = 1; i <= n; i++)
    if (a[i].a == 0 && a[i].b == 0)
      Q.push(make_pair(make_pair(a[i].c, a[i].d), i)), f[i] = 0,
                                                       change(1, 1, n, i);
  while (!Q.empty()) {
    pair<pair<int, int>, int> tmp = Q.front();
    Q.pop();
    int r = find(tmp.first.first);
    while (1) {
      pair<int, int> now = query(1, 1, n, 1, r);
      if (now.first <= tmp.first.second) {
        change(1, 1, n, now.second);
        Q.push(
            make_pair(make_pair(a[now.second].c, a[now.second].d), now.second));
        f[now.second] = f[tmp.second] + 1;
        g[now.second] = tmp.second;
      } else
        break;
    }
  }
  int aim = 0;
  for (int i = 1; i <= n; i++)
    if (a[i].e == n) aim = i;
  if (f[aim] == -1) {
    printf("-1\n");
    return 0;
  }
  printf("%d\n", f[aim] + 1);
  print(aim);
  return 0;
}
