Problem: In this problem you will need to deal with an n × m grid graph. The graph's vertices are the nodes of the n × m grid. The graph's edges are all the sides and diagonals of the grid's unit squares.

The figure below shows a 3 × 5 graph. The black lines are the graph's edges, the colored circles are the graph's vertices. The vertices of the graph are painted on the picture for a reason: the coloring is a correct vertex coloring of the 3 × 5 graph into four colors. A graph coloring is correct if and only if each vertex is painted and no two vertices connected by an edge are painted the same color.

<image>

You are given the size of the grid graph n × m and the colors of some of its vertices. Find any way how to paint the unpainted vertices of the graph in 4 colors to make the final coloring a correct vertex graph coloring. If there is no such correct vertex coloring, say that the answer doesn't exist.

Input

The first line contains two integers n and m (2 ≤ n, m ≤ 1000). Each of the next n lines consists of m characters — the given graph. Each character is either «0», «1», «2», «3», «4». Character «0» means that the corresponding vertex is unpainted, otherwise the character means the color of the vertex.

Assume that all the available colors are numbered from 1 to 4.

Output

If there is no way to get correct vertex coloring of the graph, print 0 in a single line. Otherwise print the colored n × m graph. Print the graph in the same format as in the input.

If multiple answers exist, print any of them.

Examples

Input

3 5
10101
00020
01000


Output

13131
42424
31313


Input

2 2
00
00


Output

12
34


Input

2 2
11
00


Output

0

Note

The answer to the first sample is shown on the picture (1 — green color, 2 — blue, 3 — dark blue, 4 — pink).

In the second sample there exists 4! answers, each of them is considered correct.

In the third sample two vertices with equal colors are connected. So the correct vertex coloring couldn't be obtained.

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
ifstream fin("frac1.in");
ofstream fout("frac1.out");
class compare : public std::binary_function<double, double, bool> {
 public:
  compare(double arg = 1e-7) : e(arg) {}
  bool operator()(const double &left, const double &right) const {
    return (abs(left - right) > e) && (left < right);
  }
  double e;
};
inline long long myabs(long long a) { return (a < 0) ? -a : a; }
inline int d_compare(double x, double y) {
  return (fabs(x - y) <= 1e-7) ? 0 : (x > y) ? 1 : -1;
}
inline int mod(long long x, int y) {
  if (y == 0) return x;
  if (x < 0) x = -x;
  if (x >= y) x %= y;
  return x;
}
inline int cmod(int x, int y) {
  if (y == 0) return x;
  if (x < 0) x += (abs(x) / y + 1) * y;
  if (x >= y) x = x % y;
  return x;
}
int Bcount(int mask) {
  int n = 0;
  while (mask) n += ((mask & -mask) != 0), mask &= ~(mask & -mask);
  return n;
}
inline bool Bstate(int mask, int idx) { return (mask & (1 << idx)); }
inline int B1(int mask, int idx) { return mask | (1 << idx); }
inline int B0(int mask, int idx) { return mask & ~(1 << idx); }
inline int drift(int mask, int n) { return mask & ((1 << n) - 1); }
void debugmask(int mask, int n) {
  for (int i = 0; i < n; i++) cout << Bstate(mask, i);
}
int dr[8] = {0, 0, -1, 1, -1, 1, -1, 1}, dc[8] = {-1, 1, 0, 0, 1, -1, -1, 1};
template <typename Ty>
void clear(Ty &q) {
  Ty empty;
  swap(q, empty);
}
bool check1(int n, int m, vector<vector<char> > &v, vector<vector<char> > &r,
            vector<bool> &res) {
  int i, j;
  vector<bool> b(n, 1);
  for (i = 0; i < n; ++i) {
    for (j = 0; j < m; ++j) {
      if (v[i][j] != '0') {
        if (r[i % 2][(j % 2) ^ res[i]] != v[i][j] && b[i] &&
            r[i % 2][1 - j % 2] == v[i][j]) {
          res[i] = 1;
        } else if (r[i % 2][(j % 2) ^ res[i]] != v[i][j]) {
          return 0;
        }
        b[i] = 0;
      }
    }
  }
  return 1;
}
bool check2(int n, int m, vector<vector<char> > &v, vector<vector<char> > &r,
            vector<bool> &res) {
  int i, j;
  vector<bool> b(m, 1);
  for (i = 0; i < n; ++i) {
    for (j = 0; j < m; ++j) {
      if (v[i][j] != '0') {
        if (r[j % 2][(i % 2) ^ res[j]] != v[i][j] && b[j] &&
            r[j % 2][1 - i % 2] == v[i][j]) {
          res[j] = 1;
        } else if (r[j % 2][(i % 2) ^ res[j]] != v[i][j]) {
          return 0;
        }
        b[j] = 0;
      }
    }
  }
  return 1;
}
void print1(int n, int m, vector<vector<char> > &r, vector<bool> &res) {
  int i, j;
  for (i = 0; i < n; ++i) {
    for (j = 0; j < m; ++j) {
      cout << r[i % 2][(j % 2) ^ res[i]];
    }
    cout << endl;
  }
}
void print2(int n, int m, vector<vector<char> > &r, vector<bool> &res) {
  int i, j;
  for (i = 0; i < n; ++i) {
    for (j = 0; j < m; ++j) {
      cout << r[j % 2][(i % 2) ^ res[j]];
    }
    cout << endl;
  }
}
bool solve(int first, int second, vector<vector<char> > &r, vector<bool> &b,
           int n, int m, vector<vector<char> > &v) {
  if (second == 2) {
    if (first == 1) {
      vector<bool> res(max(n, m));
      if (check1(n, m, v, r, res)) {
        print1(n, m, r, res);
        return 1;
      }
      if (check2(n, m, v, r, res)) {
        print2(n, m, r, res);
        return 1;
      }
    } else {
      if (solve(1, 0, r, b, n, m, v)) {
        return 1;
      }
    }
  } else {
    for (int i = 1; i < 5; ++i) {
      if (b[i]) {
        b[i] = 0;
        r[first][second] = '0' + i;
        if (solve(first, second + 1, r, b, n, m, v)) {
          return 1;
        }
        b[i] = 1;
      }
    }
  }
  return 0;
}
int main() {
  cin.tie(NULL);
  ios_base::sync_with_stdio(0);
  int n, m, i, j;
  cin >> n >> m;
  vector<vector<char> > r(2, vector<char>(2)), v(n, vector<char>(m));
  for (i = 0; i < n; ++i) {
    for (j = 0; j < m; ++j) {
      cin >> v[i][j];
    }
  }
  vector<bool> b(5, 1);
  if (!solve(0, 0, r, b, n, m, v)) {
    cout << 0 << endl;
  }
  return 0;
}