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 JAVA):

Solution:
import java.io.*;
import java.util.*;

public class ProblemEEE {

  
  static class Interval implements Comparable<Interval> {
    int l;
    int r;
    @Override
    public int compareTo(Interval f) {
      if(r < f.r) return -1;
      return 1;
    }
  }
  
  public static void main(String[] args) throws Exception {
    ParserdoubtEEE in = new ParserdoubtEEE(System.in);
    PrintWriter out = new PrintWriter(System.out);
    
    int n = in.nextInt();
    int m = in.nextInt();
    
    
    Interval it[] = new Interval[n];
    for (int i = 0; i < n; i++) {
      it[i] = new Interval();
      it[i].l = in.nextInt();
      it[i].r = in.nextInt();
    }
    Arrays.sort(it);
    
    ArrayList<Integer> p[] = new ArrayList[1000100];
    for (int i = 0; i < p.length; i++) {
      p[i] = new ArrayList<Integer>();
    }
    
    int lastPoint[] = new int[m];
    int count[] = new int[m];
    
    for (int i = 0; i < m; i++) {
      int cnt = in.nextInt();
      for (int j = 0; j < cnt; j++) {
        int pp = in.nextInt();
        p[pp].add(i);
      }
      p[p.length - 1].add(i);
    }

    tree = new int[1000100];

    int currInterval = 0;
    
    for (int i = 1; i < p.length; i++) {
      
      while(currInterval < it.length && it[currInterval].r < i){
        update(it[currInterval].l, 1);
        currInterval++;
      }
      
      for(int q : p[i]){
        count[q] += read(i) - read(lastPoint[q]);
        lastPoint[q] = i;
      }
    }
    
    for (int i = 0; i < m; i++) {
      out.println(n-count[i]);
    }
    
    out.close();
  }
  
  
  static int tree[];
  
  static void update(int idx, int value){
    while(idx < tree.length){
      tree[idx] += value;
      idx += idx & -idx;
    }
  }
  
  static int read(int idx){
    int sum = 0;
    while(idx > 0){
      sum += tree[idx];
      idx -= idx & -idx;
    }
    return sum;
  }
}


class ParserdoubtEEE
{
   final private int BUFFER_SIZE = 1 << 17;
 
   private DataInputStream din;
   private byte[] buffer;
   private int bufferPointer, bytesRead;
 
   public ParserdoubtEEE(InputStream in)
   {
      din = new DataInputStream(in);
      buffer = new byte[BUFFER_SIZE];
      bufferPointer = bytesRead = 0;
   }
   public String nextString() throws Exception
   {
       StringBuffer sb=new StringBuffer("");
       byte c = read();
       while (c <= ' ') c = read();
       do
       {
           sb.append((char)c);
           c=read();
       }while(c>' ');
       return sb.toString();
   }
   public char nextChar() throws Exception
   {
       byte c=read();
       while(c<=' ') c= read();
       return (char)c;
   }
   public int nextInt() throws Exception
   {
      int ret = 0;
      byte c = read();
      while (c <= ' ') c = read();
      boolean neg = c == '-';
      if (neg) c = read();
      do
      {
          ret = ret * 10 + c - '0';
         c = read();
      } while (c > ' ');
      if (neg) return -ret;
      return ret;
   }
   public long nextLong() throws Exception
   {
      long ret = 0;
      byte c = read();
      while (c <= ' ') c = read();
      boolean neg = c == '-';
      if (neg) c = read();
      do
      {
          ret = ret * 10 + c - '0';
         c = read();
      } while (c > ' ');
      if (neg) return -ret;
      return ret;
   }
   private void fillBuffer() throws Exception
   {
      bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
      if (bytesRead == -1) buffer[0] = -1;
   }
 
   private byte read() throws Exception
   {
      if (bufferPointer == bytesRead) fillBuffer();
      return buffer[bufferPointer++];
   }
}