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 N = 3e5 + 10;
vector<int> t[4 * N];
int a[N], n;
vector<int> merge(vector<int> &x, vector<int> &y) {
  vector<int> res;
  int px = 0, py = 0;
  while (px < x.size() && py < y.size()) {
    if (x[px] < y[py])
      res.push_back(x[px++]);
    else
      res.push_back(y[py++]);
  }
  while (px < x.size()) res.push_back(x[px++]);
  while (py < y.size()) res.push_back(y[py++]);
  return res;
}
void build(int v, int l, int r) {
  if (l == r)
    t[v].push_back(a[l]);
  else {
    int m = (l + r) >> 1;
    build(v << 1, l, m);
    build((v << 1) ^ 1, m + 1, r);
    t[v] = merge(t[v << 1], t[(v << 1) ^ 1]);
  }
}
int higher(int v, int tl, int tr, int l, int r, int x) {
  if (l > tr || tl > r) return 0;
  if (l <= tl && tr <= r) {
    int L = 0;
    int R = t[v].size();
    while (L + 1 < R) {
      int M = (L + R) / 2;
      if (t[v][M] > x)
        R = M;
      else
        L = M;
    }
    if (L > 0 && t[v][L - 1] > x) --L;
    if (t[v][L] <= x) ++L;
    return t[v].size() - L;
  }
  int tm = (tl + tr) / 2;
  int lv = (v << 1);
  int rv = lv + 1;
  return higher(lv, tl, tm, l, r, x) + higher(rv, tm + 1, tr, l, r, x);
}
int higher(int l, int r, int x) {
  if (l > r) return 0;
  return higher(1, 0, n - 1, l, r, x);
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  ;
  int m;
  cin >> n >> m;
  pair<int, int> x[n];
  for (int i = 0; i < n; ++i) {
    cin >> x[i].first >> x[i].second;
  }
  sort(x, x + n);
  for (int i = 0; i < n; ++i) a[i] = x[i].second;
  build(1, 0, n - 1);
  while (m--) {
    int k;
    cin >> k;
    vector<int> que;
    for (int i = 0; i < k; ++i) {
      int y;
      cin >> y;
      que.push_back(y);
    }
    que.push_back(1e7);
    sort(que.begin(), que.end());
    int ptr = 0;
    int res = 0;
    for (int i = 0; i < k; ++i) {
      int id = que[i];
      int next = que[i + 1];
      int l = 0;
      int r = n;
      while (l + 1 < r) {
        int mid = (l + r) / 2;
        if (x[mid].first <= id)
          l = mid;
        else
          r = mid;
      }
      if (l + 1 < n && x[l + 1].first <= id) ++l;
      if (x[l].first > id) --l;
      ptr = l + 1;
      while (ptr < n && x[ptr].first <= id) ++ptr;
      res += (higher(0, ptr - 1, id - 1) - higher(0, ptr - 1, next - 1));
    }
    cout << res << endl;
  }
}