#include <bits/stdc++.h>   #pragma warning(disable : 4996)   using namespace std;   bool compare(int a, int b) { return a > b; }   int main() {     int t, p, f, cnts, cntw, s, w;     scanf( %d , &t);     while (t--) {       scanf( %d%d , &p, &f);       scanf( %d%d , &cnts, &cntw);       scanf( %d%d , &s, &w);       if (s > w) {         int temp = s;         s = w;         w = temp;         temp = cnts;         cnts = cntw;         cntw = temp;       }       int mx = min(cnts, p / s);       int ans = 0;       for (int s1 = 0; s1 <= mx; s1++) {         int w1 = min(cntw, (p - s1 * s) / w);         int s2 = min(cnts - s1, f / s);         int w2 = min(cntw - w1, (f - s2 * s) / w);         ans = max(ans, s1 + s2 + w1 + w2);       }       printf( %d n , ans);     }     return 0;   }   