#include <bits/stdc++.h>
using namespace std;
const int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
const int dj[] = {0, 1, 0, -1, -1, 1, -1, 1};
const long long MOD = 1e9 + 7;
const long long INF = 1e9;
const long double EPS = 1e-7;
struct Max {
  long long v1 = 0, v2 = 0;
  int c1 = -1, c2 = -1;
  void add(long long& v, long long& c) {
    if (c == c1)
      v1 = max(v1, v);
    else if (c == c2)
      v2 = max(v2, v);
    else if (v > v1) {
      v2 = v1, c2 = c2;
      v1 = v, c1 = c;
    } else if (v > v2)
      v2 = v, c2 = c;
    if (v1 < v2) {
      swap(v1, v2);
      swap(c1, c2);
    }
  }
};
int n, q;
vector<long long> v, c, nrst;
long long a, b;
int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  cin >> n >> q;
  v.resize(n);
  c = v;
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> c[i];
  }
  while (q--) {
    cin >> a >> b;
    long long r = 0;
    Max mx;
    vector<long long> dp(n + 1, LLONG_MIN / 2);
    for (int i = 0; i < n; i++) {
      dp[c[i]] = max(dp[c[i]], dp[c[i]] + v[i] * a);
      dp[c[i]] = max(dp[c[i]], (mx.c1 == c[i] ? mx.v2 : mx.v1) + v[i] * b);
      r = max(r, dp[c[i]]);
      mx.add(dp[c[i]], c[i]);
    }
    cout << r << endl;
  }
  cin.ignore(), cin.get();
}
