using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; class Solution { static string canConstruct(int[] a) { string result = string.Empty; for(int i =0 ; i < a.Length; i++) { result += a[i].ToString(); } // Define a combination StringBuilder temp = new StringBuilder(); bool isFound = true; for(int i = 0; i < result.Length; i++) { temp = new StringBuilder(result); for(int j = 0; j < result.Length; j++) { temp[i] = temp[j]; if(int.Parse(temp.ToString()) % 3 != 0) { return "No"; } } } return "Yes"; } static void Main(String[] args) { int t = Convert.ToInt32(Console.ReadLine()); for(int a0 = 0; a0 < t; a0++){ int n = Convert.ToInt32(Console.ReadLine()); string[] a_temp = Console.ReadLine().Split(' '); int[] a = Array.ConvertAll(a_temp,Int32.Parse); string result = canConstruct(a); Console.WriteLine(result); } } }