#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  long long n, q;
  cin >> n >> q;
  vector<long long> v(n), c(n);
  for (long long &i : v) cin >> i;
  for (long long &i : c) cin >> i;
  while (q--) {
    long long a, b;
    cin >> a >> b;
    vector<long long> dp(n + 1, (long long)-1e16);
    long long answer = 0, Max = 0, secondMax = 0;
    for (long long i = 0; i < n; ++i) {
      long long val = v[i], color = c[i];
      long long choose = Max, toUpdate;
      if (dp[color] == Max) {
        choose = secondMax;
      }
      toUpdate = max({dp[color], dp[color] + val * a, choose + val * b});
      if (Max != dp[color]) {
        if (Max < toUpdate)
          secondMax = Max, Max = toUpdate;
        else if (secondMax < toUpdate)
          secondMax = toUpdate;
      } else {
        if (Max < toUpdate) Max = toUpdate;
      }
      dp[color] = toUpdate;
      answer = max(answer, dp[color]);
    }
    cout << answer << '\n';
  }
  return 0;
}
