#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c[10000],d,e=0;
	cin>>a;
	for(b=0;b<a;b++){
		cin>>c[b];
	}
	for(b=0;b<a;b++){
		d=c[b];
		e=0;
		while(d){
			e+=d%10;
			d/=10;
		}
		if(e==7){
			cout<<"Yes"<<endl;
		}else{
			cout<<"No"<<endl;
		}
	}
	return 0;
}
