#include <bits/stdc++.h>
using namespace std;
const int mxn = 1 << 20;
int s[mxn], ans[mxn], bit[mxn];
vector<int> ed[mxn];
vector<pair<int, int>> query[mxn];
void add(int idx, int v) {
  for (; idx < mxn; idx += idx & -idx) bit[idx] += v;
}
int ask(int idx) {
  int ret = 0;
  for (; idx > 0; idx -= idx & -idx) ret += bit[idx];
  return ret;
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1, x1, x2; i <= n; ++i) {
    scanf("%d%d", &x1, &x2);
    s[x1]++, ed[x2].push_back(x1);
  }
  for (int i = 1, cnti, j, x, y; i <= m; ++i) {
    for (scanf("%d", &cnti), j = 1, x = 0; j <= cnti; ++j) {
      scanf("%d", &y), query[y].push_back({x, i}), x = y;
    }
  }
  for (int i = 1; i < mxn; ++i) {
    add(i, s[i]);
    for (auto it : query[i]) ans[it.second] += ask(i) - ask(it.first);
    for (int j : ed[i]) add(j, -1);
  }
  for (int i = 1; i <= m; ++i) printf("%d\n", ans[i]);
}
