#include <bits/stdc++.h>
using namespace std;
const long long inf = (long long)4e18;
int n, q;
long long c[110000];
long long v[110000];
long long d[110000];
long long a, b;
pair<long long, int> m1;
pair<long long, int> m2;
long long get(int i, int ci) {
  long long res = max(b * v[i], d[ci]);
  res = max(res, d[ci] + a * v[i]);
  long long ept = m1.first;
  if (m1.second == ci) ept = m2.first;
  res = max(res, ept + b * v[i]);
  return res;
}
void solve() {
  m1 = m2 = make_pair(-inf, -1);
  for (int i = 0; i <= n; ++i) d[i] = -inf;
  for (int i = 0; i < n; ++i) {
    d[c[i]] = max(d[c[i]], get(i, c[i]));
    if (d[c[i]] > m1.first) {
      if (m1.second != c[i]) m2 = m1;
      m1 = make_pair(d[c[i]], c[i]);
    } else if (m1.second != c[i] && d[c[i]] > m2.first)
      m2 = make_pair(d[c[i]], c[i]);
  }
  cout << max(0LL, m1.first) << "\n";
}
int main() {
  ios::sync_with_stdio(0);
  cin >> n >> q;
  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;
    solve();
  }
}
