#include <bits/stdc++.h>
using namespace std;
#define all(a)a.begin(),a.end()
#define rall(a)a.rbegin(),a.rend()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
const int mod2=998244353;
using P = pair<int,int>;
using Pl= pair<ll,ll>;
using ld=long double;
using V=vector<int>;
using Vl=vector<ll>;
using Vd=vector<ld>;
using VV=vector<vector<int>>;
using VVl=vector<vector<ll>>;
using VVd=vector<vector<ld>>;

int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}

//return (x,y,gcd(a,b)) s.t. ax+by=gcd(a,b)
pair<Pl,ll> extgcd(ll a,ll b){
    if(b==0)return {{1,0},a};
    else{
        auto res=extgcd(b,a%b);
        ll X=res.first.first;
        ll Y=res.first.second;
        ll g=res.second;
        //bX+(a%b)Y=g
        //a=a/b*b+a%b
        //bX+(-a/b*b+a)Y=g
        //aY+b(X-a/b*Y)=g
        return {{Y,X-a/b*Y},g};
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;cin  >>t;
//    int b=13;
//    for (int a = 1; a <= b; ++a) {
//        int ex=extgcd(a,b).first.first;
//        ex%=b;
//        if(ex<0)ex+=b;
//        if(a*ex%b!=1){
//            puts("NG");
//            cout <<a<<" "<<ex<<"\n";
//            return 0;
//        }
//    }
    while(t--){
        ll n,s,k;cin >>n>>s>>k;
        ll g=gcd(k,n);
        if(s%g!=0){
            cout <<-1<<"\n";
        }
        else{
            s/=g;
            k/=g;
            n/=g;
            ll x=extgcd(k,n).first.first;//k^-1(mod n)
//            cout <<x<<"\n";
            ll ans=-s*x;
            ans%=n;
            if(ans<0)ans+=n;
            cout <<ans<<"\n";
        }
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}void pr(){ln;}
template<class A,class...B>void pr(const A &a,const B&...b){cout<<a<<(sizeof...(b)?" ":"");pr(b...);}
template<class A>void PR(A a,ll n){rep(i,n)cout<<(i?" ":"")<<a[i];ln;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[8]={-1,0,1,0,-1,-1,1,1},dy[8]={0,1,0,-1,-1,1,1,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n;
  R n;
  ll x=1.08*n;
  if(x<206) pr("Yay!");
  else if(x>206) pr(":(");
  else pr("so-so");
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}
