import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { static String canConstruct(int[] a,int p) { // Return "Yes" or "No" denoting whether you can construct the required number. //System.out.println(n); long sum=0; String s1 = new String(); for(int i=0;i< p;i++) { sum = sum *100 +a[i]; } // System.out.println(sum); String s = Long.toString(sum);int sum1=0; for(int k=0;k< s.length();k++) { sum1 += Integer.parseInt(Character.toString(s.charAt(k))); } // System.out.println(sum1); if(p==1 && Integer.parseInt(s) %3 ==0) { s1 ="Yes"; } if(sum1 % 3 ==0) { for(int i=0;i< p;i++) { for(int j=0;j< p-1;j++) { String rep = s.replace(s.charAt(i),s.charAt(j)); if((Integer.parseInt(rep) % 3) ==0) { //if(rep.charAt(0)=='0') s1 = "Yes"; } } } } else { s1 = "No"; } return s1; } 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,n); System.out.println(result); } in.close(); } }