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