#include <bits/stdc++.h>
using namespace std;
int sum[1000006];
void add(int x) {
  while (x <= 1000002) {
    sum[x]++;
    x += (x & -x);
  }
  return;
}
int query(int x) {
  int r = 0;
  while (x) {
    r += sum[x];
    x -= (x & -x);
  }
  return r;
}
vector<pair<int, pair<int, int> > > vec;
int res[300005];
int main() {
  int n, m, x, y;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++)
    scanf("%d %d", &x, &y), vec.push_back({y, {-1, x}});
  for (int i = 0; i < m; i++) {
    res[i] = n;
    scanf("%d", &x);
    int lst = 0;
    for (int j = 0; j < x; j++) {
      scanf("%d", &y);
      if (y - lst > 1) vec.push_back({y - 1, {i, lst + 1}});
      lst = y;
    }
    vec.push_back({1000002, {i, lst + 1}});
  }
  sort(vec.begin(), vec.end());
  for (int i = 1, j = 0; i <= 1000002 && j < vec.size(); i++) {
    while (j < vec.size() && vec[j].first == i && vec[j].second.first == -1)
      add(vec[j].second.second), j++;
    while (j < vec.size() && vec[j].first == i && vec[j].second.first != -1)
      res[vec[j].second.first] -= query(vec[j].first),
          res[vec[j].second.first] += query(vec[j].second.second - 1), j++;
  }
  for (int i = 0; i < m; i++) printf("%d\n", res[i]);
  return 0;
}
