#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  long long int t;
  cin >> t;
  while (t--) {
    long long int a, b, c;
    cin >> a >> b >> c;
    long long int h, d, cnt = 0;
    cin >> h >> d;
    if (h >= d) {
      cnt += (h * min(a / 2, b));
      long long int temp = min(a / 2, b);
      a = a - 2 * temp;
      b = b - temp;
      if (b == 0) {
        cnt += (d * min(a / 2, c));
      }
    } else {
      cnt += (d * min(a / 2, c));
      long long int temp = min(a / 2, c);
      a = a - 2 * temp;
      c = c - temp;
      if (c == 0) {
        cnt = cnt + (h * min(a / 2, b));
      }
    }
    cout << cnt << endl;
  }
  return 0;
}
