#include <iostream>
#include <fstream>
using namespace std;
int N,M,T,K, a[50][50],q[50*50][2],fx,fy, viz[50][50]; bool found;
void q_push(int x, int y){
q[++K][0]=x;
q[K][1]=y;
}
bool valid(int x, int y){
if (x<1 || x>N || y<1 || y>M || a[x][y]==1 || viz[x][y]==1)
return 0;
return 1;
}
void dfs(int x, int y){
if (valid(x,y)){
if (x==fx && y==fy)
found=1;
if (a[x][y]==2 && !viz[x][y]){
viz[x][y]=2;
q_push(x,y);
return;
}
viz[x][y]=1;
dfs(x+1,y);
dfs(x-1,y);
dfs(x,y+1);
dfs(x,y-1);
}
}
bool possible(void){
int l=1,cost=0,i,aux;
while(!found && cost<=T/2 && l<=K){
aux=K;
for (i=l; i<=aux; i++)
dfs(q[i][0],q[i][1]);
cost++;
l=aux+1;
}
return (found);
}
int main(){
cin >> N >> M >> T;
int i,j; char c; bool f;
for (i=1; i<=N; i++)
for (j=1; j<=M; j++){
cin >> c;
if (c=='#')
a[i][j]=1;
else if (c=='s')
a[i][j]=2;
else if (c=='@')
q_push(i,j);
else if (c=='x')
fx=i,fy=j;
}
f=possible();
if (f)
cout << "SUCCESS\n";
else
cout << "IMPOSSIBLE\n";
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8ZnN0cmVhbT4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmludCBOLE0sVCxLLCBhWzUwXVs1MF0scVs1MCo1MF1bMl0sZngsZnksIHZpels1MF1bNTBdOyBib29sIGZvdW5kOwoKdm9pZCBxX3B1c2goaW50IHgsIGludCB5KXsKICAgIHFbKytLXVswXT14OwogICAgcVtLXVsxXT15Owp9Cgpib29sIHZhbGlkKGludCB4LCBpbnQgeSl7CiAgICBpZiAoeDwxIHx8IHg+TiB8fCB5PDEgfHwgeT5NIHx8IGFbeF1beV09PTEgfHwgdml6W3hdW3ldPT0xKQogICAgICAgIHJldHVybiAwOwogICAgcmV0dXJuIDE7Cn0KCnZvaWQgZGZzKGludCB4LCBpbnQgeSl7CiAgICBpZiAodmFsaWQoeCx5KSl7CiAgICAgICAgaWYgKHg9PWZ4ICYmIHk9PWZ5KQogICAgICAgICAgICBmb3VuZD0xOwoKICAgICAgICBpZiAoYVt4XVt5XT09MiAmJiAhdml6W3hdW3ldKXsKICAgICAgICAgICAgdml6W3hdW3ldPTI7CiAgICAgICAgICAgIHFfcHVzaCh4LHkpOwogICAgICAgICAgICByZXR1cm47CiAgICAgICAgfQoKICAgICAgICB2aXpbeF1beV09MTsKICAgICAgICBkZnMoeCsxLHkpOwogICAgICAgIGRmcyh4LTEseSk7CiAgICAgICAgZGZzKHgseSsxKTsKICAgICAgICBkZnMoeCx5LTEpOwogICAgfQp9Cgpib29sIHBvc3NpYmxlKHZvaWQpewogICAgaW50IGw9MSxjb3N0PTAsaSxhdXg7CgogICAgd2hpbGUoIWZvdW5kICYmIGNvc3Q8PVQvMiAmJiBsPD1LKXsKICAgICAgICBhdXg9SzsKICAgICAgICBmb3IgKGk9bDsgaTw9YXV4OyBpKyspCiAgICAgICAgICAgIGRmcyhxW2ldWzBdLHFbaV1bMV0pOwogICAgICAgIGNvc3QrKzsKICAgICAgICBsPWF1eCsxOwogICAgfQoKICAgIHJldHVybiAoZm91bmQpOwp9CgppbnQgbWFpbigpewogICAgY2luID4+IE4gPj4gTSA+PiBUOwoKICAgIGludCBpLGo7IGNoYXIgYzsgYm9vbCBmOwogICAgZm9yIChpPTE7IGk8PU47IGkrKykKICAgICAgICBmb3IgKGo9MTsgajw9TTsgaisrKXsKICAgICAgICAgICAgY2luID4+IGM7CiAgICAgICAgICAgIGlmIChjPT0nIycpCiAgICAgICAgICAgICAgICBhW2ldW2pdPTE7CiAgICAgICAgICAgIGVsc2UgaWYgKGM9PSdzJykKICAgICAgICAgICAgICAgIGFbaV1bal09MjsKICAgICAgICAgICAgZWxzZSBpZiAoYz09J0AnKQogICAgICAgICAgICAgICAgcV9wdXNoKGksaik7CiAgICAgICAgICAgIGVsc2UgaWYgKGM9PSd4JykKICAgICAgICAgICAgICAgIGZ4PWksZnk9ajsKICAgICAgICB9CgogICAgZj1wb3NzaWJsZSgpOwogICAgaWYgKGYpCiAgICAgICAgY291dCA8PCAiU1VDQ0VTU1xuIjsKICAgIGVsc2UKICAgICAgICBjb3V0IDw8ICJJTVBPU1NJQkxFXG4iOwoKICAgIHJldHVybiAwOwp9Cg==