#include <bits/stdc++.h>
#define int long long
using namespace std;
int read()
{
int res = 0,f = 1;
char ch = getchar();
while (ch<'0'||ch>'9') f = (ch=='-'?-1:1),ch = getchar();
while (ch>='0'&&ch<='9') res = (res<<3)+(res<<1)+(ch^48),ch = getchar();
return res*f;
}
void write(int x)
{
if (x<0) putchar('-'),x = -x;
if (x>9) write(x/10);
putchar(x%10+'0');
}
void writech(int x,char ch){write(x),putchar(ch);}
const int M = 5e5+5;
int n;
int ll[M],rr[M];
int sum[4*M],tag[4*M];
int maxn[4*M];
int ql,qr,v;
void bt(int x,int l,int r)
{
if (l==r)
{
sum[x]=maxn[x]=l;
return ;
}
int mid = (l+r)/2;
bt(2*x,l,mid);
bt(2*x+1,mid+1,r);
sum[x]=sum[2*x]+sum[2*x+1];
maxn[x]=max(maxn[2*x],maxn[2*x+1]);
}
void pushdown(int x,int l,int r)
{
int mid = (l+r)/2;
sum[2*x]+=tag[x]*(mid-l+1);
maxn[2*x]+=tag[x];
tag[2*x]+=tag[x];
sum[2*x+1]+=tag[x]*(r-mid);
maxn[2*x+1]+=tag[x];
tag[2*x+1]+=tag[x];
tag[x]=0;
}
void mod(int x,int l,int r)
{
if (ql<=l&&r<=qr)
{
tag[x]+=v;
maxn[x]+=v;
sum[x]+=v*(r-l+1);
return ;
}
pushdown(x,l,r);
int mid = (l+r)/2;
if (ql<=mid) mod(2*x,l,mid);
if (qr>mid) mod(2*x+1,mid+1,r);
sum[x]=sum[2*x]+sum[2*x+1];
maxn[x]=max(maxn[2*x],maxn[2*x+1]);
}
int querys(int x,int l,int r)
{
if (ql<=l&&qr>=r) return sum[x];
pushdown(x,l,r);
int res = 0;
int mid = (l+r)/2;
if (ql<=mid) res+=querys(2*x,l,mid);
if (qr>mid) res+=querys(2*x+1,mid+1,r);
return res;
}
int querym(int x,int l,int r)
{
if (ql<=l&&r<=qr) return maxn[x];
pushdown(x,l,r);
int mid = (l+r)/2;
int res = 0;
if (ql<=mid) res = max(res,querym(2*x,l,mid));
if (qr>mid) res = max(res,querym(2*x+1,mid+1,r));
return res;
}
int getl(int x)
{
int l = 1,r = M-5;
while (l<r)
{
int mid = (l+r)/2;
ql = 1,qr = mid;
if (querym(1,1,M-5)>=x) r=mid;
else l = mid+1;
}
return l;
}
int getr(int x)
{
int l = 1,r = M-5;
while (l<r)
{
int mid = (l+r+1)/2;
ql=1,qr=mid;
if (querym(1,1,M-5)<=x) l = mid;
else r = mid-1;
}
return l;
}
signed main()
{
n=read();
for (int i = 1; i <= n; i++) ll[i]=read(),rr[i]=read();
bt(1,1,M-5);
for (int i = 1; i <= n; i++)
{
ql = getl(ll[i]),qr = getr(rr[i]);
v=1;
mod(1,1,M-5);
}
int Q=read();
while (Q--)
{
int x=read();
ql=qr=x;
writech(querys(1,1,M-5),'\n');
}
return 0;
}