public static void Main()
int rowsAndCols = int.Parse(Console.ReadLine());
string[] directions = Console.ReadLine()
char[,] matrix = new char[rowsAndCols, rowsAndCols];
for (int row = 0; row < rowsAndCols; row++)
char[] inputRowValues = Console.ReadLine()
for (int col = 0; col < rowsAndCols; col++)
matrix[row, col] = inputRowValues[col];
if (inputRowValues[col] == 's')
else if (inputRowValues[col] == 'c')
foreach (string direction in directions)
if (currentCol - 1 >= 0 && currentCol - 1 <= rowsAndCols - 1)
char currentElement = matrix[currentRow, currentCol];
if (currentElement == 'e')
Console.WriteLine("Game over! ({0}, {1})", currentRow, currentCol);
else if (currentElement == 'c')
matrix[currentRow, currentCol] = '*';
Console.WriteLine("You collected all coals! ({0}, {1})", currentRow, currentCol);
if (currentCol + 1 >= 0 && currentCol + 1 <= rowsAndCols - 1)
char currentElement = matrix[currentRow, currentCol];
if (currentElement == 'e')
Console.WriteLine("Game over! ({0}, {1})", currentRow, currentCol);
else if (currentElement == 'c')
matrix[currentRow, currentCol] = '*';
Console.WriteLine("You collected all coals! ({0}, {1})", currentRow, currentCol);
if (currentRow - 1 >= 0 && currentRow - 1 <= rowsAndCols - 1)
char currentElement = matrix[currentRow, currentCol];
if (currentElement == 'e')
Console.WriteLine("Game over! ({0}, {1})", currentRow, currentCol);
else if (currentElement == 'c')
matrix[currentRow, currentCol] = '*';
Console.WriteLine("You collected all coals! ({0}, {1})", currentRow, currentCol);
if (currentRow + 1 >= 0 && currentRow + 1 <= rowsAndCols - 1)
char currentElement = matrix[currentRow, currentCol];
if (currentElement == 'e')
Console.WriteLine("Game over! ({0}, {1})", currentRow, currentCol);
else if (currentElement == 'c')
matrix[currentRow, currentCol] = '*';
Console.WriteLine("You collected all coals! ({0}, {1})", currentRow, currentCol);
Console.WriteLine("{0} coals left. ({1}, {2})", countCoal, currentRow, currentCol);