#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 10;
int ans[maxn];
int fen[maxn];
inline void add(int id, int val) {
  id++;
  while (id < maxn) {
    fen[id] += val;
    id += id & -id;
  }
}
inline int get(int id) {
  id++;
  int ret = 0;
  while (id) {
    ret += fen[id];
    id -= id & -id;
  }
  return ret;
}
vector<int> seg[maxn];
vector<pair<int, int> > q[maxn];
int main() {
  ios::sync_with_stdio(false);
  int n, Q;
  cin >> n >> Q;
  for (int i = 1; i <= n; i++) {
    int x, y;
    cin >> x >> y;
    seg[y].push_back(x);
  }
  for (int i = 1; i <= Q; i++) {
    int cnt;
    cin >> cnt;
    int pre = 0;
    while (cnt--) {
      int x;
      cin >> x;
      q[x].push_back(pair<int, int>(pre, i));
      pre = x;
    }
  }
  for (int i = 1000000; i >= 1; i--) {
    for (int j = 0; j < seg[i].size(); j++) add(seg[i][j], +1);
    for (int j = 0; j < q[i].size(); j++)
      ans[q[i][j].second] += get(i) - get(q[i][j].first);
  }
  for (int i = 1; i <= Q; i++) cout << ans[i] << "\n";
  return 0;
}
