#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:1024000000,1024000000")
int _MAX(int a, int b) { return a > b ? a : b; }
int _MIN(int a, int b) { return a > b ? b : a; }
int Scan() {
  int res = 0, flag = 0;
  char ch;
  if ((ch = getchar()) == '-')
    flag = 1;
  else if (ch >= '0' && ch <= '9')
    res = ch - '0';
  while ((ch = getchar()) >= '0' && ch <= '9') res = res * 10 + (ch - '0');
  return flag ? -res : res;
}
void Out(int a) {
  if (a < 0) {
    putchar('-');
    a = -a;
  }
  if (a >= 10) Out(a / 10);
  putchar(a % 10 + '0');
}
const int N = 201000;
set<pair<int, int> > cc[N];
queue<int> q;
int a[N][4], lis[N], vis[N], pre[N], tot, cnt = 1;
vector<int> vx;
void add(int x, pair<int, int> m) {
  while (x <= cnt) cc[x].insert(m), x += ((x) & (-x));
}
void query(int x, int y) {
  vx.clear();
  while (x) {
    while (1) {
      set<pair<int, int> >::iterator it = cc[x].lower_bound(make_pair(y, -1));
      if (it == cc[x].end()) break;
      vx.push_back(it->second);
      cc[x].erase(it);
    }
    x -= ((x) & (-x));
  }
}
void Print(int x) {
  if (x == 0) return;
  Print(pre[x]);
  printf("%d ", x);
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i)
    scanf("%d%d%d%d", &a[i][0], &a[i][1], &a[i][2], &a[i][3]),
        lis[++tot] = a[i][0], lis[++tot] = a[i][2];
  sort(lis + 1, lis + tot + 1);
  for (int i = 2; i <= tot; ++i)
    if (lis[i] != lis[i - 1]) lis[++cnt] = lis[i];
  for (int i = 1; i <= n; ++i) {
    int t = lower_bound(lis + 1, lis + cnt + 1, a[i][0]) - lis;
    add(t, make_pair(1000000000 - a[i][1], i));
    if (a[i][0] == 0 && a[i][1] == 0) q.push(i), vis[i] = 1;
  }
  while (!q.empty()) {
    int t = q.front();
    q.pop();
    int c = lower_bound(lis + 1, lis + cnt + 1, a[t][2]) - lis;
    query(c, 1000000000 - a[t][3]);
    int siz = vx.size();
    for (int i = 0; i < siz; ++i)
      if (vis[vx[i]] == 0)
        vis[vx[i]] = vis[t] + 1, pre[vx[i]] = t, q.push(vx[i]);
  }
  if (vis[n] == 0)
    puts("-1");
  else {
    printf("%d\n", vis[n]);
    Print(n);
    putchar('\n');
  }
  return 0;
}
