#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000001;
vector<int> a[maxn];
vector<pair<int, int> > q[maxn];
int ans[maxn], seg[4 * maxn];
void update(int low, int high, int pos, int ind) {
  if (low == high) {
    seg[pos]++;
    return;
  }
  int mid = (low + high) >> 1;
  if (ind <= mid)
    update(low, mid, 2 * pos + 1, ind);
  else
    update(mid + 1, high, 2 * pos + 2, ind);
  seg[pos] = seg[2 * pos + 1] + seg[2 * pos + 2];
}
int query(int low, int high, int qlow, int qhigh, int pos) {
  if (high < qlow || qhigh < low)
    return 0;
  else if (qlow <= low && high <= qhigh)
    return seg[pos];
  int mid = (low + high) >> 1;
  return (query(low, mid, qlow, qhigh, 2 * pos + 1) +
          query(mid + 1, high, qlow, qhigh, 2 * pos + 2));
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  int i, l, j, r, cnt, p, prev;
  for (i = 0; i < n; i++) {
    cin >> l >> r;
    a[r].push_back(l);
  }
  for (i = 0; i < m; i++) {
    cin >> cnt;
    prev = 0;
    while (cnt--) {
      cin >> p;
      q[p - 1].push_back(make_pair(prev + 1, i));
      prev = p;
    }
    q[1000000].push_back(make_pair(prev + 1, i));
  }
  for (i = 1; i < maxn; i++) {
    for (j = 0; j < (int)a[i].size(); j++) update(0, maxn - 1, 0, a[i][j]);
    for (j = 0; j < (int)q[i].size(); j++)
      ans[q[i][j].second] += query(0, maxn - 1, q[i][j].first, i, 0);
  }
  for (i = 0; i < m; i++) cout << n - ans[i] << endl;
  return 0;
}
