Rectangles and Square

You are given n rectangles, labeled 1 through n. The corners of rectangles have integer coordinates and their edges are parallel to the Ox and Oy axes. The rectangles may touch each other, but they do not overlap (that is, there are no points that belong to the interior of more than one rectangle).

Your task is to determine if there’s a non-empty subset of the rectangles that forms a square. That is, determine if there exists a subset of the rectangles and some square for which every point that belongs to the interior or the border of that square belongs to the interior or the border of at least one of the rectangles in the subset, and every point that belongs to the interior or the border of at least one rectangle in the subset belongs to the interior or the border of that square.

Input

First line contains a single integer n (1 ≤ n ≤ 105) — the number of rectangles. Each of the next n lines contains a description of a rectangle, with the i-th such line describing the rectangle labeled i. Each rectangle description consists of four integers: x 1y 1x 2y 2 — coordinates of the bottom left and the top right corners (0 ≤ x 1 < x 2 ≤ 3000, 0 ≤ y 1 < y 2 ≤ 3000).

No two rectangles overlap (that is, there are no points that belong to the interior of more than one rectangle).

Output

If such a subset exists, print “YES” (without quotes) on the first line of the output file, followed by k, the number of rectangles in the subset. On the second line print k numbers — the labels of rectangles in the subset in any order. If more than one such subset exists, print any one. If no such subset exists, print “NO” (without quotes).

Examples

input

9
0 0 1 9
1 0 9 1
1 8 9 9
8 1 9 8
2 2 3 6
3 2 7 3
2 6 7 7
5 3 7 6
3 3 5 6

output

YES 5
5 6 7 8 9

input

4
0 0 1 9
1 0 9 1
1 8 9 9
8 1 9 8

output

NO

Note

The first test case looks as follows:

Note that rectangles 6, 8, and 9 form a square as well, and would be an acceptable answer.

The second test case looks as follows:

Solution:

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <memory.h>

using namespace std;

const int n = 3000;
const int N = n+10;
const int M = 100010;

int a[N][N], shcut[N][N], svcut[N][N], s[N][N];
bool hcut[N][N], vcut[N][N];
int stx[N], sty[N];
bool mark[M];
int ans[M];

int main() {
int m;
scanf("%d", &m);
for (int i=1;i<=n;i++)
    for (int j=1;j<=n;j++) a[i][j] = 0;
  for (int i=1;i<=n;i++)
    for (int j=1;j<=n;j++) hcut[i][j] = false;
  for (int i=1;i<=n;i++)
    for (int j=1;j<=n;j++) vcut[i][j] = false;
  for (int i=1;i<=m;i++) {
    int xa, ya, xb, yb;
    scanf("%d %d %d %d", &xa, &ya, &xb, &yb);
    for (int x=xa+1;x<=xb;x++)
      for (int y=ya+1;y<=yb;y++) a[x][y] = i;
    for (int x=xa+1;x<=xb-1;x++)
      for (int y=ya+1;y<=yb;y++) hcut[x][y] = true;
    for (int x=xa+1;x<=xb;x++)
      for (int y=ya+1;y<=yb-1;y++) vcut[x][y] = true;
  }
  for (int i=0;i<=n;i++) {
    shcut[i][n] = 0;
    for (int j=n-1;j>=0;j--)
if (hcut[i][j + 1]) shcut[i][j] = 0;
else shcut[i][j] = shcut[i][j+1] + 1;
}
for (int j=0;j<=n;j++) {
    svcut[n][j] = 0;
    for (int i=n-1;i>=0;i--)
if (vcut[i + 1][j]) svcut[i][j] = 0;
else svcut[i][j] = svcut[i+1][j] + 1;
}
for (int i=n+1;i>=1;i--)
for (int j=n+1;j>=1;j--)
if (i > n || j > n) s[i][j] = 0; else
if (a[i][j] == 0) s[i][j] = 0; else {
s[i][j] = s[i+1][j+1];
if (s[i][j+1] < s[i][j]) s[i][j] = s[i][j+1];
        if (s[i+1][j] < s[i][j]) s[i][j] = s[i+1][j];
        s[i][j]++;
      }
  for (int ys=1;ys<=2*n-1;ys++) {
    int e = 0;
    int x = n, y = ys;
    while (y > n) {
x--; y--;
}
while (x > 0 && y > 0) {
e++;
stx[e] = x;
sty[e] = y;
int mx = s[x][y];
if (shcut[x-1][y-1] < mx) mx = shcut[x-1][y-1];
      if (svcut[x-1][y-1] < mx) mx = svcut[x-1][y-1];
      while (e > 0 && stx[e] - x + 1 <= mx) {
        int side = stx[e] - x + 1;
        if (shcut[stx[e]][y-1] >= side && svcut[x-1][sty[e]] >= side) {
for (int i=1;i<=m;i++) mark[i] = false;
          for (int xx=x;xx<=stx[e];xx++)
            for (int yy=y;yy<=sty[e];yy++) mark[a[xx][yy]] = true;
          int ka = 0;
          for (int i=1;i<=m;i++)
            if (mark[i]) ans[ka++] = i;
          printf("YES %d\n", ka);
          for (int i=0;i<ka-1;i++) printf("%d ", ans[i]);
          printf("%d\n", ans[ka-1]);
          return 0;
        }
        else e--;
      }
      x--; y--;
    }
  }
  printf("NO\n");
  return 0;
}