// 
#pragma comment(linker, "/STACK:16777215")
#include <cmath>
#include <cstring>
#include <ctime>
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <deque>
#include <string>
using namespace std;

const int INF =100*1000*1000;

const int MAXM=120;
const int MAXN=30;

struct T 
{
	int back;
	char haus;
	int cnt;
	int n;
};

struct P
{
	bool avlible;
	int cnt;
	int back;
};

bool table[MAXM+1][MAXN+1];
int m, n, bg, nd;
P tek[MAXN+1];
T res[MAXN+1];
vector<T> out; 

int main()
{
	int i, j, k;
	char ch;
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	cin >> m >> n;
	for(i=1; i<=m; ++i)
		for(j=1; j<=n; ++j)
		{
			cin >> ch;
			table[i][j]= ch=='O';
 		}
	cin >> bg >> nd;
	for(i=1; i<=n; ++i)
	{
		tek[i].avlible= false;
		tek[i].cnt= 0;
	}
	for(i=bg; i<=nd; ++i)
	{
		res[i].cnt= INF;
		res[i].n= i;
	}
	res[bg].cnt= 0;
	for(i=bg; i<=nd; ++i)
	{
		int bst=-1;
		for(j=1; j<=n; ++j)
			if (tek[j].avlible && (bst==-1 || tek[bst].cnt>tek[j].cnt))
				bst= j;
		if (bst!=-1)
		{
			res[i].haus= (char)('A'+bst-1);
			res[i].back= tek[bst].back;
			res[i].cnt= tek[bst].cnt;
		}
		
		for(j=1; j<=n; ++j)
		{
			if (table[i][j] && !tek[j].avlible)
			{
				tek[j].avlible= true;
				tek[j].back= i;
				tek[j].cnt= res[i].cnt+1 ;
			}
			if (!table[i][j] && tek[j].avlible)
			{
				tek[j].avlible= false;
			}
		}
	}
	if (res[nd].cnt>=INF)
	{
		cout << "Not available";
	}
	else
	{
		i=nd;
		while(i!=bg)
		{
			out.push_back(res[i]);
			i= res[i].back;
		}
		for(i=out.size()-1; i>=0; --i)
		{
			while (out[i].n+1<=nd && out[i].haus==res[out[i].n+1].haus)
			{
				out[i].n++;
				if (i-1>=0)
					out[i-1].back++;
			}
			cout << out[i].haus << ": " << out[i].back << "-" << out[i].n << endl;
		}
	}

	return 0;
}