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.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class E {	
	BufferedReader reader;
    StringTokenizer tokenizer;
    PrintWriter out;
    
    // NOTE: element start from 1
    public class FenwickTree{
    	long[] element;
		public FenwickTree(int size) {
			element = new long[size+1];
		}		
		public void add(int index, long delta) {
			while (index < element.length) {
				element[index] += delta;
				index += (index & -index);
			}				
		}
		public long getcum(int index) {
			long sum = 0;
			while (index > 0) {
				sum += element[index];
				index -= (index & -index);
			}
			return sum;
		}
		public long getrange(int from, int to) {
			return getcum(to) - (from > 0? getcum(from-1): 0);
		}
	}
    
    int MAX = 1000002;
	public void solve() throws IOException {				
		int N = nextInt();
		int M = nextInt();

		ArrayList<Integer>[] segments = new ArrayList[MAX+1];
		for (int i = 0; i < N; i++) {
			int L = nextInt();
			int R = nextInt();
			if (segments[R] == null) {
				segments[R] = new ArrayList<Integer>();				
			}
			segments[R].add(L);
		}
		
		ArrayList<int[]>[] points = new ArrayList[MAX+1];	
		points[MAX] = new ArrayList<int[]>();
		for (int i = 0; i < M; i++) {
			int cnt = nextInt();
			int[] qp = new int[cnt];
			for (int j = 0; j < cnt; j++) {
				qp[j] = nextInt();
				
				if (points[qp[j]-1] == null) {
					points[qp[j]-1] = new ArrayList<int[]>();
				}
			}
			
			points[qp[0]-1].add(new int[] {i, 1});			
			for (int j = 1; j < cnt; j++) {
				if (qp[j] - qp[j-1] > 1) {
					points[qp[j]-1].add(new int[] {i, qp[j-1]+1});
				}
			}
			points[MAX].add(new int[] {i, qp[cnt-1]+1});
		}
				
		int[] ans = new int[M];
		FenwickTree tree = new FenwickTree(MAX+1);
		for (int i = 1; i <= MAX; i++) {
			if (segments[i] != null) {
				for (int seg_start: segments[i]) {
					tree.add(seg_start, 1);
				}
			}
			
			if (points[i] != null) {
				for (int[] pt: points[i]) {
					ans[pt[0]] += tree.getrange(pt[1], i);
				}
			}
		}
		
		for (int i = 0; i < M; i++){
			out.println(N - ans[i]);
		}
		
	}
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		new E().run();
	}
	
	public void run() {
        try {
            reader = new BufferedReader(new InputStreamReader(System.in));
            tokenizer = null;
            out = new PrintWriter(System.out);
            solve();
            reader.close();
            out.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }

}