Problem: Valera loves segments. He has recently come up with one interesting problem.

The Ox axis of coordinates has n segments, the i-th segment starts in position li and ends in position ri (we will mark it as [li, ri]). Your task is to process m queries, each consists of number cnti and a set of cnti coordinates of points located on the Ox axis. The answer to the query is the number of segments, such that each of them contains at least one point from the query. Segment [l, r] contains point q, if l ≤ q ≤ r.

Valera found the solution of this problem too difficult. So he asked you to help him. Help Valera. 

Input

The first line contains two integers n, m (1 ≤ n, m ≤ 3·105) — the number of segments on the axis of coordinates and the number of queries. 

Next n lines contain the descriptions of the segments. The i-th line contains two positive integers li, ri (1 ≤ li ≤ ri ≤ 106) — the borders of the i-th segment.

Next m lines contain the description of the queries, one per line. Each line starts from integer cnti (1 ≤ cnti ≤ 3·105) — the number of points in the i-th query. Then the line contains cnti distinct positive integers p1, p2, ..., pcnti (1 ≤ p1 < p2 < ... < pcnti ≤ 106) — the coordinates of points in the i-th query.

It is guaranteed that the total number of points in all queries doesn't exceed 3·105. 

Output

Print m non-negative integers, where the i-th number is the response to the i-th query.

Examples

Input

3 3
1 3
4 5
6 7
3 1 4 7
2 4 5
1 8


Output

3
1
0

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
int at[300010], next[300010];
int list[1000010], ec;
void add(int listPtr, int data) {
  at[ec] = data;
  next[ec] = list[listPtr];
  list[listPtr] = ec++;
}
typedef struct {
  int qi, qn, ul;
} Query;
void set_query(Query *q, int qi, int qn, int ul) {
  q->qi = qi;
  q->qn = qn;
  q->ul = ul;
}
int comp_query(const void *a, const void *b) {
  return ((Query *)a)->ul - ((Query *)b)->ul;
}
int segTree[4 * 1000010];
void build(int p, int l, int r) {
  int m;
  if (l == r) {
    segTree[p] = 0;
    return;
  }
  m = (l + r) / 2;
  build(2 * p + 1, l, m);
  build(2 * p + 2, m + 1, r);
  segTree[p] = 0;
}
void update(int p, int l, int r, int i, int j) {
  int m;
  if (l > j || r < i) return;
  if (i <= l && r <= j) {
    segTree[p]++;
    return;
  }
  m = (l + r) / 2;
  update(2 * p + 1, l, m, i, j);
  update(2 * p + 2, m + 1, r, i, j);
}
int query(int p, int l, int r, int pos) {
  int m;
  if (pos > r || pos < l) return 0;
  if (l == r) return segTree[p];
  m = (l + r) / 2;
  return segTree[p] + query(2 * p + 1, l, m, pos) +
         query(2 * p + 2, m + 1, r, pos);
}
int main() {
  int n, m, i, j, k, tq, l, r, pos, tpos, ans[300010], end, ei;
  Query queryPack[300010], *q;
  scanf("%d %d", &n, &m);
  for (i = 0; i < 1000000; i++) list[i] = -1;
  ec = 0;
  for (i = 0; i < n; i++) {
    scanf("%d %d", &l, &r);
    add(r - 1, l - 1);
  }
  tq = 0;
  for (i = 0; i < m; i++) {
    ans[i] = 0;
    scanf("%d", &k);
    for (j = 0; j < k; j++) {
      if (j > 0) {
        scanf("%d", &tpos);
        set_query(&queryPack[tq++], i, pos - 1, tpos - 1);
        pos = tpos;
      } else
        scanf("%d", &pos);
    }
    set_query(&queryPack[tq++], i, pos - 1, 1000000);
  }
  build(0, 0, 1000000 - 1);
  qsort(queryPack, tq, sizeof(Query), comp_query);
  end = 0;
  for (i = 0; i < tq; i++) {
    q = &queryPack[i];
    for (j = q->ul - 1; j >= end; j--) {
      ei = list[j];
      while (ei != -1) {
        update(0, 0, 1000000 - 1, at[ei], j);
        ei = next[ei];
      }
    }
    ans[q->qi] += query(0, 0, 1000000 - 1, q->qn);
    end = q->ul;
  }
  for (i = 0; i < m; i++) printf("%d\n", ans[i]);
  return 0;
}