#include <bits/stdc++.h>
struct pt {
  int x, y;
};
pt *ps;
int *qs = ((int *)malloc((311111) * sizeof(int)));
int xxcomp(pt &a, pt &b) {
  if (a.x != b.x) return a.x - b.x;
  return a.y - b.y;
}
int xcomp(const void *aa, const void *bb) {
  return xxcomp(ps[*(int *)aa], ps[*(int *)bb]);
}
int yycomp(pt &a, pt &b) {
  if (a.y != b.y) return a.y - b.y;
  return a.x - b.x;
}
int ycomp(const void *aa, const void *bb) {
  return yycomp(ps[*(int *)aa], ps[*(int *)bb]);
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  ps = ((pt *)malloc((n) * sizeof(pt)));
  int *psx = ((int *)malloc((n) * sizeof(int)));
  int *psy = ((int *)malloc((n) * sizeof(int)));
  for (int i = (0); i < (n); i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    ps[i].x = x;
    ps[i].y = y;
    psx[i] = psy[i] = i;
  }
  qsort(psx, n, sizeof(int), xcomp);
  qsort(psy, n, sizeof(int), ycomp);
  int ht = 1;
  for (int sz = 1001111, nsz = sz + 1 >> 1; sz > 1;
       ht++, sz = nsz, nsz = sz + 1 >> 1)
    ;
  int ***arrs = ((int ***)malloc((ht) * sizeof(int **)));
  int **arrc = ((int **)malloc((ht) * sizeof(int *)));
  arrs[0] = ((int **)malloc((1001111) * sizeof(int *)));
  arrc[0] = ((int *)malloc((1001111) * sizeof(int)));
  for (int i = (0); i < (1001111); i++) arrc[0][i] = 0;
  for (int i = (0); i < (n); i++) {
    arrc[0][ps[i].x]++;
  }
  for (int i = (0); i < (1001111); i++) {
    arrs[0][i] = ((int *)malloc((arrc[0][i]) * sizeof(int)));
    arrc[0][i] = 0;
  }
  for (int i = (0); i < (n); i++) {
    int x = ps[i].x;
    arrs[0][x][arrc[0][x]++] = i;
  }
  for (int i = (0); i < (1001111); i++) {
    if (arrc[0][i]) {
      qsort(arrs[0][i], arrc[0][i], sizeof(int), ycomp);
    }
  }
  for (int sz = 1001111, nsz = sz + 1 >> 1, h = 1; sz > 1;
       h++, sz = nsz, nsz = sz + 1 >> 1) {
    arrs[h] = ((int **)malloc((nsz) * sizeof(int *)));
    arrc[h] = ((int *)malloc((nsz) * sizeof(int)));
    for (int i = (0); i < (nsz); i++) {
      int son1 = i << 1;
      int son2 = son1 + 1;
      if (son2 < sz) {
        int *ars1 = arrs[h - 1][son1];
        int *ars2 = arrs[h - 1][son2];
        int arc1 = arrc[h - 1][son1];
        int arc2 = arrc[h - 1][son2];
        arrs[h][i] = ((int *)malloc((arc1 + arc2) * sizeof(int)));
        arrc[h][i] = 0;
        int ison1 = 0, ison2 = 0;
        while (ison1 < arc1 && ison2 < arc2) {
          int comp = yycomp(ps[ars1[ison1]], ps[ars2[ison2]]);
          if (comp <= 0) arrs[h][i][arrc[h][i]++] = ars1[ison1++];
          if (comp >= 0) arrs[h][i][arrc[h][i]++] = ars2[ison2++];
        }
        while (ison1 < arc1) arrs[h][i][arrc[h][i]++] = ars1[ison1++];
        while (ison2 < arc2) arrs[h][i][arrc[h][i]++] = ars2[ison2++];
      } else {
        arrc[h][i] = arrc[h - 1][son1];
        arrs[h][i] = arrs[h - 1][son1];
      }
    }
  }
  while (m--) {
    int c;
    scanf("%d", &c);
    for (int i = (0); i < (c); i++) scanf("%d", qs + i);
    int ans = n;
    int lef = qs[c - 1] + 1, ryg = qs[0] - 1;
    int L, R;
    if (ps[psy[0]].y <= ryg) {
      L = 0, R = n;
      while (R - L > 1) {
        int M = L + R >> 1;
        if (ps[psy[M]].y <= ryg) {
          L = M;
        } else {
          R = M;
        }
      }
      ans -= R;
    }
    if (lef > ps[psx[0]].x) {
      L = 0, R = n;
      while (R - L > 1) {
        int M = L + R >> 1;
        if (lef > ps[psx[M]].x) {
          L = M;
        } else {
          R = M;
        }
      }
      ans -= n - R;
    } else {
      ans -= n;
    }
    for (int ccc = (0); ccc < (c - 1); ccc++) {
      lef = qs[ccc] + 1, ryg = qs[ccc + 1] - 1;
      if (lef > ryg) continue;
      int L = lef, R = 1001111;
      for (int h = 0; L < R; h++, L >>= 1, R >>= 1) {
        if (L & 1) {
          int *ars = arrs[h][L];
          int arc = arrc[h][L];
          if (arc) {
            if (ps[ars[0]].y <= ryg) {
              int l = 0, r = arc;
              while (r - l > 1) {
                int M = l + r >> 1;
                if (ps[ars[M]].y <= ryg) {
                  l = M;
                } else {
                  r = M;
                }
              }
              ans -= r;
            }
          }
          L++;
        }
        if (R & 1) {
          R--;
          int *ars = arrs[h][R];
          int arc = arrc[h][R];
          if (arc) {
            if (ps[ars[0]].y <= ryg) {
              int l = 0, r = arc;
              while (r - l > 1) {
                int M = l + r >> 1;
                if (ps[ars[M]].y <= ryg) {
                  l = M;
                } else {
                  r = M;
                }
              }
              ans -= r;
            }
          }
        }
      }
    }
    printf("%d\n", ans);
  }
}
