#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100 * 1000;
int N, Q;
int V[MAXN + 10], C[MAXN + 10];
long long A, B;
long long dp[MAXN + 10];
const long long INF = numeric_limits<long long>::max();
long long calc_dp() {
  for (int c = 1; c <= N; c++) {
    dp[c] = -INF;
  }
  dp[0] = 0;
  int mc[2] = {0, -1};
  for (int i = 0; i < N; i++) {
    int c = C[i];
    if (dp[c] != -INF) dp[c] = max(dp[c], dp[c] + A * V[i]);
    if (mc[0] != c)
      dp[c] = max(dp[c], dp[mc[0]] + B * V[i]);
    else
      dp[c] = max(dp[c], dp[mc[1]] + B * V[i]);
    if (dp[c] > dp[mc[0]]) {
      mc[1] = mc[0];
      mc[0] = c;
    } else if (mc[0] != c && (mc[1] == -1 || dp[c] > dp[mc[1]])) {
      mc[1] = c;
    }
  }
  return dp[mc[0]];
}
int main() {
  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);
  }
  for (int q = 0; q < Q; q++) {
    scanf("%lld%lld", &A, &B);
    printf("%lld\n", calc_dp());
  }
}
