#include<iostream>
#include<algorithm>
using namespace std;
string x;
string ansx;
string ansy;
int main() {
cin >> x;
reverse(x.begin(), x.end());
int znum = 0;
int notz = 0;
int num = 0;
for (int i = 0; i < x.size(); i++) {
if (x[i] == 'Z' && notz == 0) {
znum++;
}
if (x[i] != 'Z' && znum) {
notz++;
}
if (x[i] == 'Z' && notz) {
cout << -1;
return 0;
}
if (x[i] == 'Z')
num++;
}
if (num == x.size()) {
for (int i = 1; i <= 2; i++) {
for (int j = 1; j <= x.size(); j++) {
cout << 0;
}
cout << endl;
}
return 0;
}
for(int i=0;i<x.size();i++)
{
if(x[i]=='Y')
{
ansy+='7';
ansx+='6';
}
if(x[i]=='X')
{
ansy+='6';
ansx+='7';
}
if(x[i]=='Z')
{
ansy+='1';
ansx+='1';
}
}
reverse(ansx.begin(),ansx.end());
reverse(ansy.begin(),ansy.end());
cout<<ansx<<endl<<ansy;
return 0;
}