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