#include <stdio.h>
inline int read(){
int x = 0, f = 1;
char ch;
ch = getchar();
while(ch < '0' || ch > '9'){
if(ch == '-') f = -1;
ch = getchar();
}
while(ch >= '0' && ch <= '9'){
x = x * 10 + ch - '0';
ch = getchar();
}
return (x * f);
}
namespace io{
inline bool value(int x){
int sum = 0;
while(x != 0){
sum += (x % 10);
x /= 10;
}
if(sum == 7) return true;
else return false;
}
}
using namespace io;
signed main(){
int n, x;
scanf("%d", &n);
while(n--){
x = read();
if(value(x)) puts("Yes\n");
else puts("No\n");
}
return 0;
}