if input()[0] == '7':
print('ДА')
else:
print('НЕТ')
a = int(input())
if a//100 == 7:
print("ДА")
print("НЕТ")
if input()[0] == '7':
print('ДА')
else:
print('НЕТ')
a = int(input())
if a//100 == 7:
print("ДА")
else:
print("НЕТ")