#include<bits/stdc++.h>
#define int long long
using namespace std;
auto IN = freopen("candy.in", "r", stdin);
auto OUT = freopen("candy.out", "w", stdout);
auto mread = [](){int x;scanf("%lld", &x);return x;};
signed main(){
for(int i = 1; i <= 10; i ++){
string a, b;
cin >> a >> b;
int x = 0, y = 0;
for(int i = 0; i < a.size(); i ++){
x = (x * 10 + (a[i] - '0')) % 5;
}
for(int i = 0; i < b.size(); i ++){
y = (y * 10 + (b[i] - '0')) % 5;
}
x = (x - 1 + 5) % 5;
y = (y - 1 + 5) % 5;
if(x == 3 || x == 4 || x == 0 || y == 3 || y == 4 || y == 0){
printf("M\n");
}
else{
printf("S\n");
}
}
return 0;
}