#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
long long rand(long long a, long long b) { return a + rng() % (b - a + 1); }
const long long MOD = 1e9 + 7;
const long long inf = (long long)1e9 + 500;
const long long oo = (long long)1e18 + 500;
template <typename T>
bool chmax(T& a, const T b) {
  return a < b ? a = b, 1 : 0;
}
template <typename T>
bool chmin(T& a, const T b) {
  return a > b ? a = b, 1 : 0;
}
const long long MAXN = 1000005;
vector<tuple<long long, long long, long long> > T[MAXN];
long long out[MAXN];
struct fenv {
  long long fw[MAXN];
  void update(long long x, long long v) {
    for (; x < MAXN; x += x & -x) fw[x] += v;
  }
  long long query(long long x) {
    long long res = 0;
    for (; x; x -= x & -x) res += fw[x];
    return res;
  }
  long long range_query(long long x, long long y) {
    return query(y) - query(x - 1);
  }
} fw;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long n, m;
  cin >> n >> m;
  for (long long i = 1; i <= (long long)n; ++i) {
    long long a, b;
    cin >> a >> b;
    T[b].push_back(tuple<long long, long long, long long>(0, a, -1));
  }
  for (long long i = 1; i <= (long long)m; ++i) {
    vector<long long> pts;
    pts.push_back(0);
    long long c;
    cin >> c;
    for (long long j = 1; j <= (long long)c; ++j) {
      long long x;
      cin >> x;
      pts.push_back(x);
    }
    pts.push_back(1000001);
    for (long long j = 1; j <= (long long)pts.size() - 1; ++j) {
      long long rg = pts[j] - 1;
      long long lf = pts[j - 1] + 1;
      if (lf > rg) continue;
      T[rg].push_back(tuple<long long, long long, long long>(1, lf, i));
    }
  }
  for (long long i = 0; i <= (long long)MAXN - 1; ++i) {
    for (auto v : T[i]) {
      if (get<0>(v) == 0) {
        fw.update(get<1>(v), 1);
      } else {
        out[get<2>(v)] += fw.range_query(get<1>(v), MAXN - 1);
      }
    }
  }
  for (long long i = 1; i <= (long long)m; ++i) cout << n - out[i] << "\n";
}
