```cpp
include[HTML_REMOVED]
include[HTML_REMOVED]
double a[12][12];
using namespace std;
int main(){
char ch;
double c=0,sum=0;
cin>>ch;
for(int i=0;i<12;i){
for(int j=0;j<12;j){
cin>>a[i][j];
}
}
for(int i=1;i<6;i){
for(int j=12-i;j<12;j){
sum+=a[i][j];
c;
}
}
for(int i=6;i<11;i){
for(int j=1+i;j<12;j){
sum+=a[i][j];
c;
}
}
if(ch=='S') printf("%.1lf",sum);
else if(ch=='M') printf("%.1lf",sum/c);
return 0;
}