Help me in solving FINDK3 problem what is wrong in my solution?as it show wrong solution

My issue

My code

#include <iostream>
using namespace std;
int main(){
    int t;
    cin>>t;
    while(t--){
    int X,Y,Z;
    cin>>X>>Y>>Z;
    int A,B;
if((X*Y)%Z==0){
    A=X*Y;
    B=Z;
    cout<<A<<" "<<B<<endl;
    }
 else if((Y*Z)%X==0){
   A=Y*Z;
   B=X;
   cout<<A<<" "<<B<<endl;}  
else if((X*Z)%Y==0){
 A=X*Z;
    B=Y;
    cout<<A<<" "<<B;
    }
else
    cout<<-1<<endl;
}
  return 0;}


Problem Link: FINDK3 Problem - CodeChef

@sumit_parira16
endl is missing in second last elseif