#include <bits/stdc++.h>
using namespace std;
const int N = 201000;
int n, a[N], b[N], c[N], d[N], e[N], dis[N], vis[N], pre[N], q[N];
vector<int> vx;
vector<int> vy;
vector<int> dd;
set<pair<int, int> > cc[N];
void modify(int x, pair<int, int> s) {
  for (; x < N; x += x & -x) {
    cc[x].insert(s);
  }
}
void query(int x, int v) {
  dd.clear();
  for (; x != 0; x -= x & -x) {
    while (true) {
      auto it = cc[x].lower_bound({v, -1});
      if (it == cc[x].end()) {
        break;
      }
      dd.push_back(it->second);
      cc[x].erase(it);
    }
  }
}
void print(int u) {
  printf("%d\n", dis[u] + 1);
  for (; u != -1; u = pre[u]) {
    printf("%d%c", u + 1, pre[u] == -1 ? '\n' : ' ');
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d %d %d %d", &a[i], &b[i], &c[i], &d[i]);
    vx.push_back(a[i]);
    vx.push_back(c[i]);
    vy.push_back(b[i]);
    vy.push_back(d[i]);
  }
  sort(vx.begin(), vx.end());
  sort(vy.begin(), vy.end());
  if (vx[0] != 0 || vy[0] != 0) {
    puts("-1");
    exit(0);
  }
  vis[n - 1] = 1;
  q[0] = n - 1;
  pre[n - 1] = -1;
  for (int i = 0; i < n; i++) {
    e[i] = vx.size() - (lower_bound(vx.begin(), vx.end(), a[i]) - vx.begin());
    c[i] = vx.size() - (lower_bound(vx.begin(), vx.end(), c[i]) - vx.begin());
    modify(c[i], {d[i], i});
  }
  for (int i = 0, t = 1; i < t; i++) {
    int u = q[i];
    if (a[u] == 0 && b[u] == 0) {
      print(u);
      exit(0);
    }
    query(e[u], b[u]);
    for (auto v : dd) {
      if (vis[v] == 1) {
        continue;
      }
      dis[v] = dis[u] + 1;
      vis[v] = 1;
      pre[v] = u;
      q[t++] = v;
    }
  }
  puts("-1");
  return 0;
}
