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;
const int N = 6e5 + 5;
pair<int, int> inter[N];
int b[N];
int f[N], g[N];
int m = 0;
int ans[N];
struct query {
  int id;
  pair<int, int> c;
} qq[N];
void add(int x, int s, int f[]) {
  while (x <= m) {
    f[x] += s;
    x += x & -x;
  }
}
int sum(int x, int f[]) {
  int ans = 0;
  while (x) {
    ans += f[x];
    x -= x & -x;
  }
  return ans;
}
int sum(int l, int r, int f[]) { return sum(r, f) - sum(l - 1, f); }
pair<int, int> getinter(int l, int r) {
  l = lower_bound(b, b + m, l) - b + 1;
  r = upper_bound(b, b + m, r) - b;
  return make_pair(l, r);
}
int cmp(const query &a, const query &b) { return a.c.first < b.c.first; }
int main() {
  int n, q;
  scanf("%d%d", &n, &q);
  for (int i = 1; i <= n; ++i) {
    scanf("%d%d", &inter[i].first, &inter[i].second);
    b[m++] = inter[i].first;
    b[m++] = inter[i].second;
  }
  sort(b, b + m);
  m = unique(b, b + m) - b;
  for (int i = 1; i <= n; ++i) {
    inter[i].first = lower_bound(b, b + m, inter[i].first) - b + 1;
    inter[i].second = lower_bound(b, b + m, inter[i].second) - b + 1;
    add(inter[i].second, 1, f);
  }
  sort(inter + 1, inter + 1 + n);
  int M = 0;
  for (int i = 1; i <= q; ++i) {
    int cnt, l = 1;
    ans[i] = n;
    scanf("%d", &cnt);
    while (cnt--) {
      int x;
      scanf("%d", &x);
      qq[M++] = (query){i, getinter(l, x - 1)};
      l = x + 1;
    }
    qq[M++] = (query){i, getinter(l, (int)1e6)};
  }
  sort(qq, qq + M, cmp);
  for (int i = 0, j = 1; i < M; ++i) {
    while (j <= n && inter[j].first < qq[i].c.first)
      add(inter[j++].second, -1, f);
    int l = qq[i].c.first, r = qq[i].c.second;
    ans[qq[i].id] -= sum(l, r, f);
  }
  for (int i = 1; i <= q; ++i) printf("%d\n", ans[i]);
  return 0;
}