#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, q;
  cin >> n >> q;
  long long v[n + 1];
  for (long long i = 0, _n = (n); i < _n; i++) {
    cin >> v[i + 1];
  }
  long long c[n + 1];
  for (long long i = 0, _n = (n); i < _n; i++) {
    cin >> c[i + 1];
  }
  while (q--) {
    long long a, b;
    cin >> a >> b;
    long long dp[n + 1];
    memset((dp), 0, sizeof((dp)));
    long long ind = 0;
    long long ind2 = 0;
    for (long long i = (1), _b = (n); i <= _b; i++) {
      dp[i] = -1000000000000000000;
    }
    for (long long i = (1), _b = (n); i <= _b; i++) {
      long long xx = a * v[i];
      long long yy = b * v[i];
      long long col = c[i];
      if (col != ind) {
        dp[col] = max({dp[col], dp[ind] + yy, dp[col] + xx});
      } else if (col != ind2) {
        dp[col] = max({dp[col], dp[col] + xx, dp[ind2] + yy});
      }
      if (col == ind2) {
        if (dp[col] > dp[ind]) swap(ind, ind2);
      } else if (col != ind2 && col != ind) {
        if (dp[col] > dp[ind]) {
          ind2 = ind;
          ind = col;
        } else if (dp[col] > dp[ind2]) {
          ind2 = col;
        }
      }
    }
    cout << dp[ind] << endl;
  }
}
