#include <bits/stdc++.h>
using namespace std;
template <typename T>
bool MinPlace(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool MaxPlace(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename S, typename T>
ostream &operator<<(ostream &out, const pair<S, T> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}
template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << "[";
  for (int i = 0; i < (int)v.size(); i++) {
    out << v[i];
    if (i != (int)v.size() - 1) out << ", ";
  }
  out << "]";
  return out;
}
template <typename T = long long int>
class BIT {
  int n;
  vector<T> v;

 public:
  BIT(int n) : n(n) { v.resize(n + 1, 0); }
  void inc(int pos, T delta = 1) {
    for (int i = pos; i <= n; i += i & (-i)) v[i] += delta;
  }
  void dec(int pos, T delta = 1) { inc(pos, -delta); }
  T qry(int r) {
    T ret = 0;
    for (int i = r; i; i = i & (i - 1)) ret += v[i];
    return ret;
  }
  T rangeQry(int l, int r) {
    if (r < l) return 0;
    return qry(r) - qry(l - 1);
  }
  void upd(int pos, T val) { inc(pos, val - pointQry(pos)); }
  T pointQry(int pos) { return qry(pos) - qry(pos - 1); }
};
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int n, m, l, r;
  vector<pair<int, int>> segs;
  vector<pair<pair<int, int>, int>> queries;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> l >> r;
    segs.push_back({l, r});
  }
  for (int i = 0; i < m; i++) {
    int cnti, pos, last = 0;
    cin >> cnti;
    while (cnti--) {
      cin >> pos;
      queries.push_back(make_pair(make_pair(last, pos), i));
      last = pos;
    }
    queries.push_back(make_pair(make_pair(last, int(1e6) + 1), i));
  }
  sort(segs.begin(), segs.end(), greater<pair<int, int>>());
  sort(queries.begin(), queries.end(), greater<pair<pair<int, int>, int>>());
  vector<int> ans(m, n);
  BIT<int> bit(1000005);
  for (int i = 0, j = 0; j < queries.size(); j++) {
    int pos1 = queries[j].first.first, pos2 = queries[j].first.second,
        id = queries[j].second;
    while (i < n and segs[i].first > pos1) bit.inc(segs[i++].second);
    ans[id] -= bit.rangeQry(pos1 + 1, pos2 - 1);
  }
  for (int i = 0; i < m; i++) cout << ans[i] << "\n";
}
