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 MAX_BUF_SIZE = 16384;
char BUFOR[MAX_BUF_SIZE];
int BUF_SIZE, BUF_POS;
char ZZZ;
int _MINUS;
const int MXN = 2000010;
const int C = 4 * 262144;
const int INF = 1000000001;
int n, m;
vector<int> tree[2 * C + 10];
void dodaj(int x, int y) {
  x += C;
  while (x) {
    tree[x].push_back(y);
    x /= 2;
  }
}
void prep() {
  for (int i = (2 * C - 1); i >= (0); i--)
    sort((tree[i]).begin(), (tree[i]).end());
}
int licz(vector<int> &vec, int y) {
  int it = upper_bound((vec).begin(), (vec).end(), y) - vec.begin();
  return it;
}
int _cnt(int w, int L, int R, int l, int r, int y) {
  if (l <= L && R <= r) return licz(tree[w], y);
  int second = (L + R) / 2;
  int res = 0;
  if (l <= second) res += _cnt(2 * w, L, second, l, r, y);
  if (r > second) res += _cnt(2 * w + 1, second + 1, R, l, r, y);
  return res;
}
int cnt(int y, int x1, int x2) { return _cnt(1, 0, C - 1, x1, x2, y); }
void test() {
  scanf("%d %d", &n, &m);
  for (int i = (1); i <= (n); i++) {
    int x, y;
    scanf("%d %d", &y, &x);
    dodaj(x, y);
  }
  prep();
  for (int _ = (1); _ <= (m); _++) {
    int ile;
    scanf("%d", &ile);
    int pr;
    scanf("%d", &pr);
    int res = 0;
    for (int i = (1); i <= (ile - 1); i++) {
      int p;
      scanf("%d", &p);
      res += cnt(pr, pr, p - 1);
      pr = p;
    }
    res += cnt(pr, pr, C - 2);
    printf("%d\n", res);
  }
}
int main() {
  int te = 1;
  while (te--) test();
  return 0;
}