#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
const int INF = 0x3f3f3f3f;
int n;
double x, y;
int a[1001][1001];
pair<long long, long long> seg[1001][1001];
double k;
int ty;
long long work_point(int fu, int ck) {
  double b = (double)ck - k * (double)(fu);
  b *= 1000000.0;
  return llround(b);
}
pair<long long, long long> work(int fu, int ck) {
  if (ty == 1) {
    return make_pair(work_point(fu, ck - 1), work_point(fu - 1, ck));
  } else if (ty == 2) {
    return make_pair(work_point(fu - 1, ck - 1), work_point(fu, ck));
  } else if (ty == 3) {
    return make_pair(work_point(fu - 1, ck - 1), work_point(fu, ck));
  } else {
    return make_pair(work_point(fu, ck - 1), work_point(fu - 1, ck));
  }
}
const int N = 1 << 21;
int tree[N + N], tag[N + N];
void push_down(int index) {
  tree[index] = max(tree[index], tag[index]);
  if (index < N) {
    tag[index << 1] = max(tag[index << 1], tag[index]);
    tag[index << 1 | 1] = max(tag[index << 1 | 1], tag[index]);
  }
}
void push_up(int index) {
  tree[index] = min(tree[index << 1], tree[index << 1 | 1]);
}
void modify(int ll, int rr, int val, int now = 1, int l = 1, int r = N + 1) {
  push_down(now);
  if (r <= ll || l >= rr) {
    return;
  }
  if (r <= rr && l >= ll) {
    tag[now] = max(tag[now], val);
    push_down(now);
    return;
  }
  int mid = (l + r) >> 1;
  modify(ll, rr, val, now << 1, l, mid);
  modify(ll, rr, val, now << 1 | 1, mid, r);
  push_up(now);
}
int query(int ll, int rr, int now = 1, int l = 1, int r = N + 1) {
  push_down(now);
  if (r <= ll || l >= rr) {
    return INF;
  }
  if (r <= rr && l >= ll) {
    return tree[now];
  }
  int mid = (l + r) >> 1;
  return min(query(ll, rr, now << 1, l, mid),
             query(ll, rr, now << 1 | 1, mid, r));
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> x >> y;
  if (x == 0) {
    for (int i = 1; i <= n; ++i)
      for (int j = 1; j <= n; ++j) cin >> a[i][j];
    long long rest = 0;
    for (int i = 1; i <= n; ++i) {
      int maxi = 0;
      for (int j = 1; j <= n; ++j) {
        maxi = max(maxi, a[i][j]);
      }
      rest += maxi;
    }
    cout << rest << endl;
    return 0;
  }
  if (y == 0) {
    for (int i = 1; i <= n; ++i)
      for (int j = 1; j <= n; ++j) cin >> a[i][j];
    long long rest = 0;
    for (int j = 1; j <= n; ++j) {
      int maxi = 0;
      for (int i = 1; i <= n; ++i) {
        maxi = max(maxi, a[i][j]);
      }
      rest += maxi;
    }
    cout << rest << endl;
    return 0;
  }
  k = y / x;
  if (y > 0) {
    if (x > 0) {
      ty = 1;
    } else {
      ty = 2;
    }
  } else {
    if (x > 0) {
      ty = 3;
    } else {
      ty = 4;
    }
  }
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j) cin >> a[i][j];
  map<long long, int> dul;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j) {
      seg[i][j] = work(i, j);
      dul[seg[i][j].first] = dul[seg[i][j].second] = 1;
    }
  int cnt = 0;
  for (map<long long, int>::iterator ite = dul.begin(); ite != dul.end();
       ite++) {
    ite->second = ++cnt;
  }
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j)
      seg[i][j].first = dul[seg[i][j].first],
      seg[i][j].second = dul[seg[i][j].second];
  long long rest = 0;
  if (ty == 1) {
    for (int j = 1; j <= n; ++j) {
      for (int i = 1; i <= n; ++i) {
        rest += max(0, a[i][j] - query(seg[i][j].first, seg[i][j].second));
        modify(seg[i][j].first, seg[i][j].second, a[i][j]);
      }
    }
  }
  if (ty == 2) {
    for (int j = 1; j <= n; ++j) {
      for (int i = n; i >= 1; --i) {
        rest += max(0, a[i][j] - query(seg[i][j].first, seg[i][j].second));
        modify(seg[i][j].first, seg[i][j].second, a[i][j]);
      }
    }
  }
  if (ty == 3) {
    for (int j = n; j >= 1; --j) {
      for (int i = 1; i <= n; ++i) {
        rest += max(0, a[i][j] - query(seg[i][j].first, seg[i][j].second));
        modify(seg[i][j].first, seg[i][j].second, a[i][j]);
      }
    }
  }
  if (ty == 4) {
    for (int j = n; j >= 1; --j) {
      for (int i = n; i >= 1; --i) {
        rest += max(0, a[i][j] - query(seg[i][j].first, seg[i][j].second));
        modify(seg[i][j].first, seg[i][j].second, a[i][j]);
      }
    }
  }
  cout << rest << endl;
  return 0;
}
