#include <iostream>
#include <fstream>
#include <cassert>
#include <cstdlib>
#include <cmath>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
#include <queue>
#include <list>
#include <cstring>

#define all(x) (x).begin(),(x).end()

using namespace std;

const int NMAX = 2e5;

const int nmax = 2e3;
const int mmax = 2e2;

bool hasdigit[NMAX];

char** s; // [nmax][mmax];
char** old; //[nmax][mmax];

bool** add; //[nmax][mmax];
int n,m;

template <typename T>
T* allocate(int n)
{
	return (T*)calloc(n, sizeof(T));
}

template <typename T>
T** allocate(int n, int m)
{
	T** result = (T**)calloc(n, sizeof(T*));
	for (int i = 0; i < n; i ++)
		result[i] = (T*)calloc(m, sizeof(T));
	return result;
}

template <typename T>
T*** allocate(int n, int m, int k)
{
	T*** result = (T***)calloc(n, sizeof(T**));
	for (int i = 0; i < n; i ++)
	{
		result[i] = (T**)calloc(m, sizeof(T*));
		for (int j = 0; j < m; j ++)
			result[i][j] = (T*) calloc(k, sizeof(T));
	}
	return result;
}

void init()
{
	int N = n + 10;
	int M = m + 10;
	s = allocate<char>(N, M);
	old = allocate<char>(N, M);
	add = allocate<bool>(N, M);
}

inline char next(char c)
{
	if (c == '9') 
		return '0';
	else
		return c + 1;
}

inline char prev(char c)
{
	if (c == '0')
		return '9';
	else
		return c - 1;
}

bool assign(char& lhs, char rhs)
{	
	if (lhs == '*' || lhs == rhs)
	{
		lhs = rhs;
		return true;
	}
	return false;
}

bool gen(int column)
{
	if (column < 0) return true;
	for (char c = '0'; c <= '9'; c ++)
	{
		if (!hasdigit[column]) s[0][column] = c;
		bool ok = 1;
		for (int i = 0; i + 1 < n && ok; i ++)
			if (s[i][column] != '*')
				ok = ok && assign(s[i + 1][column] , add[i+1][column] ? next(s[i][column]) : s[i][column]);
		for (int i = n - 1; i > 0 && ok; i --)
			if (s[i][column] != '*')
				ok = ok && assign(s[i - 1][column] , add[i][column] ? prev(s[i][column]) : s[i][column]);
		if (ok)
		{
			assert(s[0][column] != '*');
			if (column > 0)
				for (int i = 0; i + 1 < n; i ++)
					if (s[i][column] == '9' && s[i + 1][column] == '0')
						add[i+1][column-1] = 1;
			if (gen(column - 1)) return true; 
		}
		for (int i = 0; i < n; i ++)
		{
			s[i][column] = old[i][column];
			if (column > 0) add[i][column-1] = 0;
		}
		if (hasdigit[column] || !ok) return false;
	}
	return false;
};

int main()
{
	freopen("calendar.in","r",stdin);
	freopen("calendar.out","w",stdout);
	scanf("%d%d\n",&n,&m);
	init();
	for (int i = 0; i < n; i ++)
	{
		gets(s[i]); 
		for (int j = 0; j < m; j ++)
		{
			old[i][j] = s[i][j];
			if (isdigit(s[i][j]))
				hasdigit[j] = 1;
		}
		s[m-1][i] = 0;
	}
	for (int i = 0; i < n; i ++)
		add[i][m-1] = 1;
	bool ok = gen(m-1);
	assert(ok);
	printf("%s\n", s[0]);
	return 0;
};

