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 maxn = 3 * 100 * 100 * 100 + 10;
const int INF = 4 * 100 * 100 * 100;
pair<pair<int, int>, int> pairr[maxn];
pair<int, int> r[maxn];
int d[4 * maxn], l[maxn], ans[maxn];
void add(int l, int r, int ind, int b, int e) {
  if (l <= b && e <= r) {
    d[ind]++;
    return;
  }
  int mid = (b + e) / 2;
  if (l < mid) add(l, r, ind * 2, b, mid);
  if (r > mid) add(l, r, ind * 2 + 1, mid, e);
  return;
}
int get(int p, int ind, int b, int e) {
  int ret = d[ind];
  if (e - b == 1) return ret;
  int mid = (b + e) / 2;
  if (p < mid)
    ret += get(p, ind * 2, b, mid);
  else
    ret += get(p, ind * 2 + 1, mid, e);
  return ret;
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int n, q;
  cin >> n >> q;
  for (int i = 0; i < n; i++) {
    cin >> l[i] >> r[i].first;
    r[i].first++;
    r[i].second = i;
  }
  int j = 0, cnt, p, temp;
  for (int i = 0; i < q; i++) {
    cin >> cnt;
    cin >> p;
    temp = p;
    pairr[j].first = (make_pair(p, 0));
    pairr[j].second = i;
    j++;
    for (int k = 1; k < cnt; k++) {
      cin >> p;
      pairr[j].first = (make_pair(p, temp));
      temp = p;
      pairr[j].second = i;
      j++;
    }
    pairr[j].first = (make_pair(INF, p));
    pairr[j].second = i;
    j++;
  }
  sort(pairr, pairr + j);
  sort(r, r + n);
  int cnt1 = 0, cnt2 = 0;
  for (int i = 0; i < INF + 20; i++) {
    while (r[cnt1].first == i) {
      add(0, l[r[cnt1].second], 1, 0, INF);
      cnt1++;
    }
    while (pairr[cnt2].first.first == i) {
      ans[pairr[cnt2].second] += get(pairr[cnt2].first.second, 1, 0, INF);
      cnt2++;
    }
  }
  for (int i = 0; i < q; i++) cout << n - ans[i] << endl;
  return 0;
}