#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t, a = 0;
  cin >> t;
  while (a < t) {
    long long n, m, l, count = 0, add = 0, k, p, q;
    cin >> l >> m >> n;
    cin >> p >> q;
    if (p < q) {
      if (l / 2 > n) {
        count += n * q;
        l = l - 2 * n;
      } else {
        count += l / 2 * q;
        l = 0;
      }
      if (l > 0) {
        if (l / 2 > m) {
          count += m * p;
          l = l - 2 * p;
        } else {
          count += l / 2 * p;
          l = 0;
        }
      }
    } else {
      if (l / 2 > m) {
        count += m * p;
        l = l - 2 * m;
      } else {
        count += l / 2 * p;
        l = 0;
      }
      if (l > 0) {
        if (l / 2 > n) {
          count += m * q;
          l = l - 2 * q;
        } else {
          count += l / 2 * q;
          l = 0;
        }
      }
    }
    cout << count << "\n";
    a++;
  }
}
