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