#include <bits/stdc++.h>
using namespace std;
void file() {}
void fast() {
  std::ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
}
long long gcd(long long a, long long b) { return !b ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return (a / gcd(a, b)) * b; }
int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
char dir[] = {'U', 'R', 'D', 'L'};
const int N = 1e5 + 5, mod = 1e9 + 7;
pair<long long, int> mx1, mx2;
void relax(pair<long long, int> p) {
  if (p.second == mx1.second) {
    mx1.first = p.first;
    return;
  }
  if (p.first > mx1.first) {
    mx2 = mx1;
    mx1 = p;
    return;
  }
  mx2 = max(mx2, p);
}
int main() {
  file();
  fast();
  int n, q;
  cin >> n >> q;
  vector<int> a(n + 1), v(n + 1);
  for (int i = 1; i <= n; i++) cin >> v[i];
  for (int i = 1; i <= n; i++) cin >> a[i];
  while (q--) {
    long long x, y;
    cin >> x >> y;
    mx1 = mx2 = {-1e18, 0};
    vector<long long> ans(n + 1, -1e18);
    for (int i = 1; i <= n; i++) {
      ans[a[i]] = max({
          ans[a[i]],
          ans[a[i]] + v[i] * x,
          v[i] * y,
      });
      if (mx1.second != a[i])
        ans[a[i]] = max(ans[a[i]], v[i] * y + mx1.first);
      else
        ans[a[i]] = max(ans[a[i]], v[i] * y + mx2.first);
      relax({ans[a[i]], a[i]});
    }
    long long mx = 0;
    for (int i = 1; i <= n; i++) mx = max(mx, ans[i]);
    cout << mx << "\n";
  }
}
