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