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