#include <bits/stdc++.h>
using namespace std;
int a[200005], b[100005], vis[100005];
int n, m, t = 0;
int main() {
  int b, p, f, h, c, ans;
  cin >> t;
  while (t--) {
    ans = 0;
    cin >> b >> p >> f;
    cin >> h >> c;
    if (h > c) {
      int temp1 = min(b / 2, p);
      b = b - temp1 * 2;
      ans = ans + temp1 * h;
      int temp2 = min(b / 2, f);
      ans = ans + temp2 * c;
    } else {
      int temp1 = min(b / 2, f);
      b = b - temp1 * 2;
      ans = ans + temp1 * c;
      int temp2 = min(b / 2, p);
      ans = ans + temp2 * h;
    }
    cout << ans << endl;
  }
  return 0;
}
