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