#include <fstream>


using namespace std;

int main()
{
    ifstream f("ghem.in");
    ofstream g("ghem.out");
    int n,x,y;
    int i,j,k;
    char d;

    // citesc datele de intrare
    f>>n;
    f>>x>>y>>d;



    // so - sus orizontal ; dv - dreapta vertical
    // jo - jos orizontal ; sv - stanga vertical

    
    // 1,n,V
    if (x==1&&y==n&&d=='V')
        for(k=1;k<=n/2;k++)
                {
                for(i=k;i<=n-k+1;i++) g<<(i-1)*n+n-k+1<<" ";
                for(j=n-k;j>=k;j--) g<<(n-k+1-1)*n+j<<" ";
                for(i=n-k;i>=k+1;i--) g<<(i-1)*n+k<<" ";
                for(j=k;j<=n-k;j++) g<<(k-1)*n+j<<" ";
                }

    

    if (n%2) g<<((n+1)/2-1)*n+(n+1)/2<<"\n";
        else g<<"\n";

    f.close();
    g.close();
    return 0;
}
