#include <bits/stdc++.h>
using namespace std;
struct node {
  int ind, l, r;
  node(){};
  node(int I, int L, int R) { ind = I, l = L, r = R; }
  bool operator<(const node &rhs) const {
    if (l != rhs.l)
      return l > rhs.l;
    else if (r == rhs.r)
      return r < rhs.r;
    else
      return ind < rhs.ind;
  }
} s[2000005];
int n, m, tot, c[2000005], ans[1000005];
int lowbit(int x) { return x & (-x); }
void add(int x) {
  for (; x <= 1000000; x += lowbit(x)) c[x]++;
}
int sum(int x) {
  int res = 0;
  for (; x >= 1; x -= lowbit(x)) res += c[x];
  return res;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &s[i].l, &s[i].r);
    s[i].ind = 0;
  }
  tot = n;
  for (int i = 1; i <= m; i++) {
    int cnt;
    scanf("%d", &cnt);
    ans[i] = n;
    int last = 0;
    for (int j = 1; j <= cnt; j++) {
      int a;
      scanf("%d", &a);
      if (a > 1 && last < a - 1) s[++tot] = node(i, last + 1, a - 1);
      last = a;
    }
    s[++tot] = node(i, last + 1, 1000001);
  }
  sort(s + 1, s + 1 + tot);
  for (int i = 1; i <= tot; i++) {
    if (s[i].ind)
      ans[s[i].ind] -= sum(s[i].r);
    else
      add(s[i].r);
  }
  for (int i = 1; i <= m; i++) {
    printf("%d\n", ans[i]);
  }
}
