裴蜀定理的推广,不会的可以搜索一下,只要保证就行了。

#include <bits/stdc++.h>
using namespace std;
#define close ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define int long long 
#define endl '\n'
 
int a,b,c,m;
void solve(){ 
    cin >> a >> b >> c >> m;
    if(m % gcd(a,gcd(b,c)) == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
}
signed main(){
    close
    int T;cin >> T;
    while(T--){
        solve();
    }
    
    return 0;
}