// In search of the sexy lady #include #define LL long long using namespace std; #define MAXN 111 #define INF 1000000000000 #define MOD 1000000009 #define sf scanf #define pf printf #define pb push_back #define mp make_pair #define ff first #define ss second #define ABS(x) ((x)<0?-(x):(x)) inline LL gcd ( LL a, LL b ) { a = ABS ( a ); b = ABS ( b ); while ( b ) { a = a % b; swap ( a, b ); } return a; } LL ext_gcd ( LL A, LL B, LL *X, LL *Y ){ LL x2, y2, x1, y1, x, y, r2, r1, q, r; x2 = 1; y2 = 0; x1 = 0; y1 = 1; for (r2 = A, r1 = B; r1 != 0; r2 = r1, r1 = r, x2 = x1, y2 = y1, x1 = x, y1 = y ) { q = r2 / r1; r = r2 % r1; x = x2 - (q * x1); y = y2 - (q * y1); } *X = x2; *Y = y2; return r2; } inline LL modInv ( LL a, LL m ) { LL x, y; ext_gcd( a, m, &x, &y ); x %= m; if ( x < 0 ) x += m; return x; } inline LL power ( LL a, LL p ) { LL res = 1, x = a; while ( p ) { if ( p & 1 ) res = ( res * x ); x = ( x * x ); p >>= 1; } return res; } inline LL bigmod ( LL a, LL p, LL m ) { LL res = 1 % m, x = a % m; while ( p ) { if ( p & 1 ) res = ( res * x ) % m; x = ( x * x ) % m; p >>= 1; } return res; } #define MX 322222 int t,n,a,sum; int main() { // freopen("in.txt", "r", stdin); cin>>t; while(t--) { cin>>n; sum =0; while(n--) { cin>>a; while(a) { sum += a%10; a/=10; } } if(sum%3) cout<<"No\n"; else cout<<"Yes\n"; } return 0; }