#include using namespace std; int main() { int t,q; cin >> t; while(t--) { int n; cin >>n; int a; long long s=0; for(int i=0;i>a; while(a!=0){ s += (a%10); a/=10; } } if(s%3 == 0) cout << "Yes\n"; else cout << "No\n"; } return 0; }