#include using namespace std; string canConstruct(vector a) { string answer = "No"; string number = ""; std::string::size_type sz; long num = 0; if(a.size() == 1){ if(a[0] % 3 == 0) { answer = "Yes"; return answer; } else{ answer = "No"; return answer; } } for(int i = 0; i < a.size(); ++i) { number += to_string(a[i]); } for(int k = 0; k < number.size(); ++k) { for(int j = 1; j < number.size(); ++j) { num = stol(number,&sz); if(num % 3 == 0) { answer = "Yes"; return answer; } char temp = number[j]; number[j] = number[k]; number[k] = temp; } } return answer; } 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; }