#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int a, b, c, d, e;
    cin >> a >> b >> c >> d >> e;
    a /= 2;
    int ans = 0;
    if (d > e) {
      ans = min(a, b) * d;
      a -= b;
      a = max(a, 0);
      ans += min(a, c) * e;
    } else {
      swap(b, c);
      swap(d, e);
      ans = min(a, b) * d;
      a -= b;
      a = max(a, 0);
      ans += min(a, c) * e;
    }
    cout << ans << endl;
  }
  return 0;
}
