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;
inline int in() {
  int32_t x;
  scanf("%d", &x);
  return x;
}
inline long long lin() {
  long long x;
  scanf("%lld", &x);
  return x;
}
inline string get() {
  char ch[2000010];
  scanf("%s", ch);
  return ch;
}
const int MAX_LG = 21;
const int maxn = 3e5 + 10;
const int base = 29;
const int mod = 1e9 + 7;
const int INF = 1e9 + 100;
const int SQ = 317;
pair<int, int> P[maxn];
int n, q;
int stree[MAX_LG][4 * maxn];
inline void build(int p = 0, int l = 0, int r = n - 1, int dep = 0) {
  if (l == r) {
    stree[dep][l] = P[l].second;
    return;
  }
  int mid = (l + r) >> 1;
  build(2 * p + 1, l, mid, dep + 1);
  build(2 * p + 2, mid + 1, r, dep + 1);
  merge(stree[dep + 1] + l, stree[dep + 1] + mid + 1, stree[dep + 1] + mid + 1,
        stree[dep + 1] + r + 1, stree[dep] + l);
}
inline int get(int ql, int qr, int lim, int p = 0, int l = 0, int r = n - 1,
               int dep = 0) {
  if (l > qr || r < ql) return 0;
  if (l >= ql && r <= qr) {
    int ps = lower_bound(stree[dep] + l, stree[dep] + r + 1, lim) - stree[dep];
    return r - ps + 1;
  }
  int mid = (l + r) >> 1;
  return get(ql, qr, lim, 2 * p + 1, l, mid, dep + 1) +
         get(ql, qr, lim, 2 * p + 2, mid + 1, r, dep + 1);
}
int a[maxn], pos[maxn];
int32_t main() {
  n = in(), q = in();
  for (int i = 0; i < n; i++) P[i] = {in(), in()};
  sort(P, P + n);
  build();
  while (q--) {
    int cnt = in();
    int ret = 0;
    for (int j = 0; j < cnt; j++) {
      a[j] = in();
      pos[j] = upper_bound(P, P + n, make_pair(a[j], INF)) - P - 1;
      ret += get(0, pos[j], a[j]);
      if (j) ret -= get(0, pos[j - 1], a[j]);
    }
    cout << ret << "\n";
  }
}