#include <bits/stdc++.h>
using namespace std;
int inline read() {
  int num = 0, neg = 1;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') neg = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    num = (num << 3) + (num << 1) + c - '0';
    c = getchar();
  }
  return num * neg;
}
const int maxn = 400010, mod = 998244353;
int n, a[maxn], b[maxn], c[maxn], d[maxn];
int cnt1, cnt2, tmpx[maxn], tmpy[maxn];
set<pair<int, int> > s[maxn];
void update(int x, int y, int z, int op) {
  for (int i = x; i <= cnt1 + 1; i += i & (-i))
    if (op)
      s[i].insert(make_pair(y, z));
    else
      s[i].erase(make_pair(y, z));
}
int dis[maxn], pre[maxn], sta[maxn], tp;
queue<int> que;
set<pair<int, int> >::iterator it;
void bfs() {
  for (int i = 1; i <= n; i++)
    if (tmpx[a[i]] <= 0 && tmpy[b[i]] <= 0) {
      dis[i] = 1;
      que.push(i);
      update(a[i], b[i], i, 0);
    }
  while (!que.empty()) {
    int x = que.front();
    que.pop();
    for (int i = c[x]; i; i -= i & (-i)) {
      if (!s[i].size()) continue;
      it = s[i].begin();
      pair<int, int> now = *it;
      tp = 0;
      while (now.first <= d[x]) {
        dis[now.second] = dis[x] + 1;
        pre[now.second] = x;
        sta[++tp] = now.second;
        que.push(now.second);
        it++;
        if (it != s[i].end())
          now = *it;
        else
          break;
      }
      while (tp) {
        update(a[sta[tp]], b[sta[tp]], sta[tp], 0);
        tp--;
      }
    }
  }
  if (dis[n] == 0) {
    printf("-1");
    return;
  } else
    printf("%d\n", dis[n]);
  int now = n;
  tp = 0;
  while (now) {
    sta[++tp] = now;
    now = pre[now];
  }
  while (tp) printf("%d ", sta[tp]), tp--;
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++) {
    a[i] = read();
    b[i] = read();
    c[i] = read();
    d[i] = read();
    tmpx[++cnt1] = a[i];
    tmpx[++cnt1] = c[i];
    tmpy[++cnt2] = b[i];
    tmpy[++cnt2] = d[i];
  }
  sort(tmpx + 1, tmpx + cnt1 + 1);
  sort(tmpy + 1, tmpy + cnt2 + 1);
  cnt1 = unique(tmpx + 1, tmpx + cnt1 + 1) - tmpx - 1;
  cnt2 = unique(tmpy + 1, tmpy + cnt2 + 1) - tmpy - 1;
  for (int i = 1; i <= n; i++) {
    a[i] = lower_bound(tmpx + 1, tmpx + cnt1 + 1, a[i]) - tmpx;
    b[i] = lower_bound(tmpy + 1, tmpy + cnt2 + 1, b[i]) - tmpy;
    c[i] = lower_bound(tmpx + 1, tmpx + cnt1 + 1, c[i]) - tmpx;
    d[i] = lower_bound(tmpy + 1, tmpy + cnt2 + 1, d[i]) - tmpy;
  }
  for (int i = 1; i <= n; i++) update(a[i], b[i], i, 1);
  bfs();
  return 0;
}

### Prompt

Develop a solution in Cpp to the problem described below:

You are playing a board card game. In this game the player has two characteristics, x and y — the white magic skill and the black magic skill, respectively. There are n spell cards lying on the table, each of them has four characteristics, ai, bi, ci and di. In one move a player can pick one of the cards and cast the spell written on it, but only if first two of it's characteristics meet the requirement ai ≤ x and bi ≤ y, i.e. if the player has enough magic skill to cast this spell. However, after casting the spell the characteristics of a player change and become equal to x = ci and y = di.

At the beginning of the game both characteristics of a player are equal to zero. The goal of the game is to cast the n-th spell. Your task is to make it in as few moves as possible. You are allowed to use spell in any order and any number of times (for example, you may not use some spells at all).

Input

The first line of the input contains a single integer n (1 ≤ n ≤ 100 000) — the number of cards on the table.

Each of the next n lines contains four integers ai, bi, ci, di (0 ≤ ai, bi, ci, di ≤ 109) — the characteristics of the corresponding card.

Output

In the first line print a single integer k — the minimum number of moves needed to cast the n-th spell and in the second line print k numbers — the indices of the cards in the order in which you should cast them. In case there are multiple possible solutions, print any of them.

If it is impossible to cast the n-th spell, print  - 1.

Examples

Input

4
0 0 3 4
2 2 5 3
4 1 1 7
5 3 8 8


Output

3
1 2 4


Input

2
0 0 4 6
5 1 1000000000 1000000000


Output

-1

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int inline read() {
  int num = 0, neg = 1;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') neg = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    num = (num << 3) + (num << 1) + c - '0';
    c = getchar();
  }
  return num * neg;
}
const int maxn = 400010, mod = 998244353;
int n, a[maxn], b[maxn], c[maxn], d[maxn];
int cnt1, cnt2, tmpx[maxn], tmpy[maxn];
set<pair<int, int> > s[maxn];
void update(int x, int y, int z, int op) {
  for (int i = x; i <= cnt1 + 1; i += i & (-i))
    if (op)
      s[i].insert(make_pair(y, z));
    else
      s[i].erase(make_pair(y, z));
}
int dis[maxn], pre[maxn], sta[maxn], tp;
queue<int> que;
set<pair<int, int> >::iterator it;
void bfs() {
  for (int i = 1; i <= n; i++)
    if (tmpx[a[i]] <= 0 && tmpy[b[i]] <= 0) {
      dis[i] = 1;
      que.push(i);
      update(a[i], b[i], i, 0);
    }
  while (!que.empty()) {
    int x = que.front();
    que.pop();
    for (int i = c[x]; i; i -= i & (-i)) {
      if (!s[i].size()) continue;
      it = s[i].begin();
      pair<int, int> now = *it;
      tp = 0;
      while (now.first <= d[x]) {
        dis[now.second] = dis[x] + 1;
        pre[now.second] = x;
        sta[++tp] = now.second;
        que.push(now.second);
        it++;
        if (it != s[i].end())
          now = *it;
        else
          break;
      }
      while (tp) {
        update(a[sta[tp]], b[sta[tp]], sta[tp], 0);
        tp--;
      }
    }
  }
  if (dis[n] == 0) {
    printf("-1");
    return;
  } else
    printf("%d\n", dis[n]);
  int now = n;
  tp = 0;
  while (now) {
    sta[++tp] = now;
    now = pre[now];
  }
  while (tp) printf("%d ", sta[tp]), tp--;
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++) {
    a[i] = read();
    b[i] = read();
    c[i] = read();
    d[i] = read();
    tmpx[++cnt1] = a[i];
    tmpx[++cnt1] = c[i];
    tmpy[++cnt2] = b[i];
    tmpy[++cnt2] = d[i];
  }
  sort(tmpx + 1, tmpx + cnt1 + 1);
  sort(tmpy + 1, tmpy + cnt2 + 1);
  cnt1 = unique(tmpx + 1, tmpx + cnt1 + 1) - tmpx - 1;
  cnt2 = unique(tmpy + 1, tmpy + cnt2 + 1) - tmpy - 1;
  for (int i = 1; i <= n; i++) {
    a[i] = lower_bound(tmpx + 1, tmpx + cnt1 + 1, a[i]) - tmpx;
    b[i] = lower_bound(tmpy + 1, tmpy + cnt2 + 1, b[i]) - tmpy;
    c[i] = lower_bound(tmpx + 1, tmpx + cnt1 + 1, c[i]) - tmpx;
    d[i] = lower_bound(tmpy + 1, tmpy + cnt2 + 1, d[i]) - tmpy;
  }
  for (int i = 1; i <= n; i++) update(a[i], b[i], i, 1);
  bfs();
  return 0;
}

```