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 * 1000 * 100 + 10;
int n, m, node[21][maxn];
pair<int, int> p[maxn];
vector<int> rights;
inline int input() {
  int x;
  scanf("%d", &x);
  return x;
}
void build(int s, int e, int row) {
  if (s + 1 == e) {
    node[row][s] = p[s].first;
    return;
  }
  int mid = (s + e) / 2;
  build(s, mid, row + 1);
  build(mid, e, row + 1);
  merge(node[row + 1] + s, node[row + 1] + mid, node[row + 1] + mid,
        node[row + 1] + e, node[row] + s);
}
int get(int s, int e, int l, int r, int lim1, int lim2, int row) {
  if (r <= l or lim2 <= lim1) return 0;
  if (r <= s or l >= e) return 0;
  if (l <= s and r >= e)
    return lower_bound(node[row] + s, node[row] + e, lim2) -
           lower_bound(node[row] + s, node[row] + e, lim1);
  int mid = (s + e) / 2;
  return get(s, mid, l, r, lim1, lim2, row + 1) +
         get(mid, e, l, r, lim1, lim2, row + 1);
}
inline bool cmp(pair<int, int> a, pair<int, int> b) {
  return a.second < b.second;
}
int main() {
  n = input();
  m = input();
  for (int i = 1; i <= n; i++) {
    p[i].first = input();
    p[i].second = input();
    rights.push_back(p[i].second);
  }
  sort(p + 1, p + 1 + n, cmp);
  sort(rights.begin(), rights.end());
  build(1, n + 1, 1);
  for (int i = 1; i <= m; i++) {
    int ans = 0, cnt;
    cnt = input();
    int point[cnt + 1];
    for (int j = 1; j <= cnt; j++) {
      point[j] = input();
      if (j == 1) {
        int pos = lower_bound(rights.begin(), rights.end(), point[j]) -
                  rights.begin();
        ans += get(1, n + 1, 1, pos + 1, 1, point[j], 1);
      }
      if (j == cnt) {
        int pos = upper_bound(rights.begin(), rights.end(), point[j]) -
                  rights.begin() + 1;
        ans += get(1, n + 1, pos, n + 1, point[j] + 1, 1000000 + 1, 1);
      }
      if (j != 1) {
        int pos1 = upper_bound(rights.begin(), rights.end(), point[j - 1]) -
                   rights.begin() + 1;
        int pos2 = lower_bound(rights.begin(), rights.end(), point[j]) -
                   rights.begin();
        ans += get(1, n + 1, pos1, pos2 + 1, point[j - 1] + 1, point[j], 1);
      }
    }
    cout << n - ans << endl;
  }
}