#include <stdio.h>

#include <stdlib.h>

typedef struct position

{

    int x, y;

} Position;

// function to find the max element in array

int maximum(int arr[], int n)

{

    int i;

    // Initialize maximum element

    int max = arr[0];

    // Traverse array elements from second and

    // compare every element with current max

    for (i = 1; i < n; i++)

        if (arr[i] > max)

            max = arr[i];

    return max;

}

// function to find the min element in array

int minimum(int arr[], int n)

{

    int i;

    // Initialize maximum element

    int min = arr[0];

    // Traverse array elements from second and

    // compare every element with current max

    for (i = 1; i < n; i++)

        if (arr[i] < min)

            min = arr[i];

    return min;

}

int main()

{

    int t;

    scanf("%d", &t);

    Position *pos = (Position *)malloc(t * sizeof(Position));

    // take input

    for (int i = 0; i < t; i++)

    {

        scanf("%d %d", &pos[i].x, &pos[i].y);

    }

    // calculate output

    for (int i = 0; i < t; i++)

    {

        // decalre 4 arrays for storing all rooks which are in the same row/column around the 4 directions of current rook

        // as well as a final rook array which can actually attack the rook

        int count = 0, right_count = 0, left_count = 0, down_count = 0, up_count = 0, count2 = 0, all_rooks_right[t], all_rooks_left[t], all_rooks_down[t], all_rooks_up[t], attacking_rooks[4];

        for (int j = 0; j < t; j++)

        {

            if (i != j)

            {

                // check all rooks right of current rook

                if (pos[i].x == pos[j].x && pos[j].y > pos[i].y)

                {

                    all_rooks_right[right_count] = j + 1;

                    right_count++;

                }

                // check all rooks left of current rook

                if (pos[i].x == pos[j].x && pos[j].y < pos[i].y)

                {

                    all_rooks_left[left_count] = j + 1;

                    left_count++;

                }

                // check all rooks below current rook

                if (pos[i].y == pos[j].y && pos[j].x > pos[i].x)

                {

                    all_rooks_down[down_count] = j + 1;

                    down_count++;

                }

                // check all rooks above current rook

                if (pos[i].y == pos[j].y && pos[j].x < pos[i].x)

                {

                    all_rooks_up[up_count] = j + 1;

                    up_count++;

                }

            }

        }

        // only the rook closest to the current rook will be able to attack

        // this segement of code finds the closest rook and adds them to final array

        if (right_count)

            attacking_rooks[count++] = minimum(all_rooks_right, right_count);

        if (left_count)

            attacking_rooks[count++] = maximum(all_rooks_left, left_count);

        if (down_count)

            attacking_rooks[count++] = minimum(all_rooks_down, down_count);

        if (up_count)

            attacking_rooks[count++] = maximum(all_rooks_up, up_count);

        // print results

        printf("%d ", count);

        for (int k = 0; k < count; k++)

            printf("%d ", attacking_rooks[k]);

        printf("\n");

    }

    return 0;

}
