#include using namespace std; #define int long long typedef vector vi; typedef pair pi; #define F first #define S second #define PB push_back #define MP make_pair #define popcount __builtin_popcountll int const MOD = 1e9 + 7; void swapp(int &a, int &b) { a = a ^ b; b = a ^ b; a = a ^ b; } int mul(int a, int b) { if (log10l(a) + log10l(b) > 18.3) return 3e18; return a * b; } #define forn(i, a, b) for (int i = a; i < b; i++) bool comp(pair a, pair b) { if (a.first == b.first) { return a.second > b.second; } return a.first < b.first; } void solve() { int n; cin>>n; int a,b,c; cin>>a>>b>>c; setst; int i = 1; int m = a; while(a <= n){ a = m * i; if(c > n){ break; } i++; st.insert(a); } i = 1; m = b; while(b <= n){ b = m * i; if(b > n){ break; } i++; st.insert(b); } i = 1; m = c; while(c <= n){ c = m * i; if(c > n){ break; } i++; st.insert(c); } cout<> t; forn(i,0,t){ solve(); } return 0; }