#include using namespace std; string canConstruct(vector a) { // Return "Yes" or "No" denoting whether you can construct the required number. vector act ; int o = 0 , t = 0 ; for(int i = 0 ; i< a.size();i++){ while(a[i]%10 == 0 ){ a[i]/= 10 ; } while( (a[i] > 0) && ( a[i]%3 != 0 ) ){ if ( (a[i]%10)%3 == 1 ){ o++ ; } if((a[i]%10)%3 == 2 ){ t++ ; } a[i]/= 10 ; } } string s ; if(t== 0 && o == 0 ){ s = "Yes" ; } else if( t!=0 && o != 0 && o-t <= 2 && o-t >= 0 ){ s = "Yes"; }else{ s = "No"; } return s ; } int main() { int t; cin >> t; for(int a0 = 0; a0 < t; a0++){ int n; cin >> n; vector a(n); for(int a_i = 0; a_i < n; a_i++){ cin >> a[a_i]; } string result = canConstruct(a); cout << result << endl; } return 0; }