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