#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e16;
int main() {
  ios::sync_with_stdio(false);
  int n, q;
  cin >> n >> q;
  vector<int> v(n), c(n);
  for (int i = 0; i <= int((v).size()) - 1; i++) cin >> v[i];
  for (int i = 0; i <= int((c).size()) - 1; i++) cin >> c[i];
  for (int testcase = 1; testcase <= q; testcase++) {
    long long a, b;
    cin >> a >> b;
    vector<long long> value(n + 1, -inf);
    value[0] = 0;
    int first = 0, second = 1;
    for (int i = 0; i <= int((v).size()) - 1; i++) {
      long long va1 = value[c[i]] + a * v[i], va2;
      if (first == c[i])
        va2 = value[second] + b * v[i];
      else
        va2 = value[first] + b * v[i];
      if (max(va1, va2) > value[c[i]]) {
        value[c[i]] = max(va1, va2);
        if (value[c[i]] > value[first]) {
          second = first;
          first = c[i];
        } else if (value[c[i]] > value[second] && c[i] != first)
          second = c[i];
      }
    }
    cout << value[first] << '\n';
  }
  return 0;
}
