#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    long long x0, y0, type;
    if (cin >> x0 >> y0 >> type) {
        if (type < 1 || type > 4) {
            cout << "INVALID TYPE\n";
            return 0;
        }

        double p = 0.0;
        double x = (double)x0;
        double y = (double)y0;

        if (type == 1) {
            p = sqrt(x * x + y * y);
        } else if (type == 2) {
            p = abs(x) + abs(y);
        } else if (type == 3) {
            p = (x * x + y * y) / (abs(x - y) + 1.0);
        } else if (type == 4) {
            p = cbrt(abs(x * x * x - y * y * y));
        }

        cout << fixed << setprecision(2) << p << "\n";

        if (x0 == 0 && y0 == 0) {
            cout << "BASE DEFENSE\n";
        } else if (p < 100.0) {
            cout << "SAFE\n";
        } else if (p <= 1000000.0) {
            cout << "WARNING\n";
        } else {
            cout << "DANGER\n";
        }
    }

    return 0;
}