#include <bits/stdc++.h>
using namespace std;
void OUT_TST(string s, istream_iterator<string> it) { cerr << s; }
template <typename T, typename... Args>
void OUT_TST(string s, istream_iterator<string> it, T a, Args... args) {
  cerr << *it << "=" << a << " ";
  OUT_TST(s, ++it, args...);
}
template <class T>
void rd(T& ret) {
  ret = 0;
  bool ok = 0, u = 0;
  for (;;) {
    int c = getchar();
    if (c >= '0' && c <= '9')
      ret = (ret << 3) + (ret << 1) + c - '0', ok = 1;
    else if (c == '-')
      u = 1;
    else if (ok) {
      if (u) ret *= -1;
      return;
    }
  }
}
long long powmod(long long p, long long n, long long mod) {
  long long ret = 1;
  for (; n; n >>= 1) {
    if (n & 1) ret = ret * p % mod;
    p = p * p % mod;
  }
  return ret;
}
template <class T>
bool chmin(T& a, const T& b) {
  return b < a ? a = b, 1 : 0;
}
template <class T>
bool chmax(T& a, const T& b) {
  return b > a ? a = b, 1 : 0;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
const int N = (int)3e5 + 9;
int n, m;
set<pair<int, int>> st[N];
void update(int first, pair<int, int> val) {
  first += 1;
  for (; first <= m; first += first & (-first)) st[first].insert(val);
}
void query(vector<int>& dd, int first, int second) {
  dd.clear();
  first += 1;
  for (; first; first -= first & (-first)) {
    while (!st[first].empty() && st[first].begin()->first <= second) {
      dd.push_back(st[first].begin()->second);
      st[first].erase(st[first].begin());
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(nullptr);
  cin >> n;
  vector<int> an(n), bn(n), cn(n), dn(n);
  for (int i = 0; i < n; ++i) {
    cin >> an[i] >> bn[i] >> cn[i] >> dn[i];
  }
  vector<int> xn;
  merge(an.begin(), an.end(), cn.begin(), cn.end(), std::back_inserter(xn));
  sort(xn.begin(), xn.end());
  m = ((int)(xn).size());
  if (xn[0] != 0) {
    puts("-1");
    return 0;
  }
  for (int i = 0; i < n; ++i) {
    an[i] = lower_bound(xn.begin(), xn.end(), an[i]) - xn.begin();
    cn[i] = lower_bound(xn.begin(), xn.end(), cn[i]) - xn.begin();
  }
  for (int i = 0; i < n; ++i) {
    update(an[i], pair<int, int>(bn[i], i));
  }
  queue<int> q;
  vector<int> dis(n), pre(n);
  vector<bool> vis(n, false);
  for (int i = 0; i < n; ++i) {
    if (an[i] == 0 && bn[i] == 0) {
      q.push(i);
      dis[i] = 1;
      vis[i] = true;
      pre[i] = -1;
    }
  }
  auto output = [&](int u) {
    cout << dis[u] << endl;
    int top = dis[u];
    vector<int> ans(top);
    for (int i = 0; i < top; ++i) {
      ans[i] = u;
      u = pre[u];
    }
    for (int i = top - 1; i >= 0; --i) {
      cout << ans[i] + 1;
      if (i) cout << " ";
    }
    cout << "\n";
  };
  vector<int> dd;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    if (u == n - 1) {
      output(u);
      return 0;
    }
    query(dd, cn[u], dn[u]);
    for (int v : dd) {
      if (vis[v]) continue;
      dis[v] = dis[u] + 1;
      pre[v] = u;
      vis[v] = true;
      q.push(v);
    }
  }
  puts("-1");
  return 0;
}
