#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, q;
    cin >> n >> q;
    vector<ll> v(n);
    vector<int> c(n);
    for (ll &x : v)
        cin >> x;
    for (int &x : c)
        cin >> x;
    const ll NEG = -(1LL << 60);
    while (q--) {
        ll a, b;
        cin >> a >> b;
        vector<ll> dp(n + 1, NEG);
        pair<ll, int> one = {NEG, -1}, two = one;
        ll answer = 0;
        for (int i = 0; i < n; i++) {
            int col = c[i];
            ll other = one.second == col ? two.first : one.first;
            ll cur = max(dp[col], v[i] * b);
            if (dp[col] != NEG)
                cur = max(cur, dp[col] + v[i] * a);
            if (other != NEG)
                cur = max(cur, other + v[i] * b);
            dp[col] = cur;
            if (one.second == col)
                one.first = cur;
            else if (two.second == col) {
                two.first = cur;
                if (two > one)
                    swap(one, two);
            } else if (cur > one.first) {
                two = one;
                one = {cur, col};
            } else if (cur > two.first)
                two = {cur, col};
            answer = max(answer, cur);
        }
        cout << answer << '\n';
    }
}
