import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { static String canConstruct(int[] a) { // Return "Yes" or "No" denoting whether you can construct the required number. boolean can = false; StringBuilder allDigits = new StringBuilder(""); List digits = new ArrayList<>(); if(a.length==1){ can = ((a[0] % 3) == 0); }else{ for(int i=0;i 10){ int digit = temp % 10; digits.add(digit); temp = temp/10; } digits.add(temp); } //System.out.println("PrintAll"); //digits.forEach(System.out::print); } //divisibl criteria for 3 - last 2 digits. if sum of any 2 digits are div then Yes for(int i=0;i<10;i++){ if( (digits.contains(i) && digits.contains(3-i)) || (digits.contains(i) && digits.contains(6-i)) || (digits.contains(i) && digits.contains(9-i)) ){ can = true; break; } } return can ? "Yes" : "No"; } public static void main(String[] args) { Scanner in = new Scanner(System.in); int t = in.nextInt(); for(int a0 = 0; a0 < t; a0++){ int n = in.nextInt(); int[] a = new int[n]; for(int a_i = 0; a_i < n; a_i++){ a[a_i] = in.nextInt(); } String result = canConstruct(a); System.out.println(result); } in.close(); } }