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;
vector<int> A[2000006];
vector<int> tree[3 * 2000006];
vector<int> merge(vector<int> a, vector<int> b) {
  vector<int> c;
  int na = a.size();
  int aa = 0, bb = 0;
  int nb = b.size();
  while (aa < na || bb < nb) {
    if (aa == na) {
      c.push_back(b[bb]);
      bb++;
    } else if (bb == nb) {
      c.push_back(a[aa]);
      aa++;
    } else if (a[aa] < b[bb]) {
      c.push_back(a[aa]);
      aa++;
    } else {
      c.push_back(b[bb]);
      bb++;
    }
  }
  return c;
}
void build(int nd, int s, int e) {
  if (s == e) {
    tree[nd] = A[s];
  } else {
    int m = (s + e) / 2;
    build(2 * nd, s, m);
    build(2 * nd + 1, m + 1, e);
    tree[nd] = merge(tree[2 * nd], tree[2 * nd + 1]);
  }
}
int query(int nd, int s, int e, int l, int r, int val) {
  if (r < s || e < l) return 0;
  if (l <= s && e <= r) {
    vector<int>::iterator itr;
    itr = upper_bound(tree[nd].begin(), tree[nd].end(), val);
    return itr - tree[nd].begin();
  }
  int m = (s + e) / 2;
  return query(2 * nd, s, m, l, r, val) +
         query(2 * nd + 1, m + 1, e, l, r, val);
}
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    int a, b;
    scanf("%d", &a);
    scanf("%d", &b);
    A[a].push_back(b);
  }
  for (int i = 0; i < 1000001; i++) {
    sort(A[i].begin(), A[i].end());
  }
  build(1, 1, 1000006);
  while (m > 0) {
    m--;
    int cnt;
    scanf("%d", &cnt);
    vector<int> B;
    B.push_back(0);
    for (int i = 0; i < cnt; i++) {
      int a;
      scanf("%d", &a);
      B.push_back(a);
    }
    B.push_back(1000001);
    vector<pair<int, int> > check;
    for (int i = 1; i < B.size(); i++) {
      check.push_back(make_pair(B[i - 1] + 1, B[i] - 1));
    }
    int sum = 0;
    for (int i = 0; i < check.size(); i++) {
      int l = check[i].first;
      int r = check[i].second;
      if (r >= l) {
        sum += query(1, 1, 1000006, l, r, r);
      }
    }
    int pp = n - sum;
    printf("%d\n", pp);
  }
}