#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t, b, p, f, h, c;
  cin >> t;
  while (t--) {
    int ans = 0;
    cin >> b >> p >> f;
    cin >> h >> c;
    if (h >= c) {
      while (1) {
        b = b - 2;
        p--;
        if (b < 0 || p < 0) break;
        ans += h;
      }
      b = b + 2;
      while (1) {
        b = b - 2;
        f--;
        if (b < 0 || f < 0) break;
        ans += c;
      }
    } else if (c > h) {
      while (1) {
        b = b - 2;
        f--;
        if (b < 0 || f < 0) break;
        ans += c;
      }
      b += 2;
      while (1) {
        b = b - 2;
        p--;
        if (b < 0 || p < 0) break;
        ans += h;
      }
    }
    cout << ans << endl;
  }
  return 0;
}
