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;
void _fill_int(int* p, int val, int rep) {
  int i;
  for (i = 0; i < rep; i++) p[i] = val;
}
signed long long GETi() {
  signed long long i;
  scanf("%lld", &i);
  return i;
}
template <class V, int ME>
class BIT {
 public:
  V bit[ME];
  BIT() { clear(); };
  void clear() { memset(bit, 0, sizeof(bit)); };
  V total(int entry) {
    V s = 0;
    entry++;
    while (entry > 0) {
      s += bit[entry - 1];
      entry -= entry & -entry;
    }
    return s;
  }
  void update(int entry, V val) {
    entry++;
    while (entry <= ME) {
      bit[entry - 1] += val;
      entry += entry & -entry;
    }
  }
};
BIT<signed long long, 1 << 21> bt;
int N, M;
int L[1000011];
vector<int> R[1000011];
vector<int> Q[1000011];
vector<int> RQ[1000011];
int NU[1000011];
void solve() {
  int f, i, j, k, l, x, y;
  cin >> N >> M;
  for (i = 0; i < N; i++) {
    cin >> x >> y;
    L[x]++;
    R[y].push_back(x);
  }
  for (i = 0; i < M; i++) {
    NU[i] = N;
    cin >> x;
    Q[i].push_back(0);
    for (j = 0; j < x; j++) {
      cin >> y;
      Q[i].push_back(y);
      RQ[y].push_back(i);
    }
    reverse(Q[i].begin(), Q[i].end());
  }
  for (x = 1; x <= 1000000; x++) {
    for (i = 0; i < RQ[x].size(); i++) {
      y = RQ[x][i];
      NU[y] -= bt.total(x - 1) - bt.total(Q[y].back());
      Q[y].resize(Q[y].size() - 1);
    }
    for (i = 0; i < R[x].size(); i++) bt.update(R[x][i], 1);
  }
  for (y = 0; y < M; y++) NU[y] -= bt.total(1000001) - bt.total(Q[y].back());
  for (i = 0; i < M; i++) (void)printf("%d\n", NU[i]);
}
int main(int argc, char** argv) {
  string s;
  for (int i = 1; i < argc; i++) s += argv[i], s += '\n';
  for (int i = s.size() - 1; i >= 0; i--) ungetc(s[i], stdin);
  solve();
  return 0;
}