#include <bits/stdc++.h>
using namespace std;
int gcd(int i, int j) {
  if (j == 0)
    return i;
  else
    return gcd(j, i % j);
}
const long double e = 0.00000005;
const long double pi = 3.1415926535898;
inline int getint() {
  int val = 0;
  char c;
  while ((c = getchar()) && !(c >= '0' && c <= '9'))
    ;
  do {
    val = (val * 10) + c - '0';
  } while ((c = getchar()) && (c >= '0' && c <= '9'));
  return val;
}
const long long INF = 100000000000000;
const int Y = 1000000;
vector<int> tree[4 * Y + 100];
int sz = 1;
void build() {
  for (int i = sz; i < 2 * sz; ++i) sort(tree[i].begin(), tree[i].end());
  for (int i = sz - 1; i > 0; --i) {
    int j1 = 0, j2 = 0;
    while (j1 != tree[2 * i].size() && j2 != tree[2 * i + 1].size()) {
      if (tree[2 * i][j1] < tree[2 * i + 1][j2]) {
        tree[i].push_back(tree[2 * i][j1++]);
      } else
        tree[i].push_back(tree[2 * i + 1][j2++]);
    }
    while (j1 != tree[2 * i].size()) tree[i].push_back(tree[2 * i][j1++]);
    while (j2 != tree[2 * i + 1].size())
      tree[i].push_back(tree[2 * i + 1][j2++]);
  }
}
int get(int ql, int qr, int v, int ad, int tl, int tr) {
  if (ql <= tl && tr <= qr) {
    return tree[v].end() - lower_bound(tree[v].begin(), tree[v].end(), ad);
  }
  int mid = (tr + tl) / 2;
  int res = 0;
  if (ql <= mid) res += get(ql, qr, 2 * v, ad, tl, mid);
  if (qr > mid) res += get(ql, qr, 2 * v + 1, ad, mid + 1, tr);
  return res;
}
int main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(false);
  cout.precision(15);
  int n, q;
  cin >> n >> q;
  while (sz <= Y + 2) sz <<= 1;
  for (int i = 0; i < n; ++i) {
    int a, b;
    cin >> a >> b;
    tree[a + sz].push_back(b);
  }
  build();
  for (int i = 0; i < q; ++i) {
    int ct;
    cin >> ct;
    int st = 0, ans = 0;
    for (int j = 0; j < ct; ++j) {
      int tmp;
      cin >> tmp;
      ans += (get(0, tmp, 1, tmp, 0, sz - 1) - get(0, st, 1, tmp, 0, sz - 1));
      st = tmp;
    }
    cout << ans << "\n";
  }
  return 0;
}
