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