#include <bits/stdc++.h>
using namespace std;
void _fill_int(int* p, int val, int rep) {
  int i;
  for (i = 0; i < rep; i++) p[i] = val;
}
signed long long GETi() {
  signed long long i;
  scanf("%lld", &i);
  return i;
}
template <class V, int ME>
class BIT {
 public:
  V bit[ME];
  BIT() { clear(); };
  void clear() { memset(bit, 0, sizeof(bit)); };
  V total(int entry) {
    V s = 0;
    entry++;
    while (entry > 0) {
      s += bit[entry - 1];
      entry -= entry & -entry;
    }
    return s;
  }
  void update(int entry, V val) {
    entry++;
    while (entry <= ME) {
      bit[entry - 1] += val;
      entry += entry & -entry;
    }
  }
};
BIT<signed long long, 1 << 21> bt;
int N, M;
int L[1000011];
vector<int> R[1000011];
vector<int> Q[1000011];
vector<int> RQ[1000011];
int NU[1000011];
void solve() {
  int f, i, j, k, l, x, y;
  cin >> N >> M;
  for (i = 0; i < N; i++) {
    cin >> x >> y;
    L[x]++;
    R[y].push_back(x);
  }
  for (i = 0; i < M; i++) {
    NU[i] = N;
    cin >> x;
    Q[i].push_back(0);
    for (j = 0; j < x; j++) {
      cin >> y;
      Q[i].push_back(y);
      RQ[y].push_back(i);
    }
    reverse(Q[i].begin(), Q[i].end());
  }
  for (x = 1; x <= 1000000; x++) {
    for (i = 0; i < RQ[x].size(); i++) {
      y = RQ[x][i];
      NU[y] -= bt.total(x - 1) - bt.total(Q[y].back());
      Q[y].resize(Q[y].size() - 1);
    }
    for (i = 0; i < R[x].size(); i++) bt.update(R[x][i], 1);
  }
  for (y = 0; y < M; y++) NU[y] -= bt.total(1000001) - bt.total(Q[y].back());
  for (i = 0; i < M; i++) (void)printf("%d\n", NU[i]);
}
int main(int argc, char** argv) {
  string s;
  for (int i = 1; i < argc; i++) s += argv[i], s += '\n';
  for (int i = s.size() - 1; i >= 0; i--) ungetc(s[i], stdin);
  solve();
  return 0;
}
