Problem: Pasha is a young technician, nevertheless, he has already got a huge goal: to assemble a PC. The first task he has to become familiar with is to assemble an electric scheme.

The scheme Pasha assembled yesterday consists of several wires. Each wire is a segment that connects two points on a plane with integer coordinates within the segment [1, 10^9].

There are wires of two colors in the scheme: 

  * red wires: these wires are horizontal segments, i.e. if such a wire connects two points (x_1, y_1) and (x_2, y_2), then y_1 = y_2; 
  * blue wires: these wires are vertical segments, i.e. if such a wire connects two points (x_1, y_1) and (x_2, y_2), then x_1 = x_2. 



Note that if a wire connects a point to itself, it may be blue, and it can be red. Also, in Pasha's scheme no two wires of the same color intersect, i.e. there are no two wires of same color that have common points.

The imperfection of Pasha's scheme was that the wires were not isolated, so in the points where two wires of different colors intersect, Pasha saw sparks. Pasha wrote down all the points where he saw sparks and obtained a set of n distinct points. After that he disassembled the scheme.

Next morning Pasha looked at the set of n points where he had seen sparks and wondered how many wires had he used. Unfortunately, he does not remember that, so he wonders now what is the smallest number of wires he might have used in the scheme. Help him to determine this number and place the wires in such a way that in the resulting scheme the sparks occur in the same places.

Input

The first line contains a single integer n (1 ≤ n ≤ 1000) — the number of points where Pasha saw sparks.

Each of the next n lines contain two integers x and y (1 ≤ x, y ≤ 10^9) — the coordinates of a point with sparks. It is guaranteed that all points are distinct.

Output

Print the description of the scheme in the following format.

In the first line print h — the number of horizontal red wires (0 ≤ h). In each of the next h lines print 4 integers x_1, y_1, x_2, y_2 — the coordinates of two points (x_1, y_1) and (x_2, y_2) that are connected with this red wire. The segmenst must be horizontal, i.e. y_1 = y_2 must hold. Also, the constraint 1 ≤ x_1, y_1, x_2, y_2 ≤ 10^9 must hold.

After that print v — the number of vertical blue wires (0 ≤ v). In each of the next v lines print 4 integers x_1, y_1, x_2, y_2 — the coordinates of two points (x_1, y_1) and (x_2, y_2) that are connected with this blue wire. The segmenst must be vertical, i.e. x_1 = x_2 shomustuld hold. Also, the constraint 1 ≤ x_1, y_1, x_2, y_2 ≤ 10^9 must hold.

No two segments of the same color should have common points. The set of points where sparks appear should be the same as given in the input.

The number of segments (h + v) should be minimum possible. It's easy to see that the answer always exists. If there are multiple possible answers, print any.

Examples

Input

4
2 2
2 4
4 2
4 4


Output

2
5 2 1 2
1 4 5 4
2
2 1 2 5
4 5 4 1


Input

4
2 1
3 2
2 3
1 2


Output

4
2 1 2 1
3 2 3 2
1 2 1 2
2 3 2 3
3
1 2 1 2
3 2 3 2
2 3 2 1

Note

In the first example Pasha could have assembled the following scheme:

<image>

In this scheme there are 2 wires of each color: red ones connecting (5, 2) with (1, 2) and (1, 4) with (5, 4), blue ones connecting (2, 1) with (2, 5) and (4, 5) with (4, 1). Note that the sparks appear in the points that are described in the input, they are shown in yellow on the picture. For example, Pasha will see the spark in the point (2, 4) because the second red wire and the first blue wire intersect there. It is possible to show that we can't have less than 4 wires to produce a scheme with same sparks positions.

Solution (in JAVA):

Solution:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.BufferedWriter;
import java.util.Set;
import java.util.HashMap;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.stream.Stream;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.Collections;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author lewin
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        FElectricScheme solver = new FElectricScheme();
        solver.solve(1, in, out);
        out.close();
    }

    static class FElectricScheme {
        boolean between(int test, int lo, int high) {
            return test > lo && test < high;
        }

        boolean intersect(FElectricScheme.SegmentVer x, FElectricScheme.SegmentHor y) {
            return between(x.x, y.x1, y.x2) && between(y.y, x.y1, x.y2);
        }

        void add(HashMap<Integer, List<Integer>> mp, int key, int value) {
            List<Integer> r = mp.get(key);
            if (r == null) mp.put(key, r = new ArrayList<>());
            r.add(value);
        }

        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int n = in.nextInt();
            HashMap<Integer, List<Integer>> xmp = new HashMap<>();
            HashMap<Integer, List<Integer>> ymp = new HashMap<>();
            for (int i = 0; i < n; i++) {
                int px = in.nextInt(), py = in.nextInt();
                add(xmp, px, py);
                add(ymp, py, px);
            }
            List<FElectricScheme.SegmentVer> sx = new ArrayList<>();
            List<FElectricScheme.SegmentHor> sy = new ArrayList<>();
            xmp.forEach((k, v) -> {
                Collections.sort(v);
                for (int i = 1; i < v.size(); i++) {
                    sx.add(new FElectricScheme.SegmentVer(k, v.get(i - 1), v.get(i)));
                }
            });
            ymp.forEach((k, v) -> {
                Collections.sort(v);
                for (int i = 1; i < v.size(); i++) {
                    sy.add(new FElectricScheme.SegmentHor(k, v.get(i - 1), v.get(i)));
                }
            });
            int nnodes = sx.size() + sy.size() + 2;
            List<MaxFlowDinic.Edge>[] gg = LUtils.genArrayList(nnodes);
            for (int i = 0; i < sx.size(); i++) {
                for (int j = 0; j < sy.size(); j++) {
                    if (intersect(sx.get(i), sy.get(j))) {
                        MaxFlowDinic.addEdge(gg, i, j + sx.size(), 1);
                    }
                }
            }
            for (int i = 0; i < sx.size(); i++) MaxFlowDinic.addEdge(gg, nnodes - 1, i, 1);
            for (int j = 0; j < sy.size(); j++) MaxFlowDinic.addEdge(gg, j + sx.size(), nnodes - 2, 1);
            Set<Integer> ss = MaxFlowDinic.minCut(gg, nnodes - 1, nnodes - 2);
            boolean[] vxc = new boolean[sx.size()];
            boolean[] vyc = new boolean[sy.size()];
            for (int i = 0; i < sx.size(); i++) vxc[i] = ss.contains(i);
            for (int i = 0; i < sy.size(); i++) vyc[i] = !ss.contains(i + sx.size());
            List<FElectricScheme.SegmentVer> ax = new ArrayList<>();
            List<FElectricScheme.SegmentHor> ay = new ArrayList<>();
            int[] ptr = new int[1];
            xmp.forEach((k, v) -> {
                int start = v.get(0);
                for (int i = 1; i < v.size(); i++) {
                    if (!vxc[ptr[0]]) {
                        ax.add(new FElectricScheme.SegmentVer(k, start, sx.get(ptr[0]).y1));
                        start = sx.get(ptr[0]).y2;
                    }
                    ptr[0]++;
                }
                ax.add(new FElectricScheme.SegmentVer(k, start, v.get(v.size() - 1)));
            });
            ptr[0] = 0;
            ymp.forEach((k, v) -> {
                int start = v.get(0);
                for (int i = 1; i < v.size(); i++) {
                    if (!vyc[ptr[0]]) {
                        ay.add(new FElectricScheme.SegmentHor(k, start, sy.get(ptr[0]).x1));
                        start = sy.get(ptr[0]).x2;
                    }
                    ptr[0]++;
                }
                ay.add(new FElectricScheme.SegmentHor(k, start, v.get(v.size() - 1)));
            });


            out.println(ay.size());
            for (FElectricScheme.SegmentHor s : ay) {
                out.println(s.x1 + " " + s.y + " " + s.x2 + " " + s.y);
            }
            out.println(ax.size());
            for (FElectricScheme.SegmentVer s : ax) {
                out.println(s.x + " " + s.y1 + " " + s.x + " " + s.y2);
            }

        }

        static class SegmentHor {
            public int y;
            public int x1;
            public int x2;

            public SegmentHor(int y, int x1, int x2) {
                this.y = y;
                this.x1 = x1;
                this.x2 = x2;
            }

        }

        static class SegmentVer {
            public int x;
            public int y1;
            public int y2;

            public SegmentVer(int x, int y1, int y2) {
                this.x = x;
                this.y1 = y1;
                this.y2 = y2;
            }

        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void print(Object... objects) {
            for (int i = 0; i < objects.length; i++) {
                if (i != 0) {
                    writer.print(' ');
                }
                writer.print(objects[i]);
            }
        }

        public void println(Object... objects) {
            print(objects);
            writer.println();
        }

        public void close() {
            writer.close();
        }

        public void println(int i) {
            writer.println(i);
        }

    }

    static class LUtils {
        public static <E> List<E>[] genArrayList(int size) {
            return Stream.generate(ArrayList::new).limit(size).toArray(List[]::new);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1 << 16];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (this.numChars == -1) {
                throw new InputMismatchException();
            } else {
                if (this.curChar >= this.numChars) {
                    this.curChar = 0;

                    try {
                        this.numChars = this.stream.read(this.buf);
                    } catch (IOException var2) {
                        throw new InputMismatchException();
                    }

                    if (this.numChars <= 0) {
                        return -1;
                    }
                }

                return this.buf[this.curChar++];
            }
        }

        public int nextInt() {
            int c;
            for (c = this.read(); isSpaceChar(c); c = this.read()) {
                ;
            }

            byte sgn = 1;
            if (c == 45) {
                sgn = -1;
                c = this.read();
            }

            int res = 0;

            while (c >= 48 && c <= 57) {
                res *= 10;
                res += c - 48;
                c = this.read();
                if (isSpaceChar(c)) {
                    return res * sgn;
                }
            }

            throw new InputMismatchException();
        }

        public static boolean isSpaceChar(int c) {
            return c == 32 || c == 10 || c == 13 || c == 9 || c == -1;
        }

    }

    static class MaxFlowDinic {
        public static void addEdge(List<MaxFlowDinic.Edge>[] graph, int s, int t, int cap) {
            graph[s].add(new MaxFlowDinic.Edge(t, graph[t].size(), cap));
            graph[t].add(new MaxFlowDinic.Edge(s, graph[s].size() - 1, 0));
        }

        static boolean dinicBfs(List<MaxFlowDinic.Edge>[] graph, int src, int dest, int[] dist) {
            Arrays.fill(dist, -1);
            dist[src] = 0;
            int[] Q = new int[graph.length];
            int sizeQ = 0;
            Q[sizeQ++] = src;
            for (int i = 0; i < sizeQ; i++) {
                int u = Q[i];
                for (MaxFlowDinic.Edge e : graph[u]) {
                    if (dist[e.t] < 0 && e.f < e.cap) {
                        dist[e.t] = dist[u] + 1;
                        Q[sizeQ++] = e.t;
                    }
                }
            }
            return dist[dest] >= 0;
        }

        static int dinicDfs(List<MaxFlowDinic.Edge>[] graph, int[] ptr, int[] dist, int dest, int u, int f) {
            if (u == dest)
                return f;
            for (; ptr[u] < graph[u].size(); ++ptr[u]) {
                MaxFlowDinic.Edge e = graph[u].get(ptr[u]);
                if (dist[e.t] == dist[u] + 1 && e.f < e.cap) {
                    int df = dinicDfs(graph, ptr, dist, dest, e.t, Math.min(f, e.cap - e.f));
                    if (df > 0) {
                        e.f += df;
                        graph[e.t].get(e.rev).f -= df;
                        return df;
                    }
                }
            }
            return 0;
        }

        public static int maxFlow(List<MaxFlowDinic.Edge>[] graph, int src, int dest) {
            int flow = 0;
            int[] dist = new int[graph.length];
            while (dinicBfs(graph, src, dest, dist)) {
                int[] ptr = new int[graph.length];
                while (true) {
                    int df = dinicDfs(graph, ptr, dist, dest, src, Integer.MAX_VALUE);
                    if (df == 0)
                        break;
                    flow += df;
                }
            }
            return flow;
        }

        public static Set<Integer> minCut(List<MaxFlowDinic.Edge>[] graph, int src, int dest) {
            maxFlow(graph, src, dest);
            Set<Integer> ret = new HashSet<>();
            int n = graph.length;
            int[] queue = new int[n];
            int front = 0, back = 0;
            queue[back++] = src;
            ret.add(src);
            while (front < back) {
                int node = queue[front++];
                for (MaxFlowDinic.Edge e : graph[node]) {
                    if (!ret.contains(e.t) && e.f < e.cap) {
                        ret.add(e.t);
                        queue[back++] = e.t;
                    }
                }
            }
            return ret;
        }

        public static class Edge {
            public int t;
            public int rev;
            public int cap;
            public int f;
            public int idx;

            public Edge(int t, int rev, int cap) {
                this.t = t;
                this.rev = rev;
                this.cap = cap;
            }

            public Edge(int t, int rev, int cap, int idx) {
                this.t = t;
                this.rev = rev;
                this.cap = cap;
                this.idx = idx;
            }

        }

    }
}