#include <bits/stdc++.h>
using namespace std;
const int mxN = 1e6 + 5;
int n, m, ans[mxN];
vector<int> a[mxN];
vector<pair<int, int> > add[mxN], del[mxN];
pair<int, int> seg[mxN];
int first[mxN];
void Upd(int pos) {
  for (int i = pos; i < mxN; i |= i + 1) ++first[i];
}
int Get(int pos) {
  int ans = 0;
  for (int i = pos; i >= 0; i &= i + 1, --i) ans += first[i];
  return ans;
}
int main() {
  ios ::sync_with_stdio(false), cin.tie(nullptr);
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) cin >> seg[i].first >> seg[i].second;
  sort(seg + 1, seg + 1 + n);
  for (int i = 1; i <= m; ++i) {
    int sz;
    cin >> sz;
    a[i].push_back(0);
    for (int j = 1; j <= sz; ++j) {
      int x;
      cin >> x;
      a[i].push_back(x);
    }
    for (int j = 1; j <= sz; ++j) {
      int x = a[i][j - 1] + 1;
      int addi = lower_bound(seg + 1, seg + 1 + n, make_pair(x, 0)) - seg;
      int deli = lower_bound(seg + 1, seg + 1 + n, make_pair(a[i][j] + 1, 0)) -
                 seg - 1;
      if (addi <= deli) {
        add[addi].push_back({i, a[i][j]});
        del[deli].push_back({i, a[i][j]});
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    for (auto x : add[i]) ans[x.first] -= Get(mxN - 1) - Get(x.second - 1);
    Upd(seg[i].second);
    for (auto x : del[i]) ans[x.first] += Get(mxN - 1) - Get(x.second - 1);
  }
  for (int i = 1; i <= m; ++i) cout << ans[i] << '\n';
  return 0;
}
