#include <stdio.h>
char
s[100][100];
int
s1[100][100];
int
ax[5]={0,-1,0,1,0};
int
ay[5]={0,0,-1,0,1};
int
b[100][100]={0};
void
main()
{
int
H,W,N;
scanf
(
"%d %d %d"
,&H,&W,&N);
while
((H!=0)&&(W!=0)&&(N!=0))
{
for
(
int
i=0;i<H;i++)
{
getchar
();
for
(
int
j=0;j<W;j++)
{
scanf
(
"%c"
,&s[i][j]);
if
(s[i][j]==
'N'
)
s1[i][j]=1;
if
(s[i][j]==
'W'
)
s1[i][j]=2;
if
(s[i][j]==
'S'
)
s1[i][j]=3;
if
(s[i][j]==
'E'
)
s1[i][j]=4;
}
}
for
(
int
i=0;i<H;i++)
{
for
(
int
j=0;j<W;j++)
printf
(
"%d"
,s1[i][j]);
printf
(
"\n"
);
}
int
x=0;
int
y=N-1;
for
(
int
i=0;i<=10;i++)
{
b[x][y]=1;
printf
(
"%d %d "
,x,y);
printf
(
"%d "
,s1[x][y]);
printf
(
"%d %d\n"
,ax[s1[x][y]],ay[s1[x][y]]);
x+=ax[s1[x][y]];
y+=ay[s1[x][y]];
///*if(x<0||y<0||x==H||y==W)
//{
// printf("%d",i+1);
// break;
//}*/
}
scanf
(
"%d %d %d"
,&H,&W,&N);
}
}