#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, b, p, f, h, c;
  cin >> t;
  vector<int> arr(t);
  for (int i = 0; i < t; ++i) {
    cin >> b >> p >> f;
    cin >> h >> c;
    if (h > c) {
      while (b >= 2 && p > 0) {
        arr[i] = arr[i] + h;
        b = b - 2;
        p--;
      }
      while (b >= 2 && f > 0) {
        arr[i] = arr[i] + c;
        b = b - 2;
        f--;
      }
    } else {
      while (b >= 2 && f > 0) {
        arr[i] = arr[i] + c;
        b = b - 2;
        f--;
      }
      while (b >= 2 && p > 0) {
        arr[i] = arr[i] + h;
        b = b - 2;
        p--;
      }
    }
  }
  for (int i = 0; i < t; ++i) {
    cout << arr[i] << endl;
  }
  return 0;
}
