#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
template <class T>
ostream& operator<<(ostream& os, vector<T> V) {
  os << "[ ";
  for (auto v : V) os << v << " ";
  return os << "]";
}
template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> P) {
  return os << "(" << P.first << "," << P.second << ")";
}
template <typename T, typename U>
pair<T, U> operator+(const pair<T, U>& l, const std::pair<T, U>& r) {
  return {l.first + r.first, l.second + r.second};
}
const long long int mod = 1e18;
const long long int MAX_NODES = 200001;
const long long int MAX_LOG = 50;
const long long int maxn = 5e5 + 8;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n, q;
  cin >> n >> q;
  long long int val[n + 1], c[n + 1];
  for (long long int i = 1; i <= n; i++) cin >> val[i];
  for (long long int i = 1; i <= n; i++) cin >> c[i];
  while (q--) {
    long long int a, b;
    cin >> a >> b;
    vector<long long int> dp(n + 1, -1e12);
    vector<pair<long long int, long long int>> maxes;
    maxes.push_back(make_pair(0, -1));
    for (long long int i = 1; i <= n; i++) {
      long long int pos;
      for (long long int j = 0; j < maxes.size(); j++)
        if (maxes[j].second != c[i]) {
          pos = j;
          break;
        }
      dp[c[i]] = max(dp[c[i]],
                     max(dp[c[i]] + val[i] * a, maxes[pos].first + val[i] * b));
      pos = -1;
      for (long long int j = 0; j < maxes.size(); j++) {
        if (maxes[j].second == c[i]) {
          pos = j;
          maxes[j].first = max(maxes[j].first, dp[c[i]]);
          break;
        }
      }
      if (pos == -1) {
        maxes.push_back({dp[c[i]], c[i]});
      }
      sort(maxes.rbegin(), maxes.rend());
      if (maxes.size() > 2) maxes.pop_back();
    }
    cout << maxes[0].first << " ";
  }
}
