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