#include <iostream>
#include <string>
using namespace std;
int main() {
string s;
cin >> s;
int sum = 0;
for(int i = 0; i<16; ++i) {
int value = (s[i] - '0');
if (i%2 == 0) {
value *= 2;
}
if (value >= 10) {
// value is of the form 1X
sum += 1 + (value - 10);
} else {
sum += value;
}
}
if (s[0] == '5' && s[1] >= '1' && s[1] <= '5' && sum%10 == 0) {
cout << "VALID" << endl;
} else {
cout << "BAD" << endl;
}
return 0;
}