the soldier of love

Accepts: 14
Submissions: 43
Time Limit: 20000/10000 MS (Java/Others)
Memory Limit: 131072/131072 K (Java/Others)
Problem Description
Two days ago, the soldier of love ask a question to me.The problem can be described by linear programming. For this question, I find that I can't solve it.after that, ZZQ told me that it can be transformed into an equivalent problem: At first there are $N(1 \leq N \leq 3*10^{5})$segments, the i-th segment cover interval$[L_i, R_i]$($1 \leq L_i \leq R_i \leq 10^{6}$) Then there are $M (1 \leq M \leq 3*10^{5})$ groups, the i-th group contains $K_i(1 \leq K_i \leq 3*10^{5}$) points's positions, which are respectively $P_1, P_2, ......, P_{k_i}$. For Convenience, we make $1 \leq P_1 < P_2 < ...... < P_{k_i} \leq 10^{6}$ we can also know the total number of points in all groups is no more than $3*10^5$ now the problem is that for each group, we want to know the total number of the segments, which include at least one given point in this group.
Input
Multiple cases of data (no more than 30 cases) For each case, the first line contains two integers N and M, respectively, indicating the number of segments and M group. The next N lines, each line contains two integers$L_i$ and $R_i$, represents the start and end positions of ith segment. The next M lines, each line describes a group. Each line gives an integer K first, indicating the number of points in this group.Then K points' positions will be given in order.
Output
for each group,output the number of lines that contain at least one point in this group.
Sample Input
3 3
1 3
4 5
6 7
3 1 4 7
2 4 5
1 8
Sample Output
3
1
0