import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; import java.util.stream.*; public class Solution { static String canConstruct(int[] a) { String allDigitsToUse = Arrays.stream(a).mapToObj(i -> String.valueOf(i)).collect(Collectors.joining()); for(String number : permutateAllNumbers("", allDigitsToUse)) { if(Integer.parseInt(number) % 3 == 0) { return "Yes"; } } return "No"; } private static List permutateAllNumbers(String prefix, String rest) { if(rest.isEmpty()) { if(!prefix.isEmpty()) { return Arrays.asList(prefix); } return new ArrayList<>(); } List ret = new ArrayList<>(); for(int i=0; i< rest.length(); i++) { char digit = rest.charAt(i); String nextPrefix = digit == '0' ? prefix : prefix + digit; StringBuilder nextString = new StringBuilder(rest); nextString.deleteCharAt(i); ret.addAll(permutateAllNumbers(nextPrefix, nextString.toString())); } return ret; } 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(); } }