#include <iostream>
using namespace std;
const int MAX_SIZE = 5;
int main() {
int size, array[MAX_SIZE + 1];
cin >> size;
for (int i = 1; i <= size; ++i) {
cin >> array[i];
}
int mt[MAX_SIZE + 1][MAX_SIZE + 1] = {0}, sameColsNo = 0;
for (int line = 1; line <= size; ++line) {
for (int col = 1; col <= size; ++col) {
int currentEl;
cin >> currentEl;
if (array[line] == currentEl) {
mt[line][col] = 1;
}
mt[line][col] += mt[line - 1][col];
if (line == size && mt[line][col] == size) {
++sameColsNo;
}
}
}
if (sameColsNo >= 2) {
cout << "DA";
} else {
cout << "NU";
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKY29uc3QgaW50IE1BWF9TSVpFID0gNTsKCmludCBtYWluKCkgewogICAgaW50IHNpemUsIGFycmF5W01BWF9TSVpFICsgMV07CiAgICBjaW4gPj4gc2l6ZTsKICAgIGZvciAoaW50IGkgPSAxOyBpIDw9IHNpemU7ICsraSkgewogICAgICAgIGNpbiA+PiBhcnJheVtpXTsKICAgIH0KICAgIGludCBtdFtNQVhfU0laRSArIDFdW01BWF9TSVpFICsgMV0gPSB7MH0sIHNhbWVDb2xzTm8gPSAwOwogICAgZm9yIChpbnQgbGluZSA9IDE7IGxpbmUgPD0gc2l6ZTsgKytsaW5lKSB7CiAgICAgICAgZm9yIChpbnQgY29sID0gMTsgY29sIDw9IHNpemU7ICsrY29sKSB7CiAgICAgICAgICAgIGludCBjdXJyZW50RWw7CiAgICAgICAgICAgIGNpbiA+PiBjdXJyZW50RWw7CiAgICAgICAgICAgIGlmIChhcnJheVtsaW5lXSA9PSBjdXJyZW50RWwpIHsKICAgICAgICAgICAgICAgIG10W2xpbmVdW2NvbF0gPSAxOwogICAgICAgICAgICB9CiAgICAgICAgICAgIG10W2xpbmVdW2NvbF0gKz0gbXRbbGluZSAtIDFdW2NvbF07CiAgICAgICAgICAgIGlmIChsaW5lID09IHNpemUgJiYgbXRbbGluZV1bY29sXSA9PSBzaXplKSB7CiAgICAgICAgICAgICAgICArK3NhbWVDb2xzTm87CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgCiAgICB9CiAgICBpZiAoc2FtZUNvbHNObyA+PSAyKSB7CiAgICAgICAgY291dCA8PCAiREEiOwogICAgfSBlbHNlIHsKICAgICAgICBjb3V0IDw8ICJOVSI7CiAgICB9CiAgICByZXR1cm4gMDsKfQ==