#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], sameColsNo = 0;
for (int line = 1; line <= size; ++line) {
for (int col = 1; col <= size; ++col) {
cin >> mt[line][col];
if (array[line] == mt[line][col]) {
mt[line][col] = 1;
} else {
mt[line][col] = 0;
}
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+PiBhcnJheVtpXTsKICAgIH0KICAgIGludCBtdFtNQVhfU0laRSArIDFdW01BWF9TSVpFICsgMV0sIHNhbWVDb2xzTm8gPSAwOwogICAgZm9yIChpbnQgbGluZSA9IDE7IGxpbmUgPD0gc2l6ZTsgKytsaW5lKSB7CiAgICAgICAgZm9yIChpbnQgY29sID0gMTsgY29sIDw9IHNpemU7ICsrY29sKSB7CiAgICAgICAgICAgIGNpbiA+PiBtdFtsaW5lXVtjb2xdOwogICAgICAgICAgICBpZiAoYXJyYXlbbGluZV0gPT0gbXRbbGluZV1bY29sXSkgewogICAgICAgICAgICAgICAgbXRbbGluZV1bY29sXSA9IDE7CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICBtdFtsaW5lXVtjb2xdID0gMDsKICAgICAgICAgICAgfQogICAgICAgICAgICBtdFtsaW5lXVtjb2xdICs9IG10W2xpbmUgLSAxXVtjb2xdOwogICAgICAgICAgICBpZiAobGluZSA9PSBzaXplICYmIG10W2xpbmVdW2NvbF0gPT0gc2l6ZSkgewogICAgICAgICAgICAgICAgKytzYW1lQ29sc05vOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIAogICAgfQogICAgaWYgKHNhbWVDb2xzTm8gPj0gMikgewogICAgICAgIGNvdXQgPDwgIkRBIjsKICAgIH0gZWxzZSB7CiAgICAgICAgY291dCA8PCAiTlUiOwogICAgfQogICAgcmV0dXJuIDA7Cn0=