#include<bits/stdc++.h>
#define taskname "A"
using namespace std;
const int lim = 105;
char a[lim][lim];
int n, m;
bitset<lim>vis[lim];
void move(int i, int j, const char ans){
	if(a[i][j] == 'x'){
		cout << ":)\n" << ans;
		exit(0);
	}
	if(vis[i].test(j) || a[i][j] == '.'){
		return;
	}
	vis[i].set(j);
	if(a[i][j] == '^'){
		move(i - 1, j, ans);
	}
	else if(a[i][j] == 'v'){
		move(i + 1, j, ans);
	}
	else if(a[i][j] == '<'){
		move(i, j - 1, ans);
	}
	else{
		move(i, j + 1, ans);
	}
}
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	if(fopen(taskname".inp", "r")){
		freopen(taskname".inp", "r", stdin);
	}
	cin >> n >> m;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++){
			cin >> a[i][j];
		}
	}
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++){
			if(a[i][j] == 'o'){
				for(int k = 1; k <= n; k++){
					vis[k].reset();
				}
				move(i, j + 1, 'E');
				move(i - 1, j, 'N');
				move(i + 1, j, 'S');
				move(i, j - 1, 'W');
				return cout << ":(", 0;
			}
		}
	}
}
Compilation message (stderr)
patkice.cpp: In function 'int main()':
patkice.cpp:33:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |                 freopen(taskname".inp", "r", stdin);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |