#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int b, p, f, h, c, res = 0;
    cin >> b >> p >> f >> h >> c;
    b = b / 2;
    if (h >= c) {
      res += min(b, p) * h;
      b -= min(b, p);
      res += min(b, f) * c;
    } else {
      res += min(b, f) * c;
      b -= min(b, f);
      res += min(b, p) * h;
    }
    cout << res;
    if (t) cout << '\n';
  }
  return 0;
}
