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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.FileNotFoundException;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import java.io.Writer;
import java.io.BufferedReader;
import java.io.FileReader;
import java.util.Comparator;
import java.util.Collections;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    InputReader in = new InputReader(inputStream);
    OutputWriter out = new OutputWriter(outputStream);
    ValeraOtrezki solver = new ValeraOtrezki();
    solver.solve(1, in, out);
    out.close();
  }

  static class ValeraOtrezki extends SimpleSavingChelperSolution {
    public void solve(int testNumber, InputReader in, OutputWriter out) {
      wrapSolve(testNumber, in, out);
    }


    public void solve(int testNumber) {
      int intervalCount = in.nextInt();
      int queryCount = in.nextInt();

      List<int[]> intervals = new ArrayList<>();

      for (int i = 0; i < intervalCount; i++) {
        intervals.add(new int[]{in.nextInt(), in.nextInt() + 1});
      }

      Comparator<int[]> comparator = new Comparator<int[]>() {

        public int compare(int[] o1, int[] o2) {
          int t = Integer.compare(o1[1], o2[1]);
          if (t != 0) {
            return t;
          }
          return Integer.compare(o1[0], o2[0]);
        }
      };

      Collections.sort(intervals, comparator);

//    List<List<Integer>> queries = new ArrayList<>();
      int[] queryAnswers = new int[queryCount];

      int MAX = 1001000;
      Tree tree = new Tree(0, MAX);

      List<int[]> points = new ArrayList<>();

//    Tree tree = new Tree(0, 1000);

      for (int i = 0; i < queryCount; i++) {
        int pointCount = in.nextInt();
//      queries.add(new ArrayList<>());

        int prev = 0;

        for (int j = 0; j < pointCount; j++) {
          int point = in.nextInt();
//        queries.get(i).add(point);
          points.add(new int[]{i, point, prev});
          prev = point;

//        tree.add(point);
        }

        points.add(new int[]{i, MAX - 1, prev});
      }

      Collections.sort(points, comparator);


      int nextInterval = 0;

      for (int[] point : points) {
        int queryI = point[0];
        int x = point[1];
        int prevX = point[2];

        while (nextInterval < intervalCount && intervals.get(nextInterval)[1] <= x) {
          tree.add(intervals.get(nextInterval)[0]);

          nextInterval++;
        }

        int matching = tree.get(prevX + 1, x);

        queryAnswers[queryI] += matching;
      }

      for (int i = 0; i < queryCount; i++) {
        out.println(intervalCount - queryAnswers[i]);
      }

    /*Random random = new Random();

    for (int i = 0; i < 100; i++) {
      int l = random.nextInt(100) + 1;
      int r = random.nextInt(100) + 1;

      if (r < l) {
        int t = l;
        l = r;
        r = t;
      }

      int res1 = tree.get(l, r);
      int res2 = 0;

      for (int[] j : points) {
        if (j[1] < r && j[1] >= l) {
          res2++;
        }
      }

      out.println(res1 + " " + res2);
    }*/
    }

    class Tree {
      final int l;
      final int r;
      final int m;
      int sum = 0;
      Tree cl;
      Tree cr;

      public Tree(int l, int r) {
        this.l = l;
        this.r = r;

        m = (l + r) / 2;

//      if (r - l == 1) {
//        return;
//      }

//      cl = new Tree(l, m);
//      cr = new Tree(m, r);
      }

      void add(int x) {
        sum += 1;

        if (r - l == 1) {
          return;
        }

        if (x < m) {
          if (cl == null) {
            cl = new Tree(l, m);
          }
          cl.add(x);
        } else {
          if (cr == null) {
            cr = new Tree(m, r);
          }
          cr.add(x);
        }
      }

      int get(int ll, int rr) {
        if (ll == l && rr == r) {
          return sum;
        }

        int res = 0;

        if (ll < m && cl != null) {
          res += cl.get(ll, Math.min(m, rr));
        }

        if (rr > m && cr != null) {
          res += cr.get(Math.max(m, ll), rr);
        }

        return res;
      }

    }

  }

  static abstract class SavingChelperSolution {
    protected int testNumber;
    public InputReader in;
    public OutputWriter out;
    private OutputWriter toFile;
    private boolean local = new File("chelper.properties").exists();
    public OutputWriter debug;

    {
      if (local) {
        debug = new OutputWriter(System.out);
      } else {
        debug = new OutputWriter(new OutputStream() {

          public void write(int b) {
          }
        });
      }
    }

    public SavingChelperSolution() {
      try {
        toFile = new OutputWriter("last_test_output.txt");
      } catch (FileNotFoundException e) {
        throw new RuntimeException(e);
      }
    }

    public abstract void solve(int testNumber);

    public abstract String processOutputPreCheck(int testNumber, String output);

    public abstract String processOutputPostCheck(int testNumber, String output);

    public void wrapSolve(int testNumber, InputReader in, OutputWriter out) {
      this.testNumber = testNumber;

      ByteArrayOutputStream substituteOutContents = new ByteArrayOutputStream();
      OutputWriter substituteOut = new OutputWriter(substituteOutContents);

      this.in = in;
      this.out = substituteOut;

      solve(testNumber);
      substituteOut.flush();

      String result = substituteOutContents.toString();

      result = processOutputPreCheck(testNumber, result);
      out.print(result);
      out.flush();

      if (local) {
        debug.flush();

        result = processOutputPostCheck(testNumber, result);
        toFile.print(result);
        toFile.flush();
      }
    }

  }

  static class InputReader {
    private BufferedReader br;
    private StringTokenizer in;

    public InputReader(String fileName) {
      try {
        br = new BufferedReader(new FileReader(fileName));
      } catch (IOException e) {
        throw new RuntimeException(e);
      }
    }

    public InputReader(InputStream inputStream) {
      br = new BufferedReader(new InputStreamReader(inputStream));
    }

    private boolean hasMoreTokens() {
      while (in == null || !in.hasMoreTokens()) {
        String s = nextLine();
        if (s == null) {
          return false;
        }
        in = new StringTokenizer(s);
      }
      return true;
    }

    public String nextString() {
      return hasMoreTokens() ? in.nextToken() : null;
    }

    public String nextLine() {
      try {
        in = null;
        return br.readLine();
      } catch (Exception e) {
        e.printStackTrace();
        return null;
      }
    }

    public int nextInt() {
      return Integer.parseInt(nextString());
    }

  }

  static class OutputWriter extends PrintWriter {

    public void close() {
      super.close();
    }

    public OutputWriter(String fileName) throws FileNotFoundException {
      super(fileName);
    }

    public OutputWriter(OutputStream outputStream) {
      super(outputStream);
    }

    public OutputWriter(Writer writer) {
      super(writer);
    }

  }

  static abstract class SimpleSavingChelperSolution extends SavingChelperSolution {

    public String processOutputPreCheck(int testNumber, String output) {
      return output;
    }


    public String processOutputPostCheck(int testNumber, String output) {
      return output;
    }

  }
}