#include<iostream>
using namespace std;
int main()
{
int id,temp;
while(cin>>id)
{
int digit,max1=-1,max2=-2;
temp=id;
for(int i=1;i<=9;i++)
{
digit=temp%10;
if(digit>=max1){max2=max1;max1=digit;}
else if(max2<digit&&digit<max1){max2=digit;}
temp=temp/10;
}
if((max1*max1+max2*max2)==id%1000)cout<<"Good Morning!\n";
else cout<<"SPY!\n";
}
}