#include <iostream>
using namespace std;

typedef long long ll;



int main()
{
    int t;
    cin >> t;

    ll sumaReda = 0;
    ll sumaKolone = 0;
    bool postojiMatrica = true;

    while (t > 0)
    {
        ll n, m;
        cin >> n >> m;

        ll matrica[n][m];




        for (ll i = 1; i < n; i++)
        {
            for (ll j = 1; j < m; j++)
            {
                sumaReda += matrica[i][j];
                sumaKolone += matrica[i-1][j-1];
                if (sumaReda % i != 0 || sumaKolone % j !=0)
                    postojiMatrica = false;

            }
        }

        t--;

    }
    if (postojiMatrica)
        cout << "DA\n";
    else
        cout << -1;
    return 0;
}