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 gcd(int i, int j) {
  if (j == 0)
    return i;
  else
    return gcd(j, i % j);
}
const long double e = 0.00000005;
const long double pi = 3.1415926535898;
inline int getint() {
  int val = 0;
  char c;
  while ((c = getchar()) && !(c >= '0' && c <= '9'))
    ;
  do {
    val = (val * 10) + c - '0';
  } while ((c = getchar()) && (c >= '0' && c <= '9'));
  return val;
}
const long long INF = 100000000000000;
const int Y = 1000000;
vector<int> tree[4 * Y + 100];
int sz = 1;
void build() {
  for (int i = sz; i < 2 * sz; ++i) sort(tree[i].begin(), tree[i].end());
  for (int i = sz - 1; i > 0; --i) {
    int j1 = 0, j2 = 0;
    while (j1 != tree[2 * i].size() && j2 != tree[2 * i + 1].size()) {
      if (tree[2 * i][j1] < tree[2 * i + 1][j2]) {
        tree[i].push_back(tree[2 * i][j1++]);
      } else
        tree[i].push_back(tree[2 * i + 1][j2++]);
    }
    while (j1 != tree[2 * i].size()) tree[i].push_back(tree[2 * i][j1++]);
    while (j2 != tree[2 * i + 1].size())
      tree[i].push_back(tree[2 * i + 1][j2++]);
  }
}
int get(int ql, int qr, int v, int ad, int tl, int tr) {
  if (ql <= tl && tr <= qr) {
    return tree[v].end() - lower_bound(tree[v].begin(), tree[v].end(), ad);
  }
  int mid = (tr + tl) / 2;
  int res = 0;
  if (ql <= mid) res += get(ql, qr, 2 * v, ad, tl, mid);
  if (qr > mid) res += get(ql, qr, 2 * v + 1, ad, mid + 1, tr);
  return res;
}
int main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(false);
  cout.precision(15);
  int n, q;
  cin >> n >> q;
  while (sz <= Y + 2) sz <<= 1;
  for (int i = 0; i < n; ++i) {
    int a, b;
    cin >> a >> b;
    tree[a + sz].push_back(b);
  }
  build();
  for (int i = 0; i < q; ++i) {
    int ct;
    cin >> ct;
    int st = 0, ans = 0;
    for (int j = 0; j < ct; ++j) {
      int tmp;
      cin >> tmp;
      ans += (get(0, tmp, 1, tmp, 0, sz - 1) - get(0, st, 1, tmp, 0, sz - 1));
      st = tmp;
    }
    cout << ans << "\n";
  }
  return 0;
}