#include <bits/stdc++.h>
using namespace std;
void solve() {
  int p, b, f, h, c, s = 0;
  cin >> b >> p >> f >> h >> c;
  b = b / 2;
  int s1 = min(b, p) * h + min((b - min(b, p)), f) * c;
  int s2 = min(b, f) * c + min((b - min(b, f)), p) * h;
  if (s1 >= s2)
    cout << s1 << endl;
  else
    cout << s2 << endl;
}
int main() {
  int t;
  cin >> t;
  while (t--) solve();
}
