#include <cstdio>
#include <algorithm>
#include <cassert>

using namespace std;

const int maxn = 1e5 + 10;

int n;
int l[maxn], r[maxn];
int k1, k2;
      
int main()
{
  freopen("../stock.in", "r", stdin);
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    scanf("%d%d", &l[i], &r[i]);
  fclose(stdin);
  freopen("../stock.out", "r", stdin);
  scanf("%d", &k1);
  int last = 0, idx;
  bool ok = 1;
  for (int i = 0; i < k1; i++)
  {
    scanf("%d", &idx);
    --idx;
    if (last > l[idx])
      ok = 0;
    last = r[idx];
  }       
  freopen("../stock_bruteforce.out", "r", stdin);
  scanf("%d", &k2);
  fclose(stdin);
  ok &= (k1 == k2);
  assert(ok);
}                      