#include <bits/stdc++.h>
using namespace std;
int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int br, bf, ch, a, b;
    cin >> br >> bf >> ch >> a >> b;
    int n = br >> 1;
    if (a < b) swap(a, b), swap(bf, ch);
    int ans = 0;
    int x = min(n, bf);
    n -= x, bf -= x;
    ans += (x * a);
    x = min(n, ch);
    n -= x, ch -= x;
    ans += (x * b);
    cout << ans << '\n';
  }
}
