#include
#include
int main()
{
int *a,(*b)[2],n,k,i,j;
scanf("%d",&n);
a=(int*)malloc(sizeof(int)*n);
for(i=0;i
scanf("%d",&a[i]);
scanf("%d",&k);
b=(int(*)[2])malloc(sizeof(int)*k*2);
for(i=0;i
scanf("%d%d",&b[i][0],&b[i][1]);
for(i=0;i
for(j=0;j
if(a[i]>=b[j][0]&&a[i]<=b[j][1])
a[i]=0;
for(i=0;i
if(a[i]>0)
printf("%d ",a[i]);
free(a);
free(b);
return 0;
}