#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  vector<int> result;
  for (int i = 0; i < t; i++) {
    int b, p, f, h, c;
    cin >> b >> p >> f >> h >> c;
    int res = 0;
    b /= 2;
    if (h > c) {
      if (b - p > 0) {
        res += p * h;
        b -= p;
      } else {
        res += b * h;
        b = 0;
      }
      if (b > 0) {
        if (b > f) {
          res += f * c;
          b = 0;
        } else {
          res += b * c;
          b = 0;
        }
      }
    } else if (c > h) {
      if (b - f > 0) {
        res += f * c;
        b -= f;
      } else {
        res += b * c;
        b = 0;
      }
      if (b > 0) {
        if (b > p) {
          res += p * h;
          b = 0;
        } else {
          res += b * h;
          b = 0;
        }
      }
    } else {
      if (f + p <= b)
        res += (f + p) * h;
      else
        res += b * h;
    }
    result.push_back(res);
  }
  for (int i = 0; i < t; i++) cout << result.at(i) << endl;
  return 0;
}
