#include using namespace std; int main() { int t; cin>>t; while(t--) { int n; int temp,sum=0; cin>>n; for(int i=0;i>temp; while(temp) { sum+=temp%10; temp=temp/10; } } if(sum%3==0) cout<<"Yes"<