#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long b, p, f, h, c;
  cin >> b >> p >> f >> h >> c;
  long long total_buns = b / 2;
  long long profit = 0;
  if (h >= c) {
    long long k = min(p, total_buns);
    profit = k * h;
    total_buns = max(0LL, total_buns - k);
    profit += min(f, total_buns) * c;
    cout << profit << '\n';
  } else {
    long long k = min(f, total_buns);
    profit = k * c;
    total_buns = max(0LL, total_buns - k);
    profit += min(p, total_buns) * h;
    cout << profit << '\n';
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int testcase;
  cin >> testcase;
  while (testcase--) {
    solve();
  }
  return 0;
}
