#include #define rep(i,n) for(int i=0;i<(n);++i) #define all(a) (a).begin(),(a).end() #define dunk(a) cout << (a) << endl using namespace std; typedef long long ll; int main() { ios::sync_with_stdio(false); cin.tie(0); string a, b; cin >> a >> b; vector num = { '1','2','3','4','5','6','7','8','9','0' }; int judge1 = 0; int judge2 = 0; rep(i, 10) { judge1 += count(all(a), num[i]); judge2 += count(all(b), num[i]); } if (judge1 != a.size() || judge2 != b.size()) { puts("NG"); return 0; } if ((a.size() != 1 && a[0] == '0') || (b.size() != 1 && b[0] == '0')) { puts("NG"); return 0; } if (stoi(a) > 12345 || stoi(b) > 12345) { puts("NG"); return 0; } puts("OK"); return 0; }