#include <bits/stdc++.h>
int jy[100010 * 4], tr[100010 * 4], q[100010 * 4], pre[100010 * 4],
    f[100010 * 4];
using namespace std;
struct W {
  int a;
  int b;
  int c;
  int d;
  int rk;
} a[100010];
int lf;
int cmp(const W& a, const W& b) { return a.c < b.c; }
void update(int p, int l, int r, int x, int w) {
  if (x < l || x > r) return;
  if (l == r) {
    tr[p] = w;
    return;
  }
  int mid = (l + r) / 2;
  update(p * 2, l, mid, x, w);
  update(p * 2 + 1, mid + 1, r, x, w);
  tr[p] = max(tr[p * 2], tr[p * 2 + 1]);
}
void query(int p, int l, int r, int x, int y, int w) {
  if (x > r || y < l || tr[p] < w || lf) return;
  if (l == r) {
    lf = l;
    return;
  }
  int mid = (l + r) / 2;
  query(p * 2, l, mid, x, y, w);
  query(p * 2 + 1, mid + 1, r, x, y, w);
}
int main() {
  int i, j, m, n, x, y, s, t, k, h;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d%d%d%d", &a[i].a, &a[i].b, &a[i].c, &a[i].d);
    a[i].rk = i;
  }
  sort(a + 1, a + n + 1, cmp);
  for (i = 1; i <= n; i++) jy[i] = a[i].c;
  h = 0;
  t = 1;
  for (i = 1; i <= n; i++) {
    if (a[i].rk == n) q[1] = i, f[i] = 1, a[i].d = -1, pre[i] = 0;
    update(1, 1, n, i, a[i].d);
  }
  while (h < t) {
    x = q[++h];
    if (a[x].a == 0 && a[x].b == 0) {
      printf("%d\n", f[x]);
      for (; x; x = pre[x]) printf("%d ", a[x].rk);
      return 0;
    }
    y = lower_bound(jy + 1, jy + n + 1, a[x].a) - jy;
    for (; y <= n; y = lf + 1) {
      lf = 0;
      query(1, 1, n, y, n, a[x].b);
      if (lf == 0) break;
      t++;
      q[t] = lf;
      f[lf] = f[x] + 1;
      pre[lf] = x;
      update(1, 1, n, lf, -1);
    }
  }
  printf("-1");
}
