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;
const int N = 1010;
const int oo = 1e9;
int n, m, cc[N][N];
bool vis[N][N];
char g[N][N];
int fx[8] = {0, 1, 0, -1, 1, -1, -1, 1};
int fy[8] = {1, 0, -1, 0, -1, -1, 1, 1};
void dfs(int i, int j, int color, int rotate) {
  if (i <= 0 || j <= 0 || i > n || j > m) return;
  if (vis[i][j]) return;
  if (!cc[i][j]) cc[i][j] = color;
  vis[i][j] = 1;
  if (rotate) {
    dfs(i + 2, j, color, rotate);
    dfs(i - 2, j, color, rotate);
  } else {
    dfs(i, j + 2, color, rotate);
    dfs(i, j - 2, color, rotate);
  }
}
bool check(int rotate, int a, int b, int c, int d) {
  memset(vis, 0, sizeof vis);
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j) cc[i][j] = g[i][j] - '0';
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j)
      if (cc[i][j]) dfs(i, j, cc[i][j], rotate);
  if (!rotate) {
    for (int i = 1; i <= n; ++i) {
      set<int> st;
      if (i & 1 == 1)
        st.insert(a), st.insert(b);
      else
        st.insert(c), st.insert(d);
      for (int j = 1; j <= 2; ++j) st.erase(cc[i][j]);
      for (int j = 1; j <= 2; ++j) {
        if (!cc[i][j]) {
          cc[i][j] = *st.begin();
          dfs(i, j, cc[i][j], rotate);
        }
        st.erase(cc[i][j]);
      }
      if (st.size()) return false;
    }
  } else {
    for (int j = 1; j <= m; ++j) {
      set<int> st;
      if (j & 1 == 1)
        st.insert(a), st.insert(b);
      else
        st.insert(c), st.insert(d);
      for (int i = 1; i <= 2; ++i) st.erase(cc[i][j]);
      for (int i = 1; i <= 2; ++i) {
        if (!cc[i][j]) {
          cc[i][j] = *st.begin();
          dfs(i, j, cc[i][j], rotate);
        }
        st.erase(cc[i][j]);
      }
      if (st.size()) return false;
    }
  }
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j)
      for (int k = 0; k < 8; ++k) {
        int newX = fx[k] + i;
        int newY = fy[k] + j;
        if (newX >= 1 && newY >= 1 && newX <= n && newY <= m &&
            cc[i][j] == cc[newX][newY])
          return false;
      }
  return true;
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) scanf("%s", g[i] + 1);
  for (int it = 0; it <= 1; ++it)
    for (int a = 1; a <= 4; ++a)
      for (int b = 1; b <= 4; ++b)
        for (int c = 1; c <= 4; ++c)
          for (int d = 1; d <= 4; ++d) {
            set<int> st;
            st.insert(a), st.insert(b), st.insert(c), st.insert(d);
            if (st.size() == 4) {
              if (!check(it, a, b, c, d)) continue;
              for (int i = 1; i <= n; ++i) {
                for (int j = 1; j <= m; ++j) printf("%d", cc[i][j]);
                puts("");
              }
              return 0;
            }
          }
  puts("0");
  return 0;
}