#include<cstdio>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
using namespace std;

int main()
{
  freopen("math.in", "r", stdin);
  freopen("math.out", "w", stdout);
  vector<int> a;
  string s;
  while(cin >> s)
  {
    for(int i = 0; i < (int)s.size(); i++)
    {
      if(s[i] == '^')
      {
        int t = 0;
        i++;
        while(t < (int)1e6 + 7 && i < (int)s.size() && s[i] >= '0' && s[i] <= '9')
          t = t * 10 + (s[i++] - '0');
        a.push_back(t);
      }
    }
  }
  int n = a.size();
  cout << n << endl;
  /*for(int i = 0; i < n; i++)
    cout << a[i] << ' ';
  cout << endl;*/ 
  vector<int> ans0(n, 0), ans1(n, 0), ans2(n, 0), number((int)1e6+7, 0);
  int j = 0; 
  while(j < n && a[j] != 1)
    j++;
  //cerr<< j << endl;
  if(j != n)
  {
    number[1]++;
    ans0[j] = 1;
    for(int i = j + 1; i < n; i++)
    {
      int t = a[i];
      if(t == 1 || number[t - 1] > 0)
        number[t]++, ans0[i] = 1;
    }
    int maxi = j;
    for(int i = j + 1; i < n; i++)
      if(ans0[i] && a[maxi] <= a[i])
        maxi = i;
    //cerr << endl << maxi << endl;
    number.assign((int)1e6 + 7, 0);
    /*for(int i = maxi + 1; i < n; i++)
      if(a[i] == a[maxi])
        ans1[i] = 1, number[a[i]]++;  */
    ans1[maxi] = 1;
    number[a[maxi]]++;
    for(int i = maxi - 1; i >= j; i--)
    {
      int t = a[i];
      if(t == a[maxi] || number[t + 1] > 0)
        number[t]++, ans1[i] = 1;
    }  
  }
  for(int i = 0; i < n; i++)
    if(!(ans1[i]*ans0[i]) || number[a[i]] > 1)
      ans2[i] = 1;
  for(int i = 0; i < n; i++)
    if(ans2[i])
      cout << "Y";
    else
      cout << "N";
  cout << endl;
  for(int i = 0; i < n; i++)
    if(ans1[i] * ans0[i])
      cout << "Y";
    else
      cout << "N";
  cout << endl;
  return 0;
}

