#include <bits/stdc++.h>
using namespace std;
const double PI = 2.0 * acos(0.0);
const double EPS = 1e-6;
int v[100005];
int c[100005];
long long dp[100005];
long long process(long long a, long long b, int n) {
  fill(dp, dp + n + 1, (long long)-1e16);
  int max1 = 0;
  int max2 = 0;
  for (int i = 0; i < n; i++) {
    long long tmp = (long long)-1e16;
    if (c[i] != max1)
      tmp = max(tmp, dp[max1] + v[i] * b);
    else if (c[i] != max2)
      tmp = max(tmp, dp[max2] + v[i] * b);
    if (dp[c[i]] != (long long)-1e16) tmp = max(tmp, dp[c[i]] + v[i] * a);
    tmp = max(tmp, v[i] * b);
    if (tmp > dp[c[i]]) {
      dp[c[i]] = tmp;
      if (c[i] == max1 || c[i] == max2) {
        if (dp[max2] > dp[max1]) swap(max1, max2);
      } else {
        if (dp[c[i]] > dp[max1]) {
          max2 = max1;
          max1 = c[i];
        } else if (dp[c[i]] > dp[max2])
          max2 = c[i];
      }
    }
  }
  long long res = 0LL;
  for (int cr = 1; cr <= n; cr++) res = max(res, dp[cr]);
  return res;
}
int main() {
  int n, q;
  scanf("%d %d", &n, &q);
  for (int i = 0; i < n; i++) scanf("%d", v + i);
  for (int i = 0; i < n; i++) scanf("%d", c + i);
  while (q--) {
    int a, b;
    scanf("%d %d", &a, &b);
    printf("%I64d\n", process((long long)a, (long long)b, n));
  }
  return 0;
}
