#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int b, p, f, h, c, i = 1, profit = 0;
    cin >> b >> p >> f >> h >> c;
    if (b > 1) {
      if (h > c) {
        while ((i < b) && (p > 0)) {
          profit = profit + h;
          i = i + 2;
          p--;
        }
        while ((i < b) && (f > 0)) {
          profit = profit + c;
          i = i + 2;
          f--;
        }
      } else {
        while ((i < b) && (f > 0)) {
          profit = profit + c;
          i = i + 2;
          f--;
        }
        while ((i < b) && (p > 0)) {
          profit = profit + h;
          i = i + 2;
          p--;
        }
      }
    } else
      profit = 0;
    cout << profit << "\n";
  }
}
