#include <bits/stdc++.h>
using namespace std;
int n, m, k, x;
vector<int> a, b;
vector<int>::iterator c, d;
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 0; i < k; i++) {
    scanf("%d", &x);
    a.push_back(x);
  }
  scanf("%d", &x);
  for (int i = 0; i < n * m - k; i++) {
    scanf("%d", &x);
    b.push_back(x);
  }
  std ::sort(a.begin(), a.end());
  std ::sort(b.begin(), b.end());
  for (int i = n; i >= 1; i--)
    for (int j = 1; j <= m; j++) {
      c = lower_bound(a.begin(), a.end(), i + j);
      d = lower_bound(b.begin(), b.end(), i + m + 1 - j);
      if (c != a.end())
        a.erase(c);
      else if (d != b.end())
        b.erase(d);
      else
        return printf("NO\n"), 0;
    }
  printf("YES\n");
  return 0;
}
