#include <bits/stdc++.h>
using namespace std;
const int MAX = 2e5 + 5;
struct q {
  int a, b, c, d;
} point[MAX];
struct v {
  int x, id;
  bool operator<(const v &a) const { return x < a.x; }
} A[MAX];
int n, id1, qvq;
int pre[MAX], W[MAX], d[MAX];
bool use[MAX];
set<pair<int, int> > s[MAX];
set<pair<int, int> >::iterator _A;
vector<int> vec;
queue<int> qu;
int read() {
  int x(0);
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    ;
  for (; isdigit(ch); x = x * 10 + ch - 48, ch = getchar())
    ;
  return x;
}
int lowbit(int x) { return x & -x; }
void ask(int x, int dis) {
  vec.clear();
  for (int i = x; i; i -= lowbit(i))
    while (1) {
      _A = s[i].lower_bound(make_pair(dis, 0));
      if (_A == s[i].end()) break;
      vec.push_back((*_A).second), s[i].erase(_A);
    }
}
void change(int x, pair<int, int> A) {
  for (int i = x; i <= qvq; i += lowbit(i)) s[i].insert(A);
}
int main() {
  n = read();
  for (int i = 1; i <= n; ++i)
    A[++qvq] = (v){point[i].a = W[i] = read(), i}, point[i].b = read(),
    A[++qvq] = (v){point[i].c = read(), i}, point[i].d = read();
  sort(A + 1, A + 1 + qvq), A[0].x = -1;
  for (int i = 1; i <= qvq; ++i) {
    if (A[i].x != A[i - 1].x) ++id1;
    if (point[A[i].id].a == A[i].x) point[A[i].id].a = qvq - id1 + 1;
    if (point[A[i].id].c == A[i].x) point[A[i].id].c = qvq - id1 + 1;
  }
  for (int i = 1; i <= n; ++i) change(point[i].c, make_pair(point[i].d, i));
  qu.push(n);
  while (!qu.empty()) {
    int tt = qu.front();
    qu.pop();
    if (!W[tt] && !point[tt].b) {
      printf("%d\n", d[tt] + 1);
      while (tt != n) printf("%d ", tt), tt = pre[tt];
      return printf("%d", tt), 0;
    }
    ask(point[tt].a, point[tt].b);
    for (int i = 0, cnt = vec.size(); i < cnt; ++i)
      if (!use[vec[i]])
        use[vec[i]] = 1, d[vec[i]] = d[tt] + 1, pre[vec[i]] = tt,
        qu.push(vec[i]);
  }
  return printf("-1"), 0;
}
