#include "testlib.h"

#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <utility>
#include <string>

using namespace std;
int calc(string r, string s1, string s2)
{ int c[26]={0};
  if(r.length()!=s1.length())
     quitf(_pe, "Wrong length");
  for(int i=0; i<r.length(); ++i)
  {
    if(r[i]!=s1[i] && r[i]!=s2[i])
      quitf(_wa, "Wrong char");
    ++c[r[i]-'A'];
  }
  int m=0;
  for(int i=0;i<26;++i)
    m=max(m,c[i]);
  return m;
}
int main(int argc, char *argv[])
{
   registerTestlibCmd(argc, argv);
   
   string s1,s2,rj,rp;
   s1=inf.readLine();
   s2=inf.readLine();
   rp=ouf.readLine();
   rj=ans.readLine();
   int mp=calc(rp,s1,s2);
   int mj=calc(rj,s1,s2);
   if(mj>mp)
     quitf(_wa, "Not maximal");
   quitf(_ok, "OK");
}
