#include <bits/stdc++.h>
using namespace std;
int stmp;
const int MAX = 100000;
const int INF = 1000000001;
int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(0);
  int n, q;
  cin >> n >> q;
  int v[n], c[n];
  for (int i = 0; i < (n); ++i) cin >> v[i];
  for (int i = 0; i < (n); ++i) cin >> c[i];
  while (q--) {
    long long a, b;
    long long res = 0;
    cin >> a >> b;
    vector<long long> dp(n + 1, -(long long)INF * INF);
    dp[0] = 0;
    pair<int, int> best(0, 0);
    for (int i = 0; i < (n); ++i) {
      int col = c[i];
      dp[col] = max(dp[col], dp[col] + a * v[i]);
      dp[col] = max(dp[col], b * v[i]);
      int t = best.first;
      if (t == col) t = best.second;
      dp[col] = max(dp[col], dp[t] + b * v[i]);
      if (dp[col] > dp[best.first]) {
        if (col != best.first) {
          best.second = best.first;
          best.first = col;
        }
      } else if (col != best.first && dp[col] > dp[best.second])
        best.second = col;
      res = max(res, dp[col]);
    }
    cout << res << '\n';
  }
  return 0;
}
