#include <stdio.h>
#include "stdlib.h"

int cmpfunc(const void *a, const void *b);
int l_diff(int arr[], int n);
int compareA(int arr[], int n);
int compareB(int arr1[],int arr2[],int n1,int n2);

int main() {
    int u, i=0,e,n1,n2,y=0,z=0,x,j=0;
    int *arr1,*arr2,*arr3;
    while (scanf("%d",&u)){
        if(i==0) {
            e = u;
            arr3 = (int*) malloc(e*sizeof(int ));
            i++;
            continue;
        }
        if(i==1){
            n1 = u;
            arr1 = (int*)malloc(n1*sizeof(int ));
            i++;
            continue;
        }
        if(i==2){
            n2 = u;
            arr2 = (int*)malloc(n2*sizeof(int ));
            i++;
            continue;
        }
        if(i==3){
            arr1[y] = u;
            y++;
            if(y+1 == n1)
                i++;
            continue;
        }
        if(i==4){
            arr2[z] = u;
            z++;
            if(z+1 == n2)
                i++;
            continue;
        }
        qsort(arr1,n1,sizeof(int ),cmpfunc);
        qsort(arr2,n2,sizeof(int ),cmpfunc);
        x = compareB(arr1, arr2,n1,n2);
        if(x==0) {
            arr3[j] = 0;
            j++;
        }
        else{
            x = compareA(arr1,n1);
            if(x==0)
                arr3[j] = 0;
            else
                arr3[j] = 1;
            j++;
        }
        e--;
        free(arr1);
        arr1 = NULL;
        free(arr2);
        arr2 = NULL;
        y = 0;
        z = 0;
        if(e == 0)
            break;
        i = 1;
    }
    for (int k = 0; k <=j ; ++k) {
        printf("%d\n",arr3[k]);
    }
    return 0;
}

int compareB(int arr1[],int arr2[],int n1,int n2){
    int i=0,j=0;
    while ((i<n1) &&(j<n2)){
        if(arr1[i] == arr2[j])
            return 0;
        else if(arr1[i] < arr2[i])
            i++;
        else
            j++;
    }
    return 1;
}

int compareA(int arr[], int n){
    int x = arr[0];
    int i=1;
    int d = l_diff(arr,n);
    while (1){
        if (i==n)
            return 1;
        if(x>arr[i]){
            return 0;
        }
        if(x+d == arr[i]){
            x = arr[i];
            i++;
            continue;
        }
        x+=d;
    }
}

int l_diff(int arr[], int n){
    int d = 2147483647;
    for (int i = 0; i < n-1; i++) {
        for (int j = i+1; j <n ; j++) {
            if(abs(arr[i]-arr[j])<d)
                d = abs(arr[i] - arr[j]);
        }
    }
    return d;
}

int cmpfunc(const void *a, const void *b){
    return (*(int*)a - *(int*)b);
}