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;
int n, q;
pair<int, int> a[400009];
vector<int> tree[4000009];
int crnt = 0;
void build(int node, int l, int r) {
  if (l == r) {
    while (a[crnt].first == l && crnt < n) {
      tree[node].push_back(a[crnt].second);
      crnt++;
    }
    return;
  }
  build(node * 2, l, (l + r) / 2);
  build(node * 2 + 1, (l + r) / 2 + 1, r);
  vector<int> ret;
  int i = 0, j = 0;
  while (i < tree[node * 2].size() && j < tree[node * 2 + 1].size()) {
    if (tree[node * 2][i] >= tree[node * 2 + 1][j]) {
      ret.push_back(tree[node * 2 + 1][j]);
      j++;
    } else {
      ret.push_back(tree[node * 2][i]);
      i++;
    }
  }
  for (; i < tree[node * 2].size(); i++) {
    ret.push_back(tree[node * 2][i]);
  }
  for (; j < tree[node * 2 + 1].size(); j++) {
    ret.push_back(tree[node * 2 + 1][j]);
  }
  tree[node] = ret;
}
int query(int node, int l, int r, int s, int e) {
  if (s <= l && r <= e) {
    int ll = -1, rr = tree[node].size();
    while (rr - ll > 1) {
      int m = (rr + ll) / 2;
      if (tree[node][m] > e)
        rr = m;
      else
        ll = m;
    }
    return rr;
  }
  if (s <= (l + r) / 2 && e >= (l + r) / 2 + 1)
    return query(node * 2, l, (l + r) / 2, s, e) +
           query(node * 2 + 1, (l + r) / 2 + 1, r, s, e);
  else if (s <= (l + r) / 2)
    return query(node * 2, l, (l + r) / 2, s, e);
  else
    return query(node * 2 + 1, (l + r) / 2 + 1, r, s, e);
}
int main() {
  scanf("%d", &n);
  scanf("%d", &q);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i].first);
    scanf("%d", &a[i].second);
    a[i].first--;
    a[i].second--;
  }
  sort(a, a + n);
  build(1, 0, 1000000);
  while (q--) {
    int k;
    scanf("%d", &k);
    int sum = 0;
    vector<int> v;
    v.push_back(-1);
    while (k--) {
      int x;
      scanf("%d", &x);
      x--;
      v.push_back(x);
      int i = v.size() - 1;
      int l = v[i - 1] + 1;
      int r = v[i] - 1;
      if (l > r) continue;
      int xx = query(1, 0, 1000000, l, r);
      sum += xx;
    }
    int l = v[v.size() - 1] + 1;
    int r = 1000000;
    if (l <= r) {
      sum += query(1, 0, 1000000, l, r);
    }
    printf("%d\n", n - sum);
  }
}