#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010;
int n, m, cnt = 0;
int a[maxn], b[maxn], c[maxn], d[maxn], tmp[maxn];
int X[maxn << 1];
vector<int> V;
set<pair<int, int> > S[maxn << 1];
bool vis[maxn];
int fa[maxn], dep[maxn], Q[maxn];
void read(int &num) {
  num = 0;
  char ch = getchar();
  while (ch < '!') ch = getchar();
  while (ch >= '0' && ch <= '9') num = num * 10 + ch - '0', ch = getchar();
}
int Get_pos(int v) {
  int L = 1, R = m;
  while (L < R) {
    int mid = (L + R) >> 1;
    if (X[mid] < v)
      L = mid + 1;
    else
      R = mid;
  }
  return R;
}
int lowbit(int x) { return x & (-x); }
void add(int x, pair<int, int> v) {
  for (int i = x; i >= 1; i -= lowbit(i)) S[i].insert(v);
}
void ask(int x, int v) {
  V.clear();
  for (int i = x; i <= m; i += lowbit(i)) {
    while (true) {
      set<pair<int, int> >::iterator it = S[i].lower_bound(make_pair(v, -1));
      if (it == S[i].end()) break;
      V.push_back(it->second);
      S[i].erase(it);
    }
  }
  return;
}
void Get_print(int u) {
  printf("%d ", u);
  if (u == n) return;
  Get_print(fa[u]);
}
void print(int n) {
  printf("%d\n", dep[n] + 1);
  Get_print(n);
}
int main() {
  read(n);
  bool flag = false;
  for (int i = 1; i <= n; ++i) {
    read(a[i]);
    read(b[i]);
    read(c[i]);
    read(d[i]);
    if (a[i] == 0 && b[i] == 0) flag = true;
    X[++cnt] = a[i];
    X[++cnt] = c[i];
  }
  sort(X + 1, X + cnt + 1);
  m = unique(X + 1, X + cnt + 1) - X - 1;
  if (!flag) {
    printf("-1\n");
    return 0;
  }
  for (int i = 1; i <= n; ++i) {
    c[i] = Get_pos(c[i]);
    tmp[i] = Get_pos(a[i]);
    add(c[i], make_pair(d[i], i));
  }
  int t = 1;
  Q[1] = n;
  for (int i = 1; i <= t; ++i) {
    int now = Q[i];
    if (a[now] == 0 && b[now] == 0) {
      print(now);
      return 0;
    }
    ask(tmp[now], b[now]);
    int sz = V.size();
    for (int j = 0; j < sz; ++j) {
      int cur = V[j];
      if (vis[cur]) continue;
      vis[cur] = true;
      dep[cur] = dep[now] + 1;
      fa[cur] = now;
      Q[++t] = cur;
    }
  }
  printf("-1\n");
  return 0;
}
