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.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;

public class E369 {
	
	final int OPEN = 0, POINT = 1, CLOSE = 2;
	
	class Event implements Comparable<Event> {
		int type;
		int x, id;
		Event(int t, int a, int i) {
			type = t; x = a; id = i;
		}
		public int compareTo(Event e) {
			int ans = x - e.x;
			if(ans == 0) ans = type - e.type;
			return ans;
		}
	}
	
	public void solve(JS in, PrintWriter out) {
		final int N = (int) 1e6 + 100;
		int n = in.nextInt();
		int m = in.nextInt();
		ArrayList<Event> q = new ArrayList<>();
		for(int i = 0; i < n; ++i) {
			int l = in.nextInt(), r = in.nextInt();
			q.add(new Event(OPEN, l, i));
			q.add(new Event(CLOSE, r, i));
		}
		for(int i = 0; i < m; ++i) {
			int k = in.nextInt();
			for(int j = 0; j < k; ++j) {
				int x = in.nextInt();
				q.add(new Event(POINT, x, i));
			}
		}
		BIT bit = new BIT(N);
		Collections.sort(q);
		
		{
			int[] map = new int[n];
			int idx = 0;
			for(Event e : q) {
				if(e.type == OPEN) {
					map[e.id] = idx++;
					e.id = map[e.id];
				} else if(e.type == CLOSE) {
					e.id = map[e.id];
				}
			}
		}
		
		int[] prev = new int[m]; Arrays.fill(prev, -1);
		int running = -1;
		int[] ans = new int[m];
		
		for(Event e : q) {
			if(e.type == OPEN) {
				bit.update(e.id, 1);
				running = e.id;
			}
			else if(e.type == CLOSE) bit.update(e.id, -1);
			else {
				int cur = prev[e.id] + 1;
				int newSegs = bit.sum(cur, N);
				ans[e.id] += newSegs;
				prev[e.id] = running;
			}
		}
		
		for(int i : ans) out.println(i);
	}
	
	public static void main(String[] args) {
		JS in = new JS();
		PrintWriter out = new PrintWriter(System.out);
		new E369().solve(in, out);
		out.close();
	}
	
	static class BIT {
		int n;
		int[] tree;
		
		public BIT(int nn) {
			n = nn + 10;
			tree = new int[n + 1];
		}
		
		int read(int i) {
			i += 5;
			int sum = 0;
			while (i > 0) {
				sum += tree[i];
				i -= i & -i;
			}
			return sum;
		}
		
		int sum(int l, int r) {
			return read(r) - read(l - 1);
		}
		
		void update(int i, int val) {
			i += 5;
			while (i <= n) {
				tree[i] += val;
				i += i & -i;
			}
		}
	}
	
	static class JS {
		public int BS = 1<<16;
		public char NC = (char)0;
		byte[] buf = new byte[BS];
		int bId = 0, size = 0;
		char c = NC;
		double num = 1;
		BufferedInputStream in;

		public JS() {
			in = new BufferedInputStream(System.in, BS);
		}

		public JS(String s) throws FileNotFoundException {
			in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
		}

		public char nextChar(){
			while(bId==size) {
				try {
					size = in.read(buf);
				}catch(Exception e) {
					return NC;
				}
				if(size==-1)return NC;
				bId=0;
			}
			return (char)buf[bId++];
		}

		public int nextInt() {
			return (int)nextLong();
		}

		public long nextLong() {
			num=1;
			boolean neg = false;
			if(c==NC)c=nextChar();
			for(;(c<'0' || c>'9'); c = nextChar()) {
				if(c=='-')neg=true;
			}
			long res = 0;
			for(; c>='0' && c <='9'; c=nextChar()) {
				res = (res<<3)+(res<<1)+c-'0';
				num*=10;
			}
			return neg?-res:res;
		}

		public double nextDouble() {
			double cur = nextLong();
			return c!='.' ? cur:cur+nextLong()/num;
		}

		public String next() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c>32) {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public String nextLine() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c!='\n') {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public boolean hasNext() {
			if(c>32)return true;
			while(true) {
				c=nextChar();
				if(c==NC)return false;
				else if(c>32)return true;
			}
		}
	}
}