#include <bits/stdc++.h>   using namespace std;   int main() {     long long int t;     cin >> t;     while (t--) {       long long int a, b, c, d, e, y = 0, x = 0, l = 0, z = 0, k = 0, m = 0;       cin >> a >> b >> c >> d >> e;       if (d > e) {         while (a > 1 && b > 0) {           y++;           a = a - 2;           b = b - 1;         }         while (a > 1 && c > 0) {           x++;           a = a - 2;           c = c - 1;         }         l = (d * y) + (x * e);         cout << l << endl;       } else {         while (a > 1 && c > 0) {           z++;           a = a - 2;           c = c - 1;         }         while (a > 1 && b > 0) {           k++;           a = a - 2;           b = b - 1;         }         m = (e * z) + (k * d);         cout << m << endl;       }       y = 0, x = 0, l = 0, z = 0, k = 0, m = 0;     }     return 0;   }   