#include <bits/stdc++.h>
const int MaxN = 1000010;
int N, M, ans[MaxN], bit[MaxN];
std ::vector<int> a[MaxN];
std ::vector<std ::pair<int, int> > q[MaxN];
int main(int argv, char* argc[]) {
  scanf("%d%d", &N, &M);
  for (int i(1); i <= (N); ++i) {
    int l, r;
    scanf("%d%d", &l, &r);
    a[r].push_back(l);
  }
  for (int i(1); i <= (M); ++i) {
    int p, pre = 0, x;
    scanf("%d", &p);
    for (int j = 0; j < p; ++j) {
      scanf("%d", &x);
      q[x].push_back(std ::pair<int, int>(pre, i));
      pre = x;
    }
  }
  for (int i(1000000); i >= (1); --i) {
    for (unsigned j(0); j < a[i].size(); ++j) {
      for (int k(a[i][j]); k <= (1000000); k += k & -k) ++bit[k];
    }
    for (unsigned j(0); j < q[i].size(); ++j) {
      for (int k(i); k; k -= k & -k) {
        ans[q[i][j].second] += bit[k];
      }
      for (int k(q[i][j].first); k; k -= k & -k) {
        ans[q[i][j].second] -= bit[k];
      }
    }
  }
  for (int i(1); i <= (M); ++i) printf("%d\n", ans[i]);
  return 0;
}
