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;
template <typename T>
bool MinPlace(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool MaxPlace(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename S, typename T>
ostream &operator<<(ostream &out, const pair<S, T> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}
template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << "[";
  for (int i = 0; i < (int)v.size(); i++) {
    out << v[i];
    if (i != (int)v.size() - 1) out << ", ";
  }
  out << "]";
  return out;
}
template <typename T = long long int>
class BIT {
  int n;
  vector<T> v;

 public:
  BIT(int n) : n(n) { v.resize(n + 1, 0); }
  void inc(int pos, T delta = 1) {
    for (int i = pos; i <= n; i += i & (-i)) v[i] += delta;
  }
  void dec(int pos, T delta = 1) { inc(pos, -delta); }
  T qry(int r) {
    T ret = 0;
    for (int i = r; i; i = i & (i - 1)) ret += v[i];
    return ret;
  }
  T rangeQry(int l, int r) {
    if (r < l) return 0;
    return qry(r) - qry(l - 1);
  }
  void upd(int pos, T val) { inc(pos, val - pointQry(pos)); }
  T pointQry(int pos) { return qry(pos) - qry(pos - 1); }
};
int main() {
  int n, m, l, r;
  vector<pair<int, int>> segs;
  vector<pair<pair<int, int>, int>> queries;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> l >> r;
    segs.push_back({l, r});
  }
  for (int i = 0; i < m; i++) {
    int cnti, pos, last = 0;
    cin >> cnti;
    while (cnti--) {
      cin >> pos;
      queries.push_back(make_pair(make_pair(last, pos), i));
      last = pos;
    }
    queries.push_back(make_pair(make_pair(last, int(1e6) + 1), i));
  }
  sort(segs.begin(), segs.end(), greater<pair<int, int>>());
  sort(queries.begin(), queries.end(), greater<pair<pair<int, int>, int>>());
  vector<int> ans(m, n);
  BIT<int> bit(1000005);
  for (int i = 0, j = 0; j < queries.size(); j++) {
    int pos1 = queries[j].first.first, pos2 = queries[j].first.second,
        id = queries[j].second;
    while (i < n and segs[i].first > pos1) bit.inc(segs[i++].second);
    ans[id] -= bit.rangeQry(pos1 + 1, pos2 - 1);
  }
  for (int i = 0; i < m; i++) cout << ans[i] << "\n";
}