#include <bits/stdc++.h>
using namespace std;
int sum[4][400][400];
int t[3];
int mat[400][400];
int n, m, goalt;
void init() {
  for (int i = 0; i < n; i++) {
    sum[0][i][0] = sum[1][i][0] = 0;
    for (int j = 1; j < m; j++) {
      sum[0][i][j] = sum[0][i][j - 1];
      sum[1][i][j] = sum[1][i][j - 1];
      if (mat[i][j] == mat[i][j - 1]) {
        sum[0][i][j] += t[0];
        sum[1][i][j] += t[0];
        continue;
      }
      if (mat[i][j] > mat[i][j - 1]) {
        sum[0][i][j] += t[1];
        sum[1][i][j] += t[2];
        continue;
      }
      if (mat[i][j] < mat[i][j - 1]) {
        sum[0][i][j] += t[2];
        sum[1][i][j] += t[1];
        continue;
      }
    }
  }
  for (int j = 0; j < m; j++) {
    sum[2][0][j] = sum[3][0][j] = 0;
    for (int i = 1; i < n; i++) {
      sum[2][i][j] = sum[2][i - 1][j];
      sum[3][i][j] = sum[3][i - 1][j];
      if (mat[i][j] == mat[i - 1][j]) {
        sum[2][i][j] += t[0];
        sum[3][i][j] += t[0];
        continue;
      }
      if (mat[i - 1][j] > mat[i][j]) {
        sum[2][i][j] += t[1];
        sum[3][i][j] += t[2];
        continue;
      }
      if (mat[i - 1][j] < mat[i][j]) {
        sum[2][i][j] += t[2];
        sum[3][i][j] += t[1];
        continue;
      }
    }
  }
}
int ans[4];
int minabsdis;
inline int getLeftVal(int iup, int idn, int j) {
  return -(sum[2][idn][j] - sum[2][iup][j]) + sum[0][iup][j] + sum[1][idn][j];
}
void find() {
  minabsdis = 999999999;
  for (int iup = 0; iup < n; iup++) {
    for (int idn = iup + 2; idn < n; idn++) {
      set<pair<int, int> > leftsum;
      leftsum.clear();
      set<pair<int, int> >::iterator spi;
      leftsum.insert(pair<int, int>(getLeftVal(iup, idn, 0), 0));
      for (int j = 2; j < m; j++) {
        int now =
            sum[0][iup][j] + sum[1][idn][j] + sum[3][idn][j] - sum[3][iup][j];
        int should = now - goalt;
        spi = leftsum.lower_bound(pair<int, int>(should, 0));
        if (spi == leftsum.end()) {
          spi--;
        } else if (spi != leftsum.begin()) {
          int rnum = now - (*spi).first;
          spi--;
          int lnum = now - (*spi).first;
          spi++;
          if (fabs(lnum - goalt) < fabs(rnum - goalt)) {
            spi--;
          }
        }
        pair<int, int> findpair = *spi;
        int final = now - findpair.first;
        if ((int)fabs(final - goalt) < minabsdis) {
          minabsdis = fabs(final - goalt);
          ans[0] = iup;
          ans[1] = findpair.second;
          ans[2] = idn;
          ans[3] = j;
        }
        leftsum.insert(pair<int, int>(getLeftVal(iup, idn, j - 1), j - 1));
      }
    }
  }
}
int gettype(int l, int r, bool rev) {
  if (rev) l ^= r ^= l ^= r;
  if (l == r) return 0;
  if (l < r) return 1;
  if (l > r) return 2;
}
void checkAns() {
  int res = 0;
  for (int j = ans[1] + 1; j <= ans[3]; j++) {
    res += t[gettype(mat[ans[0]][j - 1], mat[ans[0]][j], false)];
    res += t[gettype(mat[ans[2]][j - 1], mat[ans[2]][j], true)];
  }
  for (int i = ans[0] + 1; i <= ans[2]; i++) {
    res += t[gettype(mat[i - 1][ans[1]], mat[i][ans[1]], true)];
    res += t[gettype(mat[i - 1][ans[3]], mat[i][ans[3]], false)];
  }
  if ((int)fabs(res - goalt) != minabsdis)
    printf("error!: check:%d, output:%d\n", (int)fabs(res - goalt), minabsdis);
}
int main() {
  while (scanf("%d%d%d", &n, &m, &goalt) != EOF) {
    for (int i = 0; i < 3; i++) {
      scanf("%d", &t[i]);
    }
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        scanf("%d", &mat[i][j]);
      }
    }
    init();
    find();
    for (int i = 0; i < 4; i++) {
      printf("%d ", ans[i] + 1);
    }
    puts("");
    checkAns();
  }
  return 0;
}
