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