#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
int lcm(int a, int b) { return a * (b / gcd(a, b)); }
int n, m;
vector<pair<int, int> > seg;
vector<int> v;
struct SegmentTreeNode {
  int start, end;
  vector<int> rightseg;
  void assignLeaf(int value) { rightseg.push_back(value); }
  void merge(SegmentTreeNode& left, SegmentTreeNode& right) {
    int a = (int)(left.rightseg.size()), b = (int)(right.rightseg.size());
    int i = 0, j = 0;
    while (i < a && j < b) {
      if (left.rightseg[i] <= right.rightseg[j]) {
        rightseg.push_back(left.rightseg[i]);
        i++;
      } else {
        rightseg.push_back(right.rightseg[j]);
        j++;
      }
    }
    if (i < a) {
      for (int p = i; p < a; p++) rightseg.push_back(left.rightseg[p]);
    } else {
      for (int p = j; p < b; p++) rightseg.push_back(right.rightseg[p]);
    }
  }
  int cal(int l, int r) {
    int index1, index2;
    vector<int>::iterator it1, it2;
    it1 = lower_bound(rightseg.begin(), rightseg.end(), l);
    index1 = it1 - rightseg.begin();
    it2 = lower_bound(rightseg.begin(), rightseg.end(), r);
    it2--;
    index2 = it2 - rightseg.begin();
    return index2 - index1 + 1;
  }
};
SegmentTreeNode nodes[4 * 300010];
class SegmentTree {
 public:
  void build() { buildTree(1, 0, n - 1); }
  int getValue(int lo, int hi, int l, int r) {
    int result = getValue(1, lo, hi, l, r);
    return result;
  }

 private:
  void buildTree(int stIndex, int lo, int hi) {
    nodes[stIndex].start = lo, nodes[stIndex].end = hi;
    if (lo == hi) {
      nodes[stIndex].assignLeaf(seg[lo].second);
      return;
    }
    int left = 2 * stIndex, right = left + 1, mid = (lo + hi) / 2;
    buildTree(left, lo, mid);
    buildTree(right, mid + 1, hi);
    nodes[stIndex].merge(nodes[left], nodes[right]);
  }
  int getValue(int stIndex, int lo, int hi, int l, int r) {
    if (nodes[stIndex].start == lo && nodes[stIndex].end == hi)
      return nodes[stIndex].cal(l, r);
    int mid = (nodes[stIndex].start + nodes[stIndex].end) / 2;
    if (lo > mid) return getValue(2 * stIndex + 1, lo, hi, l, r);
    if (hi <= mid) return getValue(2 * stIndex, lo, hi, l, r);
    int leftResult = getValue(2 * stIndex, lo, mid, l, r);
    int rightResult = getValue(2 * stIndex + 1, mid + 1, hi, l, r);
    int result;
    result = leftResult + rightResult;
    return result;
  }
};
SegmentTree st;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  long long int ans = 0LL;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    seg.push_back(make_pair(x, y));
  }
  sort(seg.begin(), seg.end());
  st.build();
  for (int i = 0; i < m; i++) {
    v.clear();
    int cnt;
    cin >> cnt;
    ans = 0LL;
    for (int j = 0; j < cnt; j++) {
      int pos;
      cin >> pos;
      v.push_back(pos);
    }
    sort(v.begin(), v.end());
    for (int i = 0; i < (int)(v.size()); i++) {
      int val = v[i], nextval, index, temp;
      if (i != (int)(v.size()) - 1)
        nextval = v[i + 1];
      else
        nextval = 1000001;
      vector<pair<int, int> >::iterator it;
      it = upper_bound(seg.begin(), seg.end(), make_pair(val, 1000010));
      it--;
      index = it - seg.begin();
      if (index < 0)
        temp = 0;
      else
        temp = st.getValue(0, index, val, nextval);
      ans += ((long long int)temp);
    }
    cout << ans << "\n";
  }
  return 0;
}
