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 n,int t) { // Return "Yes" or "No" denoting whether you can construct the required number. String s=" "; // int k; if(n==1) { if(a[0]%t==0) s="Yes"; else s="No"; } else if(n==2) { String s1=String.valueOf(a[0]); String s2=String.valueOf(a[1]); String s3=s1+s2; int k=Integer.parseInt(s3); if(k%t==0) s="Yes"; else { s3=s2+s1; k=Integer.parseInt(s3); if(k%t==0) s="Yes"; else s="No"; } } else s="Yes"; return s; } 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,t); System.out.println(result); } in.close(); } }