#include
#include
using namespace std;
int main() {
int niza[7];
for(int i = 0; i < 7; i++) {
cin >> niza[i];
}
int mat[5][6];
for(int i = 0; i < 5; i++) {
for(int j = 0; j < 6; j++) {
cin >> mat[i][j];
}
}
int brojac = 0;
for(int i = 0; i < 7; i++) {
int c = niza[i];
int dali_postoi_brojot = 0;
for(int x = 0; x < 5; x++) {
for(int y = 0; y < 6; y++) {
if(mat[x][y] == c) {
dali_postoi_brojot = 1;
mat[x][y] = -1;
break;
}
}
if(dali_postoi_brojot == 1) {
break;
}
}
if(dali_postoi_brojot == 1) {
brojac++;
}
}
if(brojac == 7) {
cout << "DA" << endl;
}
else {
cout << "NE" << endl;
}
return 0;
}