﻿using System;
using System.Linq;
using System.Numerics;

public class Program
{
    private static BigInteger[,] matrix;
    public static void Main()
    {
        int[] matrixSize = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int[] mainBaseLocation = Console.ReadLine().Split().Select(int.Parse).ToArray();

        int rows = matrixSize[0];