#include using namespace std; int main() { long int t,i; cin>>t; while(t--) { long int n; cin>>n; long int a[200]; map m; for(i=0;i>a[i]; long int temp=a[i]; while(temp!=0) { long int r=temp%10; m[r]++; temp=temp/10; } } long int sum=0; for(auto it=m.begin();it!=m.end();it++) sum=sum+it->second*it->first; if(sum%3==0) cout<<"Yes"<