#include <bits/stdc++.h>
using namespace std;
int BIT[1000006 + 10], ans[1000006];
int n, qx, cur, t, m, c;
vector<pair<pair<int, int>, int> > query;
vector<pair<int, int> > seg;
void upd(int x) {
  for (; x <= 1000006; x += x & -x) BIT[x]++;
}
int ask(int x) {
  int ret = 0;
  for (; x > 0; x -= x & -x) ret += BIT[x];
  return ret;
}
void work(vector<pair<int, int> > &seg,
          vector<pair<pair<int, int>, int> > &query) {
  vector<int> *e = new vector<int>[1000006 + 1];
  vector<pair<int, int> > *q = new vector<pair<int, int> >[1000006 + 1];
  for (auto x : seg) e[x.first].push_back(x.second);
  for (auto x : query) q[x.first.first].push_back({x.first.second, x.second});
  for (int i = 1000006; i >= 1; i--) {
    for (int x : e[i]) upd(x);
    for (auto x : q[i]) ans[x.second] += ask(x.first);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    seg.push_back({a, b});
  }
  for (int i = 0; i < m; i++) {
    cin >> c;
    cur = 0;
    for (int j = 0; j < c; j++) {
      cin >> t;
      if (t > cur + 1) query.push_back({{cur + 1, t - 1}, i});
      cur = t;
    }
    query.push_back({{cur + 1, 1000006}, i});
  }
  for (auto x : query)
    if (0)
      cerr << x.first.first << " " << x.first.second << " " << x.second << endl;
  work(seg, query);
  for (int i = 0; i < m; i++) cout << n - ans[i] << endl;
}
