#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while(t--){
int n;
string s;
cin >> n >> s;
int a = sqrt(n);
//cout << a << endl;
if(a * a == n){
int zero_c = 0;
for(int i=0;i<s.size();i++){
if(s[i] == '0')
zero_c++;
}
if(zero_c == (a-2)*(a-2))
cout << "Yes\n";
else
cout << "No\n";
}
else
cout << "No\n";
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKSB7CglpbnQgdDsKCWNpbiA+PiB0OwoJd2hpbGUodC0tKXsKCQlpbnQgbjsKCQlzdHJpbmcgczsKCQljaW4gPj4gbiA+PiBzOwoJCWludCBhID0gc3FydChuKTsKCQkvL2NvdXQgPDwgYSA8PCBlbmRsOwoJCWlmKGEgKiBhID09IG4pewoJCQlpbnQgemVyb19jID0gMDsKCQkJZm9yKGludCBpPTA7aTxzLnNpemUoKTtpKyspewoJCQkJaWYoc1tpXSA9PSAnMCcpCgkJCQkJemVyb19jKys7CgkJCX0KCQkJaWYoemVyb19jID09IChhLTIpKihhLTIpKQoJCQkJY291dCA8PCAiWWVzXG4iOwoJCQllbHNlCgkJCQljb3V0IDw8ICJOb1xuIjsKCQl9CgkJZWxzZQoJCQljb3V0IDw8ICJOb1xuIjsKCX0KICAgIHJldHVybiAwOwp9Cg==