#include <bits/stdc++.h>
using namespace std;
template <class _T>
inline void ina(_T a[], int n) {
  int i;
  for (i = 0; i < n; i++) cin >> a[i];
}
template <class _T>
inline void outa(_T a[], int n) {
  int i;
  for (i = 0; i < n - 1; i++) cout << a[i], cout << " ";
  if (i) printf("%d", i);
  cout << "\n";
}
const double EPS = 1e-9;
const int SIZE = 1e6;
template <class _T>
inline _T pow(_T a, _T b, _T m) {
  a %= m;
  _T ans = 1 % m;
  while (b) {
    if (b & 1) ans *= a, ans %= m;
    a *= a;
    a %= m;
    b >>= 1;
  }
  return ans;
}
template <class _T>
inline _T pow(_T a, _T b) {
  _T ans = 1;
  while (b) {
    if (b & 1) ans *= a;
    a *= a;
    b >>= 1;
  }
  return ans;
}
template <class _T>
inline _T add(_T a, _T b, _T m) {
  return a >= m - b ? a - (m - b) : a + b;
}
template <class _T>
inline _T multiply(_T a, _T b, _T m) {
  _T ans = 0;
  if (b > a) swap(a, b);
  while (b) {
    if (b & 1) ans = add(ans, a, m);
    b >>= 1;
    a = add(a, a, m);
  }
  return ans;
}
template <class _T>
inline _T bigpow(_T a, _T b, _T m) {
  a %= m;
  _T ans = 1 % m;
  while (b) {
    if (b & 1) ans = multiply(ans, a, m);
    a = multiply(a, a, m);
    b >>= 1;
  }
  return ans;
}
template <class _T>
inline _T modinvers(_T a, _T m) {
  return m > 2000000000LL ? bigpow(a, m - 2, m) : pow(a, m - 2, m);
}
template <class _T>
_T _egcd(_T a, _T b, _T &x, _T &y) {
  if (!b) {
    x = 1, y = 0;
    return a;
  }
  _T _g = _egcd(b, a % b, x, y);
  _T xt = x;
  x = y, y = xt - (a / b) * y;
  return _g;
}
template <class _T>
inline _T fmodinvers(_T a, _T m) {
  _T x, y;
  _egcd(a, m, x, y);
  x %= m;
  if (x < 0) x += m;
  return x;
}
template <class _T>
inline _T _lcm(_T a, _T b) {
  return (a * b) / __gcd(a, b);
}
int par[100];
int findp(int _n) { return par[_n] == _n ? _n : par[_n] = findp(par[_n]); }
long long mod = 1000000007;
struct node {
  int s;
  node *l, *r;
  node() { l = r = NULL; }
} ALL[10000000];
int AV = 0;
node *root[300009];
int _MN, _MX;
int p, v;
void extend(node *x, int l, int r) {
  int m = ((l + r) >> 1);
  if (p <= m && x->l == NULL) {
    x->l = &ALL[AV++];
    x->l->l = x->l->r = NULL;
    x->l->s = 0;
  } else if (p > m && x->r == NULL) {
    x->r = &ALL[AV++];
    x->r->l = x->r->r = NULL;
    x->r->s = 0;
  }
}
node *ins(node *cur, int l, int r) {
  if (p < l || p > r) return cur;
  if (l == r && l == p) {
    node *x = &ALL[AV++];
    x->l = x->r = NULL;
    x->s = cur->s + 1;
    return x;
  }
  extend(cur, l, r);
  int m = ((l + r) >> 1);
  node *nw = &ALL[AV++];
  nw->l = ins(cur->l, l, m);
  nw->r = ins(cur->r, m + 1, r);
  nw->s = (nw->l ? nw->l->s : 0) + (nw->r ? nw->r->s : 0);
  return nw;
}
int L, R;
int query(node *cur, int l, int r) {
  if (!cur) return 0;
  if (R < l || L > r) return 0;
  if (l >= L && r <= R) return cur->s;
  int m = ((l + r) >> 1);
  return query(cur->l, l, m) + query(cur->r, m + 1, r);
}
void ini() {
  AV = 0;
  root[0] = &ALL[AV++];
  root[0]->l = root[0]->r = NULL;
}
pair<int, int> sg[300099];
int id[1000099], fr[1000099], i, j, k, n, q, ans, a, b, c;
int FID(int x) {
  int l = 0, r = k, m, an;
  while (l <= r) {
    m = ((l + r) >> 1);
    if (id[m] < x)
      an = m, l = m + 1;
    else
      r = m - 1;
  }
  return an;
}
int main() {
  ini();
  scanf("%d %d", &n, &q);
  for (i = 0; i < n; i++) {
    scanf("%d %d", &sg[i].second, &sg[i].first);
    fr[sg[i].first]++;
  }
  for (i = 1; i <= 1e6 + 1; i++) {
    fr[i] += fr[i - 1];
  }
  sort(sg, sg + n);
  _MN = 0, _MX = 1e6 + 1;
  k = 1;
  for (i = 0; i < n; i++) {
    p = sg[i].second;
    root[k] = ins(root[k - 1], _MN, _MX);
    if (!id[sg[i].first]) id[k++] = sg[i].first;
  }
  id[k] = (int)1e6 + 1;
  while (q--) {
    a = 0;
    scanf("%d", &c);
    ans = 0;
    while (c--) {
      scanf("%d", &b);
      L = 0, R = a;
      ans += fr[b - 1] - query(root[FID(b)], _MN, _MX);
      a = b;
    }
    b = 1e6 + 1;
    L = 0, R = a;
    ans += fr[b - 1] - query(root[FID(b)], _MN, _MX);
    printf("%d", n - ans);
    putchar(10);
  }
  return 0;
}
