#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, b, p, f, h, c;
  cin >> t;
  for (int i = 0; i < t; i++) {
    cin >> b >> p >> f;
    cin >> h >> c;
    int paisa = 0;
    if (b % 2 != 0) b--;
    if (h > c) {
      while (b > 0 && p > 0) {
        b -= 2;
        p--;
        paisa += h;
      }
      while (b > 0 && f > 0) {
        b -= 2;
        f--;
        paisa += c;
      }
      cout << paisa << "\n";
    } else {
      while (b > 0 && f > 0) {
        b -= 2;
        f--;
        paisa += c;
      }
      while (b > 0 && p > 0) {
        b -= 2;
        p--;
        paisa += h;
      }
      cout << paisa << "\n";
    }
  }
  return 0;
}
