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