#include #include using namespace std; typedef long long ll; void fs(ll &num) { bool neg=false; register ll c; num=0; c=getchar(); if (c=='-') { neg=true; c=getchar(); } for (;c>47&&c<58;c=getchar()) num=num*10+c-48; if (neg) num*=-1; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ll t; cin>>t; while (t--) { ll n,c,ans=0; cin>>n; for (ll i=0;i>c; while (c!=0) { ans+=c%10; c=c/10; } } if (ans%3==0) cout<<"Yes"<