import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { static ArrayList al; static String canConstruct(int a[]){ String s = ""; al = new ArrayList<>(); for(int i : a)s+=Integer.toString(i); permute(s,0,s.length()-1); //System.out.println(al); for(Integer i : al){ if(i%3 == 0){ return "Yes"; } } return "No"; } static private void permute(String str, int l, int r){ if (l == r){ al.add(Integer.parseInt(str)); } // System.out.println(str); else { for (int i = l; i <= r; i++) { str = swap(str,l,i); permute(str, l+1, r); str = swap(str,l,i); } } } static public String swap(String a, int i, int j) { char temp; char[] charArray = a.toCharArray(); temp = charArray[i] ; charArray[i] = charArray[j]; charArray[j] = temp; return String.valueOf(charArray); } 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(); } }