#include <bits/stdc++.h>
using namespace std;
int t, b, p, f, h, c;
int main() {
  cin >> t;
  for (int i = 0; i < t; i++) {
    cin >> b >> p >> f >> h >> c;
    b = b / 2;
    if (h < c) {
      swap(h, c);
      swap(p, f);
    }
    int y = 0;
    int x = min(b, p);
    b = b - x;
    p = p - x;
    y = y + h * x;
    x = min(b, f);
    b = b - x;
    f = f - x;
    y = y + c * x;
    cout << y << "\n";
  }
}
