#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

#define endl "\n"

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

struct Point{
	int x, y;
	int num;
	
	Point (int y = 0, int x = 0, int num = 0) : y(y), x(x), num(num){}
};
	
class kDtree{
public:
	struct Node{
		Point p;
		Node *l, *r;
		
		Node (Point p, Node *l = NULL, Node *r = NULL) : p(p), l(l), r(r) {}
		
	} *root;
	
	kDtree() : root(NULL) {}
	
	inline bool compare(const int depth, const Point &p, const Point &np) {
		if(depth%2 == 0) {
			if(p.x <= np.x) return true;
			else return false;
		} else if(depth%2 == 1) {
			if(p.y <= np.y) return true;
			else return false;
		}
	}
	
	 void insert(const vector<Point> &vp, const vector<int> &num, int l, int r, int m, int depth){
		
		if(l >= r) return ;
		
		vector<int> num0, num1;
		
		if(depth%2 == 0) {
			vector<pair<int,int>> x(num.size());
			
			for(int i = 0; i < num.size(); i++){
				x[i] = {vp[num[i]].x, num[i]};
			}
			
			sort(x.begin(), x.end());
			
			for(int i = 0; i < num.size(); i++){
				if(x[i].first <= vp[num[m - l]].x) num0.push_back(x[i].second);
				else num1.push_back(x[i].second);
			}
			
			insert(vp[num0.back()]);
			num0.pop_back();
 		} else {
			vector<pair<int,int>> y(num.size());
			
			for(int i = 0; i < num.size(); i++){
				y[i] = {vp[num[i]].y, num[i]};
			}
			
			sort(y.begin(), y.end());
			
			for(int i = 0; i < num.size(); i++){
				if(y[i].first <= vp[num[m - l]].y) num0.push_back(y[i].second);
				else num1.push_back(y[i].second);
			}
			
			insert(vp[num0.back()]);
			num0.pop_back();
		}
		
		insert(vp, num0, 0, num0.size(), (num0.size())/2, depth+1);
		insert(vp, num1, 0, num1.size(), (num1.size())/2, depth+1);
	}
	
	
	void insert(const vector<Point> &vp) {
		vector<int> num(vp.size());
		
		
		for(int i = 0; i < vp.size(); i++){
			num[i] = i;
		}
		
		insert(vp, num, 0, vp.size(), vp.size()/2, 0);
	}
	
	
	void insert(const Point &p) {
		root = insert(root, p);
	}
	
	Node *insert(Node *n, const Point p, int depth = 0){
		if(n == NULL) {
			return new Node(p);
		}
		if(compare(depth, p, n->p)) n->l = insert(n->l, p, depth+1);
		else  n->r = insert(n->r, p, depth+1);
		
		return n;
	}
	
	bool check(const Point &p, const Point &ld, const Point &ru){
		if(!(ld.x <= p.x && p.x <= ru.x)) return false;
		if(!(ld.y <= p.y && p.y <= ru.y)) return false;
		return true;
	}
	
	void search(const Point &ld, const Point &ru, vector<int> &out){
		search(root, ld, ru, out);
		
	}
	
	void search(const Node *n, const Point &ld, const Point &ru, vector<int> &out, int depth = 0){
		if(n == NULL) return ;
		
		if(check(n->p, ld, ru)) out.push_back(n->p.num);
		
		if(compare(depth, ld, n->p)) search(n->l, ld, ru, out, depth+1);
		if(compare(depth, n->p, ru)) search(n->r, ld, ru, out, depth+1);
	}
	
};

int main(){
	int n, q;
	kDtree kd;
	vector<Point> p;
	
	cin>>n;
	
	p.resize(n);
	
	for(int i = 0; i < n; i++){
		cin>>p[i].x>>p[i].y;
		p[i].num = i;
	}
	
	kd.insert(p);
	
	cin>>q;
	
	for(int i = 0; i < q; i++){
		Point a, b;
		vector<int> out;
		
		cin>>a.x>>b.x>>a.y>>b.y;
		
		kd.search(a, b, out);
		
		sort(out.begin(), out.end());
		
		for(int p : out){
			cout<<p<<endl;
		}
		
		cout<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 39400