#include<cstdio>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include<cstring>
#include<string>
#include<stack>
#include<math.h>
#include<stdlib.h>
using namespace std;
#define int long long
#define double long double
typedef pair<int, int> pii;
typedef pair<int, pii > piii;
typedef pair<double, double> pdd;
typedef pair<int, char> pic;
typedef priority_queue<pii, vector<pii>, greater<pii> > RPQ;
#define mk make_pair
#define INF (1 << 30)
#define INFL (1ll << 60ll)
#define mod 1000000007

int N, Q;
pair<double, double> trgorg[30300], trg[30300];
vector<double> ktmk;

double theta_calc(double Ax, double Ay, double Bx, double By){
    double absA = sqrtl(Ax * Ax + Ay * Ay);
    double absB = sqrtl(Bx * Bx + By * By);
    double AB = Ax * Bx + Ay * By;
    double theta = acosl(AB / (absA * absB));
    return theta;
}

signed main(){
    cin >> N;
    double xmin = (double)INFL;
    int minid = -1;
    for(int i = 0; i < N; i++){
        double a, b;
        cin >> a >> b;
        a *= 10000 / (10000 - 1.0);
        b *= 10000 / (10000 - 1.0);
        trgorg[i] = mk(a, b);
        if(xmin > a){
            xmin = a;
            minid = i;
        }
    }
    double sx = trgorg[minid].first;
    double sy = trgorg[minid].second;
    /*cout << endl;
    cout << sx << " " << sy << endl;
    cout << endl;*/

    int idx = 0;
    for(int i = minid + 1; i < N; i++){
        trg[idx] = trgorg[i];
        if(sx - trg[idx].first == 0.0){
            //cout << "ha?" << i << endl;
            if(sy > trg[idx].second)ktmk.push_back(-INFL);
            else ktmk.push_back(INFL);
        }
        else ktmk.push_back((sy - trg[idx].second) / (sx - trg[idx].first));
        
        idx++;
    }
    for(int i = 0; i < minid; i++){
        trg[idx] = trgorg[i];
        if(sx - trg[idx].first == 0.0){
            if(sy > trg[idx].second)ktmk.push_back(-INFL);
            else ktmk.push_back(INFL);
        }
        else ktmk.push_back((sy - trg[idx].second) / (sx - trg[idx].first));

        idx++;
    }
    /*for(int i = 1; i < (int)ktmk.size(); i++){
        if(ktmk[i] < ktmk[i - 1]){
            return 1;
        }
    }*/


    cin >> Q;
    for(int i = 0; i < Q; i++){
        double x, y;
        cin >> x >> y;
        if(x < sx){
            cout << 0 << endl;
            continue;
        }
        if(sx - x == 0.0){
            return 1;
        }
        double kata = (sy - y) / (sx - x);
        auto ite = lower_bound(ktmk.begin(), ktmk.end(), kata);
        if(ite == ktmk.begin() || ite == ktmk.end()){
            cout << 0 << endl;
            continue;
        }

        int id = (int)(ite - ktmk.begin());
        double alfa = theta_calc(sx - trg[id - 1].first, sy - trg[id - 1].second, trg[id].first - trg[id - 1].first, trg[id].second - trg[id - 1].second);
        double beta = theta_calc(sx - trg[id - 1].first, sy - trg[id - 1].second, x - trg[id - 1].first, y - trg[id - 1].second);

        /*cout << endl;
        cout << "id : " << id << endl;
        cout << "id-1:" << id - 1 << endl;
        cout << "trg[id]" << trg[id].first << " " << trg[id].second << endl;
        cout << "trg[id-1]" << trg[id-1].first << " " << trg[id-1].second << endl;
        cout << "alfa : " << alfa << endl;
        cout << "beta : " << beta << endl;
        cout << endl;*/
        

        if(alfa <= beta){
            cout << 0 << endl;
            continue;
        }
        cout << 1 << endl;
    }

    /*cout << endl;
    cout << endl;
    cout << theta_calc(-1.0, 2.0, -6.0, -3.0) << endl;
    cout << theta_calc(-1.0, 2.0, -4.0, -1.0) << endl;*/
    

    return 0;
}

/*

*/


Measured memory_bytes: 5456