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>
using namespace std;
struct interval {
  int l, r;
};
struct qrs {
  int l, r, id;
};
struct BIT {
  int n = 1000025 - 1;
  long long tree[1000025];
  int shift(int x) { return x & (-x); }
  void update(int index, long long val) {
    if (index == 0) return;
    while (index <= this->n) {
      tree[index] += val;
      index += shift(index);
    }
  }
  long long getans(int index) {
    if (index == 0) return 0;
    long long ret = 0;
    while (index > 0) {
      ret += tree[index];
      index = index - shift(index);
    }
    return ret;
  }
  long long query(int start, int end) {
    if (start > end) return 0;
    return getans(end) - getans(start - 1);
  }
};
vector<qrs> qs;
int n;
interval arr[1000025];
long long ans[1000025];
static bool cmp_1(const interval &a, const interval &b) { return a.r < b.r; }
static bool cmp_2(const qrs &a, const qrs &b) { return a.r < b.r; }
BIT tree;
void addinterval(int l, int r, int id) {
  if (l > r) return;
  qs.push_back(qrs{l, r, id});
}
int main() {
  int m, i, j;
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; i++) {
    scanf("%d%d", &arr[i].l, &arr[i].r);
  }
  sort(arr + 1, arr + 1 + n, cmp_1);
  for (i = 1; i <= m; i++) {
    int k;
    vector<int> pt;
    scanf("%d", &k);
    for (j = 0; j < k; j++) {
      int p;
      scanf("%d", &p);
      pt.push_back(p);
    }
    for (j = 0; j < k; j++) {
      if (j == 0) {
        addinterval(0, pt[j] - 1, i);
      } else {
        addinterval(pt[j - 1] + 1, pt[j] - 1, i);
      }
    }
    addinterval(pt.back() + 1, 1000001, i);
  }
  sort(qs.begin(), qs.end(), cmp_2);
  for (i = 0, j = 1; i < (int)qs.size(); i++) {
    while (j <= n && arr[j].r <= qs[i].r) {
      tree.update(arr[j].l, 1);
      j++;
    }
    ans[qs[i].id] += tree.query(qs[i].l, qs[i].r);
  }
  for (i = 1; i <= m; i++) {
    printf("%lld\n", n - ans[i]);
  }
  return 0;
}