#include <stdio.h>
#include <ctype.h>
#include <vector>
#include <algorithm>

using namespace std;

#define mmax(a,b) (a>b)?a:b
#define mmin(a,b) (a<b)?a:b

char C[101][27];
char prev[27];
int E[101][27];

int count2;

struct e{
	int id, l, s, end;
	int dist;
	int first_l;
	bool used;
	int prev;
};

e els[2700];

int main()
{
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);

	int n, m, a, b;

	scanf("%d%d\n", &m, &n);

	for(int i = 0; i < m; i++)
	{
		gets(C[i]);
	}

	if( scanf("%d%d", &a, &b) != 2 )
	{
		for(;1!=2;);
	}
	a--;
	b--;
	b--;

	for(int i = 0; i < m; i++)
	{
		for(int j = 0; j < n; j++)
		{
			if( C[i][j] == 'O' )
			{
				if( prev[j] != 'O' )
				{
					els[count2].id = count2;
					els[count2].l = j;
					els[count2].s = i;
					els[count2].end = i;
					els[count2].dist = 100500;
					els[count2].first_l = j;
					els[count2].used = false;
					els[count2].prev = -1;
					E[i][j] = count2;
					count2++;
				}
				else
				{
					els[E[i-1][j]].end = i;
					E[i][j] = E[i-1][j];
				}
			}
			prev[j] = C[i][j];
		}
	}

	for(int i = 0; i < count2; i++)
	{
		if( els[i].s <= a && els[i].end >= a )
		{
			els[i].dist = 0;
		}
	}

	while(1)
	{
		int index;
		bool found = false;
		int min;
		for(int i = 0; i < count2; i++)
		{
			if( !els[i].used && (!found || min > els[i].dist ) )
			{
				found = true;
				min = els[i].dist;
				index = i;
			}
		}

		if( !found )
		{
			break;
		}

		els[index].used = true;

		for(int i = 0; i < count2; i++)
		{
			if( els[index].end + 1 >= els[i].s  && !els[i].used && els[index].dist + 1 < els[i].dist )
			{
				els[i].dist = els[index].dist + 1;
				els[i].prev = index;
				els[i].first_l = els[index].first_l;
			}
		}
	}

	int min_a;
	bool found_a = false;
	int index_a;
	int min_l;

	for(int i = 0; i < count2; i++)
	{
		if( els[i].s <= b && els[i].end >= b && els[i].dist != 100500 && 
			(!found_a || 
				min_a > els[i].dist || 
				(min_a == els[i].dist && min_l > els[i].first_l ) ) )
		{
			found_a = true;
			min_a = els[i].dist;
			index_a = i;
			min_l = els[i].first_l;
		}
	}

	if( !found_a )
	{
		printf("Not available\n");
		return 0;
	}

	vector<int> a1, a2, a3;
	do{
		a1.push_back(els[index_a].l);
		a3.push_back(mmin(els[index_a].end, b));
		a2.push_back(mmax(els[index_a].s, a));
		index_a = els[index_a].prev;
	} while( index_a != -1 );

	reverse(a1.begin(), a1.end());
	reverse(a2.begin(), a2.end());
	reverse(a3.begin(), a3.end());

	int prev_max = -1;
	for(int i = 0; i < a1.size(); i++)
	{
		printf("%c: %d-%d\n", 'A' + a1[i], mmax(prev_max, a2[i] + 1), a3[i] + 2);
		prev_max = a3[i] + 2;
	}

	return 0;
}