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