package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
)

func main() {
	defer writer.Flush()
	N := ReadInt()
	P = make([]*Point, N)
	for i := 0; i < N; i++ {
		P[i] = &Point{
			X:  ReadInt(),
			Y:  ReadInt(),
			id: i,
		}
	}

	np = 0
	T = make([]Node, N)
	root := MakeKDTree(0, N, 0)

	ans := make([]*Point, 0)
	q := ReadInt()
	for ; q > 0; q-- {
		sx, tx, sy, ty := ReadInt(), ReadInt(), ReadInt(), ReadInt()
		ans = ans[:0]
		Find(root, sx, tx, sy, ty, 0, &ans)
		sort.Slice(ans, func(i, j int) bool { return ans[i].id < ans[j].id })
		for _, a := range ans {
			Println(a.id)
		}
		Println()
	}
}

var np int
var P []*Point
var T []Node

const None = -1

type Node struct {
	location, p, l, r int
}

type Point struct {
	X, Y int
	id   int
}

type PointSliceX []*Point

func (s PointSliceX) Len() int           { return len(s) }
func (s PointSliceX) Less(i, j int) bool { return s[i].X < s[j].X }
func (s PointSliceX) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }

type PointSliceY []*Point

func (s PointSliceY) Len() int           { return len(s) }
func (s PointSliceY) Less(i, j int) bool { return s[i].Y < s[j].Y }
func (s PointSliceY) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }

func MakeKDTree(l, r, depth int) int {
	if !(l < r) {
		return None
	}
	mid := (l + r) / 2
	t := np
	np++
	if depth%2 == 0 {
		// sort.Slice(P[l:r], func(i, j int) bool { return P[l+i].X < P[l+j].X })
		Select(PointSliceX(P), mid, l, r-1)
	} else {
		// sort.Slice(P[l:r], func(i, j int) bool { return P[l+i].Y < P[l+j].Y })
		Select(PointSliceY(P), mid, l, r-1)
	}
	T[t].location = mid
	T[t].l = MakeKDTree(l, mid, depth+1)
	T[t].r = MakeKDTree(mid+1, r, depth+1)
	return t
}

func Find(v, sx, tx, sy, ty, depth int, ans *[]*Point) {
	x := P[T[v].location].X
	y := P[T[v].location].Y
	if sx <= x && x <= tx && sy <= y && y <= ty {
		*ans = append(*ans, P[T[v].location])
	}
	if depth%2 == 0 {
		if T[v].l != None {
			if sx <= x {
				Find(T[v].l, sx, tx, sy, ty, depth+1, ans)
			}
		}
		if T[v].r != None {
			if x <= tx {
				Find(T[v].r, sx, tx, sy, ty, depth+1, ans)
			}
		}
	} else {
		if T[v].l != None {
			if sy <= y {
				Find(T[v].l, sx, tx, sy, ty, depth+1, ans)
			}
		}
		if T[v].r != None {
			if y <= ty {
				Find(T[v].r, sx, tx, sy, ty, depth+1, ans)
			}
		}
	}
}

var scanner = bufio.NewScanner(os.Stdin)

func init() {
	scanner.Buffer(make([]byte, 256), 1e9)
	scanner.Split(bufio.ScanWords)
}
func ReadString() string { scanner.Scan(); return scanner.Text() }
func ReadInt() int {
	a, err := strconv.Atoi(ReadString())
	if err != nil {
		panic(err)
	}
	return a
}

var writer = bufio.NewWriter(os.Stdout)

func Println(a ...interface{}) { fmt.Fprintln(writer, a...) }

/////////////////////////////////////////////////////////////////////////////
// https://github.com/furstenheim/nth_element
/////////////////////////////////////////////////////////////////////////////
// FloydRivest
func Select(array sort.Interface, k, left, right int) {
	length := array.Len()
	for right > left {
		if right-left > 600 {
			var n = float64(right - left + 1)
			var kf = float64(k)
			var m = float64(k - left + 1)
			var z = math.Log(n)
			var s = 0.5 * math.Exp(2*z/3)
			sign := float64(1)
			if m-n/2 < 0 {
				sign = -1
			}
			var sd = 0.5 * math.Sqrt(z*s*(n-s)/n) * sign
			var newLeft = IntMax(left, int(math.Floor(kf-m*s/n+sd)))
			var newRight = IntMin(right, int(math.Floor(kf+(n-m)*s/n+sd)))
			Select(array, k, newLeft, newRight)
		}

		var i = left
		var j = right
		array.Swap(left, k)
		// in the original algorithm array[k] is stored to a value. To use golangs sort interface we need to keep track of the changes for the index
		// we define it as right because in the first iteration of for i<j it will be changed
		pointIndex := right
		if array.Less(left, right) {
			array.Swap(left, right)
			pointIndex = left
		}

		for i < j {
			// pointIndex is swapped only once in the first iteration. Later it will either be bigger (if left) or smaller (if right)
			array.Swap(i, j)
			i++
			j--
			for i < length && array.Less(i, pointIndex) {
				i++
			}
			for j >= 0 && array.Less(pointIndex, j) {
				j--
			}
		}
		// All equal points
		if !array.Less(left, pointIndex) && !array.Less(pointIndex, left) {
			array.Swap(left, j)
		} else {
			j++
			array.Swap(j, right)
		}
		if j <= k {
			left = j + 1
		}
		if k <= j {
			right = j - 1
		}
	}
}

func IntMin(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func IntMax(a, b int) int {
	if a > b {
		return a
	}
	return b
}

type Stack []int

func (s Stack) Push(v int) Stack {
	return append(s, v)
}
func (s Stack) Pop() (Stack, int) {
	l := len(s)
	return s[:l-1], s[l-1]
}



Measured memory_bytes: 55680