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