#include <bits/stdc++.h>
using namespace std;
const pair<long long int, long long int> INF = {2e9, 2e9};
struct MinTree {
  MinTree(const vector<pair<long long int, long long int>>& init) {
    n = (int)(init).size();
    bound = 1;
    while (bound < n) bound *= 2;
    t = vector<pair<long long int, long long int>>(2 * bound);
    for (int i = (0); i <= (n - 1); ++i) t[bound + i] = init[i];
    for (int i = (n); i <= (bound - 1); ++i) t[bound + i] = INF;
    for (int i = (bound - 1); i >= (0); --i) t[i] = min(t[2 * i], t[2 * i + 1]);
  }
  pair<long long int, long long int> query(int l, int r) {
    l += bound;
    r += bound;
    pair<long long int, long long int> res = INF;
    while (l <= r) {
      if (l % 2 == 1) {
        res = min(res, t[l++]);
      }
      if (r % 2 == 0) {
        res = min(res, t[r--]);
      }
      l /= 2;
      r /= 2;
    }
    return res;
  }
  void replace(int i, pair<long long int, long long int> elm) {
    i += bound;
    t[i] = elm;
    i /= 2;
    while (i > 0) {
      t[i] = min(t[2 * i], t[2 * i + 1]);
      i /= 2;
    }
  }
  vector<pair<long long int, long long int>> t;
  int n, bound;
};
struct Card {
  long long int x1, y1, x2, y2;
};
int main() {
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  vector<Card> cards;
  map<pair<long long int, long long int>, vector<int>> ind;
  map<pair<long long int, long long int>, int> dist;
  map<pair<long long int, long long int>, int> prv;
  unordered_map<int, int> coord;
  vector<int> cVec;
  for (int i = 0; i < (n); ++i) {
    long long int a, b, c, d;
    cin >> a >> b >> c >> d;
    cards.push_back({a, b, c, d});
    cVec.push_back(a);
    cVec.push_back(c);
  }
  cVec.push_back(0);
  sort((cVec).begin(), (cVec).end());
  cVec.resize(unique((cVec).begin(), (cVec).end()) - cVec.begin());
  for (int i = 0; i < (int)(cVec).size(); i++) {
    coord[cVec[i]] = i;
  }
  const int c = (int)(cVec).size();
  vector<pair<long long int, long long int>> treeInit(c);
  vector<vector<long long int>> vert(c);
  for (int i = 0; i < (n); ++i) {
    auto& card = cards[i];
    card.x1 = coord[card.x1];
    card.x2 = coord[card.x2];
    ind[make_pair(card.y1, card.x1)].push_back(i);
    vert[card.x1].push_back(card.y1);
  }
  for (int i = 0; i < (c); ++i) {
    sort((vert[i]).begin(), (vert[i]).end(), greater<long long int>());
    vert[i].resize(unique((vert[i]).begin(), (vert[i]).end()) -
                   vert[i].begin());
    treeInit[i] = (vert[i].empty() ? INF : make_pair(vert[i].back(), 1LL * i));
  }
  MinTree tree(treeInit);
  queue<pair<long long int, long long int>> q;
  q.push({0, 0});
  if (!vert[0].empty()) {
    vert[0].pop_back();
    tree.replace(0, (vert[0].empty() ? INF : make_pair(vert[0].back(), 0LL)));
  }
  while (!q.empty()) {
    pair<long long int, long long int> p = q.front();
    q.pop();
    for (int x : ind[p]) {
      if (x == n - 1) {
        vector<int> res = {x};
        int it = x;
        while (cards[it].x1 != 0 || cards[it].y1 != 0) {
          it = prv[make_pair(cards[it].y1, cards[it].x1)];
          res.push_back(it);
        }
        assert(dist[p] + 1 == (int)(res).size());
        cout << (dist[p] + 1) << endl;
        for (int i = ((int)(res).size() - 1); i >= (0); --i)
          cout << (res[i] + 1) << ' ';
        cout << endl;
        return 0;
      }
      pair<long long int, long long int> dest =
          make_pair(cards[x].y2, cards[x].x2);
      pair<long long int, long long int> ans;
      while ((ans = tree.query(0, dest.second)).first <= dest.first) {
        dist[ans] = dist[p] + 1;
        prv[ans] = x;
        q.push(ans);
        vert[ans.second].pop_back();
        pair<long long int, long long int> toInsert =
            (vert[ans.second].empty()
                 ? INF
                 : make_pair(vert[ans.second].back(), ans.second));
        tree.replace(ans.second, toInsert);
      }
    }
  }
  cout << "-1\n";
  return 0;
}
