import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main{
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int T = Integer.parseInt(br.readLine());
while (T > 0) {
String[] input = br.readLine().split(" ");
long K = Long.parseLong(input[0]);
int d0 = Integer.parseInt(input[1]);
int d1 = Integer.parseInt(input[2]);
int S = d0 + d1;
int [] cycle_mul = {2,4,8,6};
long cycles = (K - 3) / 4;
long remaining = (K - 3) % 4;
long cycle_value = 0;
if(K==2){
if((d0+d1)%3==0){
System.out.println("YES");
}
else{
System.out.println("NO");
}
continue;
}
for(int i=0;i<cycle_mul.length;i++){
cycle_value += (cycle_mul[i]* S)%10;
}
long ans = S + (S%10) + (cycles *(cycle_value));
if(remaining>0){
int i=0;
for(int j=0;j<remaining;j++){
ans+= (cycle_mul[j] * S)%10;
}
}
if(ans%3==0){
System.out.println("YES");
}
else{
System.out.println("NO");
}
System.out.flush();
T--;
}
}
}