#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
void solve(){
int n;string s;cin >> n >> s;
bool ok=false;
for(auto c:s) if(c=='5' || c=='0') ok=true;
if(ok) cout << "YES\n";
else cout << "NO\n";
}
int main(){
ios::sync_with_stdio(false);cin.tie(0);
int t;cin >> t;while(t--) solve();
}