#include <bits/stdc++.h>
#pragma GCC optimize(2)
#pragma GCC optimize(3)
using namespace std;
template <class nmsl>
inline void read(nmsl &x) {
  x = 0;
  char ch = getchar(), w = 0;
  while (!isdigit(ch)) w = (ch == '-'), ch = getchar();
  while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
  x = w ? -x : x;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  int t;
  cin >> t;
  while (t--) {
    int b, p, f;
    int h, c;
    cin >> b >> p >> f >> h >> c;
    int prof = 0;
    b /= 2;
    if (h > c) {
      prof = min(b, p) * h;
      if (b > p) {
        b -= p;
        prof += min(b, f) * c;
      }
    } else {
      prof = min(b, f) * c;
      if (b > f) {
        b -= f;
        prof += min(b, p) * h;
      }
    }
    cout << prof << "\n";
  }
  return 0;
}
