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.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.text.DecimalFormat;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;
import java.util.Queue;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
public class Main {
    int n, q, a, b;
    int[] v = new int[N], c = new int[N];
    long[] dp = new long[N];
    int[] pre = new int[N];
    long max1, max2;
    int col1, col2;
    void up(long val, int col){
        if(val>=max1){
            if(val>max1){
                if(col == col1){
                    max1 = val;
                }
                else {
                    max2 = max1; col2 = col1;
                    max1 = val; col1 = col;         
                }
            }
            else if(col!=col1){
                max2 = val; col2 = col;             
            }
        }
        else if(val >= max2){
            if(col == col1)return;
            max2 = val; col2 = col;
        }
    }
    void work() throws Exception{
        n = Int(); q = Int();
        for(int i = 1; i <= n; i++)v[i] = Int();
        for(int i = 1; i <= n; i++)c[i] = Int();        
        
        while(q-->0){
            a = Int(); b = Int();
            long ans = 0;
            max1 = -inf64; max2 = -inf64;
            col1 = 0; col2 = 0;
            for(int i = 1; i <= n; i++)pre[i] = -1;
            for(int i = 1; i <= n; i++){
                long now = (long)v[i]*b;
                if(pre[c[i]]!=-1){
                    now = max(now, dp[c[i]] + (long)a*v[i]);
            //      out.print("now1:"+now);
                }
                if(col1!=c[i] && col1!=0)now = max(now, max1 + (long)b*v[i]);
                else if(col2!=c[i] && col2!=0)now = max(now, max2 + (long)b*v[i]);
            //  out.println(" now2:"+now);
                
                up(now, c[i]);
                if(pre[c[i]] == -1)dp[c[i]] = now;
                else 
                dp[c[i]] = max(dp[c[i]], now);
                pre[c[i]] = i;
                ans = max(ans, now);
            //  out.println(max1+" "+col1); out.println(max2+" "+col2); out.println(now+" "+ans+" ***");
            }
            out.println(ans);
        }
    }

    public static void main(String[] args) throws Exception{
        Main wo = new Main();
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
  //    in = new BufferedReader(new InputStreamReader(new FileInputStream(new File("input.txt"))));
  //    out = new PrintWriter(new File("output.txt"));
        wo.work();
        out.close();
    }

    static int N = 100000+5;
    static int M = 101;
    DecimalFormat df=new DecimalFormat("0.0000");
    static int inf = (int)1e9;
    static long inf64 = (long) 1e18;
    static double eps = 1e-8;
    static double Pi = Math.PI;
    static int mod = (int)1e9 + 7 ;
    
    private String Next() throws Exception{
        while (str == null || !str.hasMoreElements())
            str = new StringTokenizer(in.readLine());
        return str.nextToken();
    }
    private int Int() throws Exception{
        return Integer.parseInt(Next());
    }
    private long Long() throws Exception{
        return Long.parseLong(Next());
    }
    private double Double() throws Exception{
        return Double.parseDouble(Next());
    }
    StringTokenizer str;
    static Scanner cin = new Scanner(System.in);
    static BufferedReader in;
    static PrintWriter out;
  /*  
    class Edge{
        int from, to, dis, nex;
        Edge(){}
        Edge(int from, int to, int dis, int nex){
            this.from = from;
            this.to = to;
            this.dis = dis;
            this.nex = nex;
        }
    }
    Edge[] edge = new Edge[M<<1];
    int[] head = new int[N];
    int edgenum;
    void init_edge(){for(int i = 0; i < N; i++)head[i] = -1; edgenum = 0;}
    void add(int u, int v, int dis){
        edge[edgenum] = new Edge(u, v, dis, head[u]);
        head[u] = edgenum++;
    }/**/
    int upper_bound(int[] A, int l, int r, int val) {// upper_bound(A+l,A+r,val)-A;
        int pos = r;
        r--;
        while (l <= r) {
            int mid = (l + r) >> 1;
            if (A[mid] <= val) {
                l = mid + 1;
            } else {
                pos = mid;
                r = mid - 1;
            }
        }
        return pos;
    }

    int Pow(int x, int y) {
        int ans = 1;
        while (y > 0) {
            if ((y & 1) > 0)
                ans *= x;
            y >>= 1;
            x = x * x;
        }
        return ans;
    }
    double Pow(double x, int y) {
        double ans = 1;
        while (y > 0) {
            if ((y & 1) > 0)
                ans *= x;
            y >>= 1;
            x = x * x;
        }
        return ans;
    }
    int Pow_Mod(int x, int y, int mod) {
        int ans = 1;
        while (y > 0) {
            if ((y & 1) > 0)
                ans *= x;
            ans %= mod;
            y >>= 1;
            x = x * x;
            x %= mod;
        }
        return ans;
    }
    long Pow(long x, long y) {
        long ans = 1;
        while (y > 0) {
            if ((y & 1) > 0)
                ans *= x;
            y >>= 1;
            x = x * x;
        }
        return ans;
    }
    long Pow_Mod(long x, long y, long mod) {
        long ans = 1;
        while (y > 0) {
            if ((y & 1) > 0)
                ans *= x;
            ans %= mod;
            y >>= 1;
            x = x * x;
            x %= mod;
        }
        return ans;
    }

    int gcd(int x, int y){
        if(x>y){int tmp = x; x = y; y = tmp;}
        while(x>0){
            y %= x;
            int tmp = x; x = y; y = tmp;
        }
        return y;
    }
    int max(int x, int y) {
        return x > y ? x : y;
    }

    int min(int x, int y) {
        return x < y ? x : y;
    }

    double max(double x, double y) {
        return x > y ? x : y;
    }

    double min(double x, double y) {
        return x < y ? x : y;
    }

    long max(long x, long y) {
        return x > y ? x : y;
    }

    long min(long x, long y) {
        return x < y ? x : y;
    }

    int abs(int x) {
        return x > 0 ? x : -x;
    }

    double abs(double x) {
        return x > 0 ? x : -x;
    }

    long abs(long x) {
        return x > 0 ? x : -x;
    }

    boolean zero(double x) {
        return abs(x) < eps;
    }
    double sin(double x){return Math.sin(x);}
    double cos(double x){return Math.cos(x);}
    double tan(double x){return Math.tan(x);}
    double sqrt(double x){return Math.sqrt(x);}
}