#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
long long rand(long long a, long long b) { return a + rng() % (b - a + 1); }
const long long MOD = 1e9 + 7;
const long long inf = (long long)1e9 + 500;
const long long oo = (long long)1e18 + 500;
template <typename T>
bool chmax(T& a, const T b) {
  return a < b ? a = b, 1 : 0;
}
template <typename T>
bool chmin(T& a, const T b) {
  return a > b ? a = b, 1 : 0;
}
const long long MAXN = 1000005;
vector<tuple<long long, long long, long long> > T[MAXN];
long long out[MAXN];
struct fenv {
  long long fw[MAXN];
  void update(long long x, long long v) {
    for (; x < MAXN; x += x & -x) fw[x] += v;
  }
  long long query(long long x) {
    long long res = 0;
    for (; x; x -= x & -x) res += fw[x];
    return res;
  }
  long long range_query(long long x, long long y) {
    return query(y) - query(x - 1);
  }
} fw;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long n, m;
  cin >> n >> m;
  for (long long i = 1; i <= (long long)n; ++i) {
    long long a, b;
    cin >> a >> b;
    T[b].push_back(tuple<long long, long long, long long>(0, a, -1));
  }
  for (long long i = 1; i <= (long long)m; ++i) {
    vector<long long> pts;
    pts.push_back(0);
    long long c;
    cin >> c;
    for (long long j = 1; j <= (long long)c; ++j) {
      long long x;
      cin >> x;
      pts.push_back(x);
    }
    pts.push_back(1000001);
    for (long long j = 1; j <= (long long)pts.size() - 1; ++j) {
      long long rg = pts[j] - 1;
      long long lf = pts[j - 1] + 1;
      if (lf > rg) continue;
      T[rg].push_back(tuple<long long, long long, long long>(1, lf, i));
    }
  }
  for (long long i = 0; i <= (long long)MAXN - 1; ++i) {
    for (auto v : T[i]) {
      if (get<0>(v) == 0) {
        fw.update(get<1>(v), 1);
      } else {
        out[get<2>(v)] += fw.range_query(get<1>(v), MAXN - 1);
      }
    }
  }
  for (long long i = 1; i <= (long long)m; ++i) cout << n - out[i] << "\n";
}

### Prompt

Please create a solution in Cpp to the following 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

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
long long rand(long long a, long long b) { return a + rng() % (b - a + 1); }
const long long MOD = 1e9 + 7;
const long long inf = (long long)1e9 + 500;
const long long oo = (long long)1e18 + 500;
template <typename T>
bool chmax(T& a, const T b) {
  return a < b ? a = b, 1 : 0;
}
template <typename T>
bool chmin(T& a, const T b) {
  return a > b ? a = b, 1 : 0;
}
const long long MAXN = 1000005;
vector<tuple<long long, long long, long long> > T[MAXN];
long long out[MAXN];
struct fenv {
  long long fw[MAXN];
  void update(long long x, long long v) {
    for (; x < MAXN; x += x & -x) fw[x] += v;
  }
  long long query(long long x) {
    long long res = 0;
    for (; x; x -= x & -x) res += fw[x];
    return res;
  }
  long long range_query(long long x, long long y) {
    return query(y) - query(x - 1);
  }
} fw;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long n, m;
  cin >> n >> m;
  for (long long i = 1; i <= (long long)n; ++i) {
    long long a, b;
    cin >> a >> b;
    T[b].push_back(tuple<long long, long long, long long>(0, a, -1));
  }
  for (long long i = 1; i <= (long long)m; ++i) {
    vector<long long> pts;
    pts.push_back(0);
    long long c;
    cin >> c;
    for (long long j = 1; j <= (long long)c; ++j) {
      long long x;
      cin >> x;
      pts.push_back(x);
    }
    pts.push_back(1000001);
    for (long long j = 1; j <= (long long)pts.size() - 1; ++j) {
      long long rg = pts[j] - 1;
      long long lf = pts[j - 1] + 1;
      if (lf > rg) continue;
      T[rg].push_back(tuple<long long, long long, long long>(1, lf, i));
    }
  }
  for (long long i = 0; i <= (long long)MAXN - 1; ++i) {
    for (auto v : T[i]) {
      if (get<0>(v) == 0) {
        fw.update(get<1>(v), 1);
      } else {
        out[get<2>(v)] += fw.range_query(get<1>(v), MAXN - 1);
      }
    }
  }
  for (long long i = 1; i <= (long long)m; ++i) cout << n - out[i] << "\n";
}

```