#include <bits/stdc++.h>
using namespace std;
const int mv = 1000 * 1000 + 3;
int n, m;
int l, r;
int cnt;
vector<int> segments[mv + 100], a[303000];
vector<pair<int, int> > b[mv + 100];
int t[mv + 100], ans[303000];
int x;
int prev(int x) { return x & (x - 1); }
int next(int x) { return x * 2 - prev(x); }
void add(int x, int v) {
  while (x < mv) {
    t[x] += v;
    x = next(x);
  }
}
int sum(int x) {
  int ret = 0;
  while (x > 0) {
    ret += t[x];
    x = prev(x);
  }
  return ret;
}
void solve() {
  for (int i = 0; i < m; i++) {
    ans[i] = 0;
    for (int j = 0; j < a[i].size() - 1; j++)
      b[a[i][j + 1]].push_back(make_pair(i, a[i][j]));
  }
  for (int i = 0; i < mv + 40; i++) {
    for (int j = 0; j < b[i].size(); j++) {
      ans[b[i][j].first] += (sum(i - 1) - sum(b[i][j].second));
    }
    for (int j = 0; j < segments[i].size(); j++) add(segments[i][j], 1);
  }
  for (int i = 0; i < m; i++) {
    cout << n - ans[i] << endl;
  }
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> l >> r;
    segments[r].push_back(l);
  }
  for (int i = 0; i < m; i++) {
    cin >> cnt;
    a[i].push_back(0);
    for (int j = 0; j < cnt; j++) {
      cin >> x;
      a[i].push_back(x);
    }
    a[i].push_back(mv + 30);
  }
  solve();
  return 0;
}
