E
#include<iostream>
using namespace std;
int main(){
int t;
cin>>t;
while(t--){
int x,y,z,ans;
cin>>x>>y>>z;
ans=(z-y)/x*x+y;
cout<<ans<<endl;
}
return 0;
}
F
#include<iostream>
#include<math.h>
using namespace std;
int main(){
int t;
cin>>t;
while(t--){
int n,cnt=0;
cin>>n;
int x=n;
while(x%6==0) {x/=6;++cnt;}
while(x%3==0) {x/=3;cnt+=2;}
if(x!=1) cnt=-1;
cout<<cnt<<endl;
}
return 0;
}
G
#include<iostream>
#include<stack>
using namespace std;
stack<char> s;
int main(){
int t;
cin>>t;
while(t--){
int n,cnt=0;
char c;
s.push(')');
cin>>n;
while(n--){
cin>>c;
if(c==')'&&s.top()=='(') s.pop();
else s.push(c);
}
if(!s.empty()){
while(s.top()=='('){
++cnt;
s.pop();
}
}
cout<<cnt<<endl;
}
return 0;
}