#include <iostream>
using namespace std;
/* The solution planes 7 weeks in advanced.
* Because the first pill day determines which days pills are taken, there can
* never be more than 6 distinct weeks(at least one day punched), and the 7th
* is needed only to ensure a cycle can be detected.
*
* The following functions operate on an array days over 7 weeks.
* First eliminate all punctured days so we don't have to check the letters.
* Second compute the next pill repeatedly until the range is finished.
* Third compare weeks (7 day sections) by pill sequence to find a cycle.
* Four print weeks one line at a time.
*/
const int needed_days = 49;
int* D = new int[49];
//eliminates (set to -1) every instance of a punctured weekday
void eliminate(int i){
do{
D[i]=-1;
i+=7;
}while(i<needed_days);
}
//find next pill day from a given index and step, returns new index
int next(int i, int p){
while(D[i+p]==-1) p--;
if(i+p>=0) D[i+p]=1; //when P=2 and Sundays punched, i+p=-1 once
return i+p;
}
//compare two weeks by week-index.
int equals(int i, int j){
i*=7; j*=7;
for(int k=7; k--;)
if(D[i+k]!=D[j+k]) return 0;
return 1;
}
//print week by week-index, include arrow if arrow is 1.
void print(int i, int arrow){
if(arrow) cout<<">";
else cout<<" ";
i*=7;
for(int k=0; k<7; k++)
if(D[i+k]==1) cout<<" X";
else cout<<" ·";
cout<<"\n";
}
int main() {
//Parse input P and eliminate punctured weekdays.
int P; char C;
cin>>P;
while(cin>>C){
switch(C){
case 'N': eliminate(0); break;
case 'M': eliminate(1); break;
case 'T': eliminate(2); break;
case 'W': eliminate(3); break;
case 'R': eliminate(4); break;
case 'F': eliminate(5); break;
case 'S': eliminate(6); break;
}
}
//plan out all days
int i=-2; //last friday
while(i<needed_days){
i = next(i,P);
}
//compare weeks to find cycles
int first = -1; int last = 0;
while(first==-1){
last++;
for(int i=last; i--;){
if(equals(last,i))
first=i;
}
}
//print weeks
for(int i=0; i<last; i++)
print(i,i==first);
}