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