#include <stdio.h>
#include <string.h>
FILE *fin =fopen("ghem.in" ,"rt");
FILE *fout=fopen("ghem.out","wb");
int n,x,y,i,j,k,p;
char a[502][502][8], d;
void rama(int p, int k){
    ///(k,k)    - (k,n+1-k)
    ///  |              |
    ///(n+1-k,k)- (n+1-k,n+1-k)
    if(p==0){
        int i=k, j=k;
        while(j<n+1-k){fwrite(a[i][j],strlen(a[i][j]),1,fout); j++;};
        while(i<n+1-k){fwrite(a[i][j],strlen(a[i][j]),1,fout);  i++;};
        while(j>k){fwrite(a[i][j],strlen(a[i][j]),1,fout);  j--;};
        while(i>k){fwrite(a[i][j],strlen(a[i][j]),1,fout);  i--;};
        return;
    }
    if(p==1){
        int i=k, j=n+1-k;
        while(i<n+1-k){fwrite(a[i][j],strlen(a[i][j]),1,fout);  i++;};
        while(j>k){fwrite(a[i][j],strlen(a[i][j]),1,fout);  j--;};
        while(i>k){fwrite(a[i][j],strlen(a[i][j]),1,fout);  i--;};
        while(j<n+1-k){fwrite(a[i][j],strlen(a[i][j]),1,fout);  j++;};
        return;
    }
    if(p==2){
        int i=n+1-k, j=n+1-k;
        while(j>k){fwrite(a[i][j],strlen(a[i][j]),1,fout);  j--;};
        while(i>k){fwrite(a[i][j],strlen(a[i][j]),1,fout);  i--;};
        while(j<n+1-k){fwrite(a[i][j],strlen(a[i][j]),1,fout);  j++;};
        while(i<n+1-k){fwrite(a[i][j],strlen(a[i][j]),1,fout);  i++;};
        return;
    }
    if(p==3){
        int i=n+1-k, j=k;
        while(i>k){fwrite(a[i][j],strlen(a[i][j]),1,fout);  i--;};
        while(j<n+1-k){fwrite(a[i][j],strlen(a[i][j]),1,fout);  j++;};
        while(i<n+1-k){fwrite(a[i][j],strlen(a[i][j]),1,fout);  i++;};
        while(j>k){fwrite(a[i][j],strlen(a[i][j]),1,fout);  j--;};
        return;
    }
    if(p==4){
        int i=k, j=k;
        while(i<n+1-k){fwrite(a[i][j],strlen(a[i][j]),1,fout);  i++;};
        while(j<n+1-k){fwrite(a[i][j],strlen(a[i][j]),1,fout);  j++;};
        while(i>k){fwrite(a[i][j],strlen(a[i][j]),1,fout);  i--;};
        while(j>k){fwrite(a[i][j],strlen(a[i][j]),1,fout);  j--;};
        return;
    }
    if(p==5){
        int i=n+1-k, j=k;
        while(j<n+1-k){fwrite(a[i][j],strlen(a[i][j]),1,fout);  j++;};
        while(i>k){fwrite(a[i][j],strlen(a[i][j]),1,fout);  i--;};
        while(j>k){fwrite(a[i][j],strlen(a[i][j]),1,fout);  j--;};
        while(i<n+1-k){fwrite(a[i][j],strlen(a[i][j]),1,fout);  i++;};
        return;
    }
    if(p==6){
        int i=n+1-k, j=n+1-k;
        while(i>k){fwrite(a[i][j],strlen(a[i][j]),1,fout);  i--;};
        while(j>k){fwrite(a[i][j],strlen(a[i][j]),1,fout);  j--;};
        while(i<n+1-k){fwrite(a[i][j],strlen(a[i][j]),1,fout);  i++;};
        while(j<n+1-k){fwrite(a[i][j],strlen(a[i][j]),1,fout);  j++;};
        return;
    }
    if(p==7){
        int i=k, j=n+1-k;
        while(j>k){fwrite(a[i][j],strlen(a[i][j]),1,fout);  j--;};
        while(i<n+1-k){fwrite(a[i][j],strlen(a[i][j]),1,fout);  i++;};
        while(j<n+1-k){fwrite(a[i][j],strlen(a[i][j]),1,fout);  j++;};
        while(i>k){fwrite(a[i][j],strlen(a[i][j]),1,fout);  i--;};
        return;
    }
}
int main()
{
    int r=0;
    fscanf(fin,"%d\n%d %d\n%c",&n,&x,&y,&d);
    for(i=1;i<=n;i++){
        for(j=1;j<=n;j++){
            r++;
            sprintf(a[i][j],"%d ",r);
        }
    }
    if(d=='O' && x==1 && y==1)p=0;
    if(d=='V' && x==1 && y==1)p=4;
    if(d=='V' && x==1 && y==n)p=1;
    if(d=='O' && x==1 && y==n)p=7;
    if(d=='O' && x==n && y==n)p=2;
    if(d=='V' && x==n && y==n)p=6;
    if(d=='V' && x==n && y==1)p=3;
    if(d=='O' && x==n && y==1)p=5;

    for(k=1;k<=n/2;k++){
        rama(p,k);
    }
    if(n%2==1){
        fwrite(a[n/2+1][n/2+1],strlen(a[n/2+1][n/2+1]),1,fout);
    }
    fclose(fin);
    fclose(fout);
    return 0;
}

