Problem: There are n balls. They are arranged in a row. Each ball has a color (for convenience an integer) and an integer value. The color of the i-th ball is ci and the value of the i-th ball is vi.

Squirrel Liss chooses some balls and makes a new sequence without changing the relative order of the balls. She wants to maximize the value of this sequence.

The value of the sequence is defined as the sum of following values for each ball (where a and b are given constants):

  * If the ball is not in the beginning of the sequence and the color of the ball is same as previous ball's color, add (the value of the ball)  ×  a. 
  * Otherwise, add (the value of the ball)  ×  b. 



You are given q queries. Each query contains two integers ai and bi. For each query find the maximal value of the sequence she can make when a = ai and b = bi.

Note that the new sequence can be empty, and the value of an empty sequence is defined as zero.

Input

The first line contains two integers n and q (1 ≤ n ≤ 105; 1 ≤ q ≤ 500). The second line contains n integers: v1, v2, ..., vn (|vi| ≤ 105). The third line contains n integers: c1, c2, ..., cn (1 ≤ ci ≤ n).

The following q lines contain the values of the constants a and b for queries. The i-th of these lines contains two integers ai and bi (|ai|, |bi| ≤ 105).

In each line integers are separated by single spaces.

Output

For each query, output a line containing an integer — the answer to the query. The i-th line contains the answer to the i-th query in the input order.

Please, do not write the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.

Examples

Input

6 3
1 -2 3 4 0 -1
1 2 1 2 1 1
5 1
-2 1
1 0


Output

20
9
4


Input

4 1
-3 6 -1 2
1 2 3 1
1 -1


Output

5

Note

In the first example, to achieve the maximal value:

  * In the first query, you should select 1st, 3rd, and 4th ball. 
  * In the second query, you should select 3rd, 4th, 5th and 6th ball. 
  * In the third query, you should select 2nd and 4th ball. 



Note that there may be other ways to achieve the maximal value.

Solution (in JAVA):

Solution:
import java.io.OutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.io.Writer;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author emotionalBlind
 */
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);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }
}

class TaskC {
    private static final long INF = (long) 1e18;
    public void solve(int testNumber, InputReader in, OutputWriter out) {
        int n = in.readInt();
        int q = in.readInt();

        int[] vs = IOUtils.readIntArray(in, n);
        int[] cs = IOUtils.readIntArray(in, n);

        int[] lastN = new int[n];

        for (int i = 0; i < q; ++i) {
            int a = in.readInt();
            int b = in.readInt();

            long res = solveQuery(vs, cs, a, b);
            out.printLine(res);
        }
    }

    private long solveQuery(int[] vs, int[] cs, int a, int b) {
        int n = vs.length;
        long[] colorBest = new long[n + 1];
        Arrays.fill(colorBest, -INF);

        int bestColor1 = 0;
        int bestColor2 = -1;
        colorBest[0] = 0;

        for (int i = 0; i < n; ++i) {
            long res = -INF;
            res = Math.max(res, (long)b * vs[i]);
            res = Math.max(res, colorBest[cs[i]] + (long) a * vs[i]);
            if (bestColor1 != cs[i]) {
                res = Math.max(colorBest[bestColor1] + (long) b * vs[i], res);
            }
            if (bestColor2 != cs[i] && bestColor2 != -1) {
                res = Math.max(colorBest[bestColor2] + (long) b * vs[i], res);
            }
            if (res > colorBest[cs[i]]) {
                colorBest[cs[i]] = res;
                if (cs[i] == bestColor1) {
                    // do nothing
                }  else {
                    if (cs[i] == bestColor2) {
                        if (colorBest[cs[i]] > colorBest[bestColor1]) {
                            bestColor2 = bestColor1;
                            bestColor1 = cs[i];
                        }
                    } else {
                        if (colorBest[cs[i]] > colorBest[bestColor1]) {
                            bestColor2 = bestColor1;
                            bestColor1 = cs[i];
                        } else if (bestColor2 == -1 || colorBest[cs[i]] > colorBest[bestColor2]) {
                            bestColor2 = cs[i];
                        }
                    }
                }
            }
        }
        return colorBest[bestColor1];
    }
}

class InputReader {

    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;

    public InputReader(InputStream stream) {
        this.stream = stream;
    }

    public int read() {
        // InputMismatchException -> UnknownError
        if (numChars == -1)
            throw new UnknownError();
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = stream.read(buf);
            } catch (IOException e) {
                throw new UnknownError();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    public int readInt() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        } else if (c == '+') {
            c = read();
        }
        int res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public static boolean isSpaceChar(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    }

class OutputWriter {
    private final PrintWriter writer;

    public OutputWriter(OutputStream outputStream) {
        writer = new PrintWriter(outputStream);
    }

    public OutputWriter(Writer writer) {
        this.writer = new PrintWriter(writer);
    }

    public void print(Object...objects) {
        for (int i = 0; i < objects.length; i++) {
            if (i != 0)
                writer.print(' ');
            writer.print(objects[i]);
        }
    }

    public void printLine(Object...objects) {
        print(objects);
        writer.println();
    }

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

}

class IOUtils {

    public static int[] readIntArray(InputReader in, int size) {
        int[] res = new int[size];
        for (int i = 0; i < size; ++i) {
            res[i] = in.readInt();
        }
        return res;
    }
}