#include <bits/stdc++.h>
using namespace std;
bool comp(int a, int b) { return (a < b); }
int main() {
  long long int ans = 0;
  long long int t, b, p, f, h, c, n, l, r, k, flag;
  cin >> t;
  while (t--) {
    cin >> b >> p >> f;
    cin >> h >> c;
    if (b < 2) {
      cout << 0 << endl;
      continue;
    }
    k = 0;
    int req = b / 2;
    if (h > c) {
      if (req >= p) {
        k += p * h;
        if ((req - p) >= f) {
          k += f * c;
        } else {
          k += c * (req - p);
        }
      } else {
        k += h * (req);
      }
    } else {
      if (req >= f) {
        k += f * c;
        if ((req - f) >= p) {
          k += p * h;
        } else {
          k += h * (req - f);
        }
      } else {
        k += c * (req);
      }
    }
    cout << k << endl;
  }
  return 0;
}
