#pragma GCC optimize("Ofast") #include using namespace std; typedef long long int ll; typedef unsigned long long int ull; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); ll myRand(ll B) { return (ull)rng() % B; } inline double time() { return static_cast(chrono::duration_cast(chrono::steady_clock::now().time_since_epoch()).count()) * 1e-9; } int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); int n,m; cin >> n >> m; vector> v(n), u(m); for (int i = 0; i < n; ++i) { cin >> v[i].first >> v[i].second; } for (int i = 0; i < m; ++i) { cin >> u[i].first >> u[i].second; } int k; cin >> k; vector pos(k); for (int i = 0; i < k; ++i) { cin >> pos[i]; } sort(v.begin(), v.end()); sort(u.begin(), u.end()); bool ok = false; ll mx = v[0].second; for (int i = 1; i < n; ++i) { if (v[i].first <= mx) ok = true; mx = max(mx, v[i].second); } mx = u[0].second; for (int i = 1; i < m; ++i) { if (u[i].first <= mx) ok = true; mx = max(mx, u[i].second); } if (ok) { for (int i = 0; i < k; ++i) { cout << 1 << " "; } cout << "\n"; return 0; } for (int i = 0; i < k; ++i) { ok = false; for (int j = 0; j < m and !ok; ++j) { ll l = u[j].first-pos[i]; ll r = u[j].second-pos[i]; if (l > r) swap(l, r); ll lx = pos[i]-r, rx = pos[i]-l; if (lx > rx) swap(lx, rx); // if (pos[i] == 2) { // cout << l << " " << r << " " << lx << " " << rx << endl; // } auto it = lower_bound(v.begin(), v.end(), pair{rx+1, -2e9}); if (it != v.begin()) { it--; auto p = *it; if (max(p.first, lx) <= min(p.second, rx)) { ok = true; } } } cout << ok << " "; } cout << endl; }