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 inf = 2000000000;
const long long infLL = 9000000000000000000;
template <typename first, typename second>
ostream& operator<<(ostream& os, const pair<first, second>& p) {
  return os << "(" << p.first << ", " << p.second << ")";
}
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  os << "{";
  for (auto it = v.begin(); it != v.end(); ++it) {
    if (it != v.begin()) os << ", ";
    os << *it;
  }
  return os << "}";
}
template <typename T>
ostream& operator<<(ostream& os, const set<T>& v) {
  os << "[";
  for (auto it = v.begin(); it != v.end(); ++it) {
    if (it != v.begin()) os << ",";
    os << *it;
  }
  return os << "]";
}
template <typename T>
ostream& operator<<(ostream& os, const multiset<T>& v) {
  os << "[";
  for (auto it = v.begin(); it != v.end(); ++it) {
    if (it != v.begin()) os << ", ";
    os << *it;
  }
  return os << "]";
}
template <typename first, typename second>
ostream& operator<<(ostream& os, const map<first, second>& v) {
  os << "[";
  for (auto it = v.begin(); it != v.end(); ++it) {
    if (it != v.begin()) os << ", ";
    os << it->first << " = " << it->second;
  }
  return os << "]";
}
void faltu() { cerr << '\n'; }
template <typename T>
void faltu(T a[], int n) {
  for (int i = 0; i < n; ++i) cerr << a[i] << ' ';
  cerr << '\n';
}
template <typename T, typename... hello>
void faltu(T arg, const hello&... rest) {
  cerr << arg << ' ';
  faltu(rest...);
}
const int mx = 1e6 + 5;
int n, m;
vector<int> seg[(int)(1e6 + 5)];
vector<pair<int, int> > points[(int)(1e6 + 5)];
int tree[mx * 4];
int ans[(int)3e5 + 5];
vector<int> vec;
int lim = mx - 2;
void update(int node, int l, int r, int b, int x) {
  if (l == r) {
    tree[node] += x;
    return;
  }
  int mid = (l + r) / 2;
  if (mid >= b)
    update(2 * node, l, mid, b, x);
  else
    update(2 * node + 1, mid + 1, r, b, x);
  tree[node] = tree[2 * node] + tree[2 * node + 1];
}
int query(int node, int l, int r, int b, int e) {
  if (l > e || r < b) return 0;
  if (l >= b && r <= e) return tree[node];
  int mid = (l + r) / 2;
  return query(2 * node, l, mid, b, e) + query(2 * node + 1, mid + 1, r, b, e);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    int l, r;
    cin >> l >> r;
    seg[r].push_back(l);
  }
  for (int i = 0; i < m; ++i) {
    int cnt;
    cin >> cnt;
    vec.clear();
    vec.push_back(0);
    for (int j = 0; j < cnt; ++j) {
      int p;
      cin >> p;
      vec.push_back(p);
    }
    vec.push_back(lim);
    for (int j = 1; j < (int)vec.size(); ++j) {
      points[vec[j]].push_back(make_pair(vec[j - 1], i));
    }
  }
  for (int i = 1; i <= lim; ++i) {
    for (auto x : points[i]) {
      if (x.first + 1 > i - 1) continue;
      ans[x.second] += query(1, 1, lim, x.first + 1, i - 1);
    }
    for (auto x : seg[i]) {
      update(1, 1, lim, x, 1);
    }
  }
  for (int i = 0; i < m; ++i) cout << n - ans[i] << '\n';
}