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