#include <bits/stdc++.h>
using namespace std;
const int Maxn = 100 * 1000 + 5, Max = 500;
const long long num = -1e18;
int n, q;
long long dp[Maxn], a, b, val[Maxn], col[Maxn];
void filldp() {
  int ind1 = 0, ind2 = 0;
  for (int i = 0; i < n; i++) {
    long long v1 = dp[col[i]] + a * val[i];
    if (dp[col[i]] == num) v1 = num;
    int ind = ind1;
    if (ind == col[i]) ind = ind2;
    long long v2 = dp[ind] + b * val[i];
    if (dp[ind] == num) v2 = num;
    dp[col[i]] = max(dp[col[i]], max(v1, v2));
    if (dp[col[i]] >= dp[ind1]) {
      if (col[i] != ind1) {
        ind2 = ind1;
        ind1 = col[i];
      }
    } else {
      if (dp[col[i]] > dp[ind2]) ind2 = col[i];
    }
  }
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> q;
  for (int i = 0; i < n; i++) cin >> val[i];
  for (int i = 0; i < n; i++) cin >> col[i];
  for (int i = 0; i < q; i++) {
    cin >> a >> b;
    for (int j = 1; j < Maxn; j++) dp[j] = num;
    filldp();
    long long ans = 0;
    for (int j = 0; j < Maxn; j++) ans = max(ans, dp[j]);
    cout << ans << endl;
  }
  return 0;
}
