#include <bits/stdc++.h>
using namespace std;
struct node {
  int l, r, id;
} a[1001000];
int c[1001000], b[1001000], n, m, num, cnt, ans[1001000];
int cmp(node aa, node bb) {
  if (aa.l == bb.l) {
    if (aa.r == bb.r) return aa.id < bb.id;
    return aa.r < bb.r;
  }
  return aa.l > bb.l;
}
int sum(int x) {
  int sum = 0;
  for (int i = x; i > 0; i -= i & (-i)) sum += c[i];
  return sum;
}
void update(int x) {
  for (int i = x; i < 1001000; i += i & (-i)) c[i]++;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%d%d", &a[i].l, &a[i].r), a[i].id = 0;
  num = n;
  for (int i = 1; i <= m; i++) {
    scanf("%d", &cnt);
    b[0] = 0;
    b[cnt + 1] = 1e6 + 10;
    for (int j = 1; j <= cnt; j++) scanf("%d", &b[j]);
    for (int j = 0; j <= cnt; j++) {
      if (b[j] + 1 <= b[j + 1] - 1)
        a[num++] = (node){b[j] + 1, b[j + 1] - 1, i};
    }
  }
  sort(a, a + num, cmp);
  for (int i = 0; i < num; i++) {
    if (a[i].id == 0)
      update(a[i].r);
    else
      ans[a[i].id] += sum(a[i].r);
  }
  for (int i = 1; i <= m; i++) cout << n - ans[i] << endl;
  return 0;
}
