• + 0 comments
    from re import match
    [print("YES" if match(r'^[789]\d{9}$', input()) else "NO") for _ in range(int(input()))]