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>
T nextInt() {
  T x = 0, p = 1;
  char ch;
  do {
    ch = getchar();
  } while (ch <= ' ');
  if (ch == '-') {
    p = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + (ch - '0');
    ch = getchar();
  }
  return x * p;
}
const int maxN = (int)1e6 + 10;
const int maxK = 17;
const int INF = (int)1e9;
const int mod = (int)1e9 + 7;
const long long LLINF = (long long)1e18;
vector<int> g[maxN];
int n, m;
template <typename T>
struct segmentTree {
  int n;
  vector<int> t[4 * maxN];
  segmentTree() {}
  segmentTree(int n) : n(n) { build(1, 0, n - 1); }
  void mymerge(const vector<int> &a, const vector<int> &b, vector<int> &res) {
    int n = (int)a.size(), m = (int)b.size();
    res.resize(n + m);
    int itA = 0, itB = 0, itRES = 0;
    while (itA < n || itB < m) {
      if (itA == n) {
        res[itRES++] = b[itB++];
        continue;
      }
      if (itB == m) {
        res[itRES++] = a[itA++];
        continue;
      }
      if (a[itA] < b[itB]) {
        res[itRES++] = a[itA++];
        continue;
      }
      res[itRES++] = b[itB++];
    }
  }
  void build(int v, int l, int r) {
    if (l == r) {
      t[v] = g[r];
    } else {
      int m = (l + r) / 2;
      build(v + v, l, m);
      build(v + v + 1, m + 1, r);
      mymerge(t[v + v], t[v + v + 1], t[v]);
    }
  }
  int query(int l, int r, T x) {
    if (l > r) return 0;
    return query(1, l, r, x, 0, n - 1);
  }
  int query(int v, int l, int r, T x, int tl, int tr) {
    if (tl >= l && tr <= r) {
      return t[v].end() - lower_bound(t[v].begin(), t[v].end(), x);
    }
    int tm = (tl + tr) / 2;
    if (l > tm) {
      return query(v + v + 1, l, r, x, tm + 1, tr);
    }
    if (r <= tm) {
      return query(v + v, l, r, x, tl, tm);
    }
    return query(v + v, l, r, x, tl, tm) +
           query(v + v + 1, l, r, x, tm + 1, tr);
  }
};
segmentTree<int> *t;
int query(int l, int r) { return t->query(l, r, l); }
int main() {
  n = nextInt<int>();
  m = nextInt<int>();
  for (int i = 0; i < n; ++i) {
    int l, r;
    l = nextInt<int>();
    r = nextInt<int>();
    g[r].push_back(l);
  }
  for (int i = 0; i < maxN; ++i) {
    sort(g[i].begin(), g[i].end());
  }
  t = new segmentTree<int>(maxN);
  while (m--) {
    int c = nextInt<int>();
    vector<int> pts;
    pts.push_back(0);
    while (c--) {
      int p = nextInt<int>();
      pts.push_back(p);
    }
    pts.push_back((int)1e6 + 1);
    int res = n;
    for (int i = 0; i < pts.size() - 1; ++i) {
      res -= query(pts[i] + 1, pts[i + 1] - 1);
    }
    printf("%d\n", res);
  }
  return 0;
}