Link to this code: https://cses.fi/paste/bea2f55ea833f98e334280/
//
// Created by michaelyang on 4:57 PM Jan 09 2022.
// Problem: Point in Polygon
// check if points are inside polygon

#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <queue>
#include <set>
#include <map>

#define f first
#define s second
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

typedef long long ll;
typedef pair<ll,ll> pl;

const int MOD=1e9+7;
const int N=1e5+5;

ll cross_product(pl a,pl b,pl c){
	return (b.f-a.f)*(c.s-a.s)-(c.f-a.f)*(b.s-a.s);
}

bool on_line(pl a,pl b,pl c){
	if (cross_product(a,b,c)!=0) return false;
	return c.f<=max(a.f,b.f)&&c.f>=min(a.f,b.f)&&c.s<=max(a.s,b.s)&&c.s>=min(a.s,b.s);
}

bool check_intersect(pl p1,pl p2,pl q1,pl q2){
	if (min(p1.f,p2.f)>max(q1.f,q2.f)||min(q1.f,q2.f)>max(p1.f,p2.f)||min(p1.s,p2.s)>max(q1.s,q2.s)||min(q1.s,q2.s)>max(p1.s,p2.s)) return false;
	if (cross_product(p1,q1,p2)*cross_product(p1,q2,p2)>0||cross_product(q1,p1,q2)*cross_product(q1,p2,q2)>0) return false;
	return true;
}

string check_inside(vector<pl> polygon,pl p){
	int k=polygon.size();
	if (k<3) return "OUTSIDE";
	pl ext_inf={1e9+5,p.s};
	int intersections=0;
	for (int i=0;i<k;i++){
		int next=(i+1)%k;
		if (check_intersect(polygon[i],polygon[next],p,ext_inf)){
			if (cross_product(polygon[i],polygon[next],p)==0){
				if (on_line(polygon[i],polygon[next],p)) return "BOUNDARY";
				else return "OUTSIDE";
			}
			intersections++;
		}
	}
	if (intersections%2) return "INSIDE";
	else return "OUTSIDE";
}

int main(){
	fastio
	int n,m;
	cin>>n>>m;
	vector<pl> polygon;
	for (int i=0;i<n;i++){
		int a,b;
		cin>>a>>b;
		polygon.push_back({a,b});
	}
	for (int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		cout<<check_inside(polygon,{a,b})<<endl;
	}
}