#include <bits/stdc++.h>
using namespace std;
int main() {
  int t = 0, b = 0, p = 0, f = 0, h = 0, c = 0, max = -1;
  cin >> t;
  for (int i = 0; i < t; ++i) {
    cin >> b >> p >> f >> h >> c;
    int bu = b / 2;
    int g = 0, k = 0;
    if (h > c) {
      if (p <= bu) {
        g = p;
        k = min(f, bu - p);
      } else {
        g = bu;
      }
    } else {
      if (f <= bu) {
        k = f;
        g = min(p, bu - f);
      } else {
        k = bu;
      }
    }
    max = g * h + k * c;
    cout << max << endl;
  }
  return 0;
}
