#include <bits/stdc++.h>
using namespace std;
const int inf = 2000000000;
const long long infLL = 9000000000000000000;
template <typename first, typename second>
ostream& operator<<(ostream& os, const pair<first, second>& p) {
  return os << "(" << p.first << ", " << p.second << ")";
}
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  os << "{";
  for (auto it = v.begin(); it != v.end(); ++it) {
    if (it != v.begin()) os << ", ";
    os << *it;
  }
  return os << "}";
}
template <typename T>
ostream& operator<<(ostream& os, const set<T>& v) {
  os << "[";
  for (auto it = v.begin(); it != v.end(); ++it) {
    if (it != v.begin()) os << ",";
    os << *it;
  }
  return os << "]";
}
template <typename T>
ostream& operator<<(ostream& os, const multiset<T>& v) {
  os << "[";
  for (auto it = v.begin(); it != v.end(); ++it) {
    if (it != v.begin()) os << ", ";
    os << *it;
  }
  return os << "]";
}
template <typename first, typename second>
ostream& operator<<(ostream& os, const map<first, second>& v) {
  os << "[";
  for (auto it = v.begin(); it != v.end(); ++it) {
    if (it != v.begin()) os << ", ";
    os << it->first << " = " << it->second;
  }
  return os << "]";
}
void faltu() { cerr << '\n'; }
template <typename T>
void faltu(T a[], int n) {
  for (int i = 0; i < n; ++i) cerr << a[i] << ' ';
  cerr << '\n';
}
template <typename T, typename... hello>
void faltu(T arg, const hello&... rest) {
  cerr << arg << ' ';
  faltu(rest...);
}
const int mx = 1e6 + 5;
int n, m;
vector<int> seg[(int)(1e6 + 5)];
vector<pair<int, int> > points[(int)(1e6 + 5)];
int tree[mx * 4];
int ans[(int)3e5 + 5];
vector<int> vec;
int lim = mx - 2;
void update(int node, int l, int r, int b, int x) {
  if (l == r) {
    tree[node] += x;
    return;
  }
  int mid = (l + r) / 2;
  if (mid >= b)
    update(2 * node, l, mid, b, x);
  else
    update(2 * node + 1, mid + 1, r, b, x);
  tree[node] = tree[2 * node] + tree[2 * node + 1];
}
int query(int node, int l, int r, int b, int e) {
  if (l > e || r < b) return 0;
  if (l >= b && r <= e) return tree[node];
  int mid = (l + r) / 2;
  return query(2 * node, l, mid, b, e) + query(2 * node + 1, mid + 1, r, b, e);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    int l, r;
    cin >> l >> r;
    seg[r].push_back(l);
  }
  for (int i = 0; i < m; ++i) {
    int cnt;
    cin >> cnt;
    vec.clear();
    vec.push_back(0);
    for (int j = 0; j < cnt; ++j) {
      int p;
      cin >> p;
      vec.push_back(p);
    }
    vec.push_back(lim);
    for (int j = 1; j < (int)vec.size(); ++j) {
      points[vec[j]].push_back(make_pair(vec[j - 1], i));
    }
  }
  for (int i = 1; i <= lim; ++i) {
    for (auto x : points[i]) {
      if (x.first + 1 > i - 1) continue;
      ans[x.second] += query(1, 1, lim, x.first + 1, i - 1);
    }
    for (auto x : seg[i]) {
      update(1, 1, lim, x, 1);
    }
  }
  for (int i = 0; i < m; ++i) cout << n - ans[i] << '\n';
}
