#include <bits/stdc++.h>
#define ii pair<int,int>

using namespace std;

int n,m;
char grid[1010][1010];
int ssize[1010][1010];
int cols[1010][1010];
bool vis[1010][1010];

int dx[4]={1,-1,0,0};
int dy[4]={0,0,-1,1};

bool ingrid(int x,int y)
{
    return (x>=0 && y>=0 && x<n && y<m && grid[x][y]=='.');
}

int bfs(int sx,int sy)
{
    int si=0;
    queue<ii> q;
    q.push(ii(sx,sy));
    vis[sx][sy]=true;
    while(!q.empty())
    {
        ii u=q.front();
        q.pop();
        si++;
        for(int i=0;i<4;i++)
        {
            int x=u.first+dx[i];
            int y=u.second+dy[i];
            if(ingrid(x,y) && !vis[x][y])
            {
                q.push(ii(x,y));
                vis[x][y]=true;
            }
        }
    }

    return si;
}

void bfsssize(int sx,int sy,int col,int siz)
{
    cols[sx][sy]=col;
    queue<ii> q;
    q.push(ii(sx,sy));

    while(!q.empty())
    {
        ii u=q.front();
        q.pop();
        ssize[u.first][u.second]=siz;
        for(int i=0;i<4;i++)
        {
            int x=u.first+dx[i];
            int y=u.second+dy[i];
            if(ingrid(x,y) && cols[x][y]==-1)
            {
                q.push(ii(x,y));
                cols[x][y]=col;
            }
        }
    }

}

int main()
{
    ios::sync_with_stdio(false);
    cin>>n>>m;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)cin>>grid[i][j];
    }

    int col=0;
    memset(cols,-1,sizeof cols);
    memset(ssize,0,sizeof ssize);

    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(cols[i][j]==-1 && grid[i][j]=='.')
            {
                memset(vis,false,sizeof vis);
                int siz = bfs(i,j)%10;
                bfsssize(i,j,col,siz);
                col++;
            }
        }
    }

    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(grid[i][j]=='.')cout<<'.';
            else
            {
                int ans=1;
                set<int> se;
                for(int it=0;it<4;it++)
                {
                    int x=i+dx[it];
                    int y=j+dy[it];
                    if(ingrid(x,y) && se.find(cols[x][y])==se.end())
                    {
                        se.insert(cols[x][y]);
                        ans+=ssize[x][y];
                    }
                }
                cout<<ans%10;
            }
        }
        cout<<'\n';

    }

   /* string res[n];

    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(grid[i][j]=='.')res[i]+='.';
            else
            {
                int ans=1;
                set<int> se;
                for(int it=0;it<4;it++)
                {
                    int x=i+dx[it];
                    int y=j+dy[it];
                    if(ingrid(x,y) && se.find(cols[x][y])==se.end())
                    {
                        se.insert(cols[x][y]);
                        ans+=ssize[x][y];
                    }
                }
                res[i]+=(char)(ans%10+'0');
            }
        }

    }

    for(int i=0;i<n;i++)cout<<res[i]<<'\n';*/

    return 0;
}


#include <iostream>
#include <stdio.h>
#include <string.h>

using namespace std;
int n,m;

int sea(int n,int m,char mat[][1001],bool vis[][1001],int x,int y)
{
    int ans=1;
    if(x>0 && mat[x-1][y]=='.' && !vis[x-1][y])
    {
        vis[x-1][y]=true;
        ans+=sea(n,m,mat,vis,x-1,y);
    }
    if(x<n-1 && mat[x+1][y]=='.' && !vis[x+1][y])
    {
        vis[x+1][y]=true;
        ans+=sea(n,m,mat,vis,x+1,y);
    }
    if(y>0 && mat[x][y-1]=='.' && !vis[x][y-1])
    {
        vis[x][y-1]=true;
        ans+=sea(n,m,mat,vis,x,y-1);
    }
    if(y<m-1 && mat[x][y+1]=='.' && !vis[x][y+1])
    {
        vis[x][y+1]=true;
        ans+=sea(n,m,mat,vis,x,y+1);
    }
    return (ans%10);
}

int main()
{

    cin>>n>>m;
    char mat[n][1001];

    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
            cin>>mat[i][j];
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(mat[i][j]=='.')cout<<'.';
            else
            {
                bool vis[n][1001];
                for(int i=0;i<n;i++)
                {
                    memset(vis[i],false,m);
                }
                cout<<sea(n,m,mat,vis,i,j);
            }
        }
        cout<<endl;
    }

    return 0;
}


#include <bits/stdc++.h>
#define ii pair<int,int>

using namespace std;

int n,m;
char grid[1010][1010];
vector<int> ssize;
int cols[1010][1010];
bool vis[1010][1010];

int dx[4]={1,-1,0,0};
int dy[4]={0,0,-1,1};

bool ingrid(int x,int y)
{
    return (x>=0 && y>=0 && x<n && y<m && grid[x][y]=='.');
}

int bfs(int sx,int sy,int col)
{
    int si=0;
    queue<ii> q;
    q.push(ii(sx,sy));
    cols[sx][sy]=col;
    while(!q.empty())
    {
        ii u=q.front();
        q.pop();
        si++;
        for(int i=0;i<4;i++)
        {
            int x=u.first+dx[i];
            int y=u.second+dy[i];
            if(ingrid(x,y) && cols[x][y]==-1)
            {
                q.push(ii(x,y));
                vis[x][y]=true;
                cols[x][y]=col;
            }
        }
    }

    return si;
}

int main()
{
    ios::sync_with_stdio(false);
    cin>>n>>m;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)cin>>grid[i][j];
    }

    int col=0;
    memset(cols,-1,sizeof cols);
    ssize.clear();

    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(cols[i][j]==-1 && grid[i][j]=='.')
            {
                ssize.push_back(bfs(i,j,col)%10);
                col++;
            }
        }
    }

    string res[n];

    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(grid[i][j]=='.')res[i]+='.';
            else
            {
                int ans=1;
                set<int> se;
                for(int it=0;it<4;it++)
                {
                    int x=i+dx[it];
                    int y=j+dy[it];
                    if(ingrid(x,y) && se.find(cols[x][y])==se.end())
                    {
                        se.insert(cols[x][y]);
                        ans+=ssize[cols[x][y]];
                    }
                }
                res[i]+=(char)(ans%10+'0');
            }
        }

    }

    for(int i=0;i<n;i++)cout<<res[i]<<'\n';

    return 0;
}


#include <iostream>
#include <stdio.h>
#include <string.h>

using namespace std;
int n,m;

int sea(int n,int m,char mat[][1001],bool vis[][1001],int x,int y)
{
    int ans=1;
    if(x>0 && mat[x-1][y]=='.' && !vis[x-1][y])
    {
        vis[x-1][y]=true;
        ans+=sea(n,m,mat,vis,x-1,y);
    }
    if(x<n-1 && mat[x+1][y]=='.' && !vis[x+1][y])
    {
        vis[x+1][y]=true;
        ans+=sea(n,m,mat,vis,x+1,y);
    }
    if(y>0 && mat[x][y-1]=='.' && !vis[x][y-1])
    {
        vis[x][y-1]=true;
        ans+=sea(n,m,mat,vis,x,y-1);
    }
    if(y<m-1 && mat[x][y+1]=='.' && !vis[x][y+1])
    {
        vis[x][y+1]=true;
        ans+=sea(n,m,mat,vis,x,y+1);
    }
    return ans;
}

int main()
{

    cin>>n>>m;
    char mat[n][1001];

    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
            cin>>mat[i][j];
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(mat[i][j]=='.')cout<<'.';
            else
            {
                bool vis[n][1001];
                for(int i=0;i<n;i++)
                {
                    memset(vis[i],false,m);
                }
                cout<<sea(n,m,mat,vis,i,j);
            }
        }
        cout<<endl;
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

char arr[1009][1009];
int n,m;

int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};
bool vis[1009][1009];

bool getdir(int x,int y,int i)
{
    int xx=dx[i]+x;
    int yy=dy[i]+y;
    return xx>=0 && xx<n && yy>=0 && yy<m && (arr[xx][yy]=='.') && (!vis[xx][yy]) ;
}

struct pt
{
    int x,y;
};

char bfs(int x,int y)
{
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)vis[i][j]=false;
    }
    queue<pt> q;
    pt xy;
    xy.x=x;
    xy.y=y;
    q.push(xy);

    vis[x][y]=true;
    int surf=1;

    while(!q.empty())
    {
        pt s=q.front(),e;
        q.pop();
        for(int i=0;i<4;i++)
        {
            if(getdir(s.x,s.y,i))
            {
                e.x=s.x+dx[i];
                e.y=s.y+dy[i];
                q.push(e);
                surf++;
                vis[e.x][e.y]=true;

            }
        }

    }

    surf%=10;
    return ((char)('0'+surf));

}

int main()
{

    scanf("%d %d",&n,&m);
//    cin>>n>>m;
    for(int i=0;i<n;i++)
    {
        scanf("%s",arr+i);
//        cin>>arr[i];
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(arr[i][j]=='*')
                arr[i][j]=bfs(i,j);
        }
    }

//printf("test");
    for(int i=0;i<n;i++)
    {
//        cout<<arr[i]<<endl;
        printf("%s\n",arr+i);
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

string arr[1009];
int n,m;

int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};
bool vis[1009][1009];

bool getdir(int x,int y,int i)
{
    int xx=dx[i]+x;
    int yy=dy[i]+y;
    return xx>=0 && xx<n && yy>=0 && yy<m && (arr[xx][yy]=='.') && (!vis[xx][yy]) ;
}

struct pt
{
    int x,y;
};

char bfs(int x,int y)
{
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)vis[i][j]=false;
    }
    queue<pt> q;
    pt xy;
    xy.x=x;
    xy.y=y;
    q.push(xy);

    vis[x][y]=true;
    int surf=1;

    while(!q.empty())
    {
        pt s=q.front(),e;
        q.pop();
        for(int i=0;i<4;i++)
        {
            if(getdir(s.x,s.y,i))
            {
                e.x=s.x+dx[i];
                e.y=s.y+dy[i];
                q.push(e);
                surf++;
                vis[e.x][e.y]=true;

            }
        }

    }

    surf%=10;
    return ((char)('0'+surf));

}

int main()
{

    cin>>n>>m;
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }

    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(arr[i][j]=='*')
                arr[i][j]=bfs(i,j);
        }
    }

    for(int i=0;i<n;i++)
    {
        cout<<arr[i]<<endl;
    }

    return 0;
}


#include <bits/stdc++.h>
#define ii pair<int,int>

using namespace std;

int n,m;
char grid[1010][1010];
int ssize[1010][1010];
int cols[1010][1010];
bool vis[1010][1010];

int dx[4]={1,-1,0,0};
int dy[4]={0,0,-1,1};

bool ingrid(int x,int y)
{
    return (x>=0 && y>=0 && x<n && y<m && grid[x][y]=='.');
}

int bfs(int sx,int sy)
{
    int si=0;
    queue<ii> q;
    q.push(ii(sx,sy));
    vis[sx][sy]=true;
    while(!q.empty())
    {
        ii u=q.front();
        q.pop();
        si++;
        for(int i=0;i<4;i++)
        {
            int x=u.first+dx[i];
            int y=u.second+dy[i];
            if(ingrid(x,y) && !vis[x][y])
            {
                q.push(ii(x,y));
                vis[x][y]=true;
            }
        }
    }

    return si;
}

void bfsssize(int sx,int sy,int col,int siz)
{
    cols[sx][sy]=col;
    queue<ii> q;
    q.push(ii(sx,sy));

    while(!q.empty())
    {
        ii u=q.front();
        q.pop();
        ssize[u.first][u.second]=siz;
        for(int i=0;i<4;i++)
        {
            int x=u.first+dx[i];
            int y=u.second+dy[i];
            if(ingrid(x,y) && cols[x][y]==-1)
            {
                q.push(ii(x,y));
                cols[x][y]=col;
            }
        }
    }

}

int main()
{
    ios::sync_with_stdio(false);
    cin>>n>>m;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)cin>>grid[i][j];
    }

    int col=0;
    memset(cols,-1,sizeof cols);
    memset(ssize,0,sizeof ssize);

    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(cols[i][j]==-1 && grid[i][j]=='.')
            {
                memset(vis,false,sizeof vis);
                int siz = bfs(i,j)%10;
                bfsssize(i,j,col,siz);
                col++;
            }
        }
    }

    string res[n];

    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(grid[i][j]=='.')res[i]+='.';
            else
            {
                int ans=1;
                set<int> se;
                for(int it=0;it<4;it++)
                {
                    int x=i+dx[it];
                    int y=j+dy[it];
                    if(ingrid(x,y) && se.find(cols[x][y])==se.end())
                    {
                        se.insert(cols[x][y]);
                        ans+=ssize[x][y];
                    }
                }
                res[i]+=(char)(ans%10+'0');
            }
        }

    }

    for(int i=0;i<n;i++)cout<<res[i]<<'\n';

    return 0;
}


#include <bits/stdc++.h>
#define ii pair<int,int>

using namespace std;

int n,m;
char grid[1010][1010];
int ssize[1010][1010];
bool cols[1010][1010];
bool vis[1010][1010];
int rep[1010][1010];

int dx[4]={1,-1,0,0};
int dy[4]={0,0,-1,1};

bool ingrid(int x,int y)
{
    return (x>=0 && y>=0 && x<n && y<m);
}

int bfs(int sx,int sy)
{
    int si=0;
    queue<ii> q;
    q.push(ii(sx,sy));
    vis[sx][sy]=true;
    while(!q.empty())
    {
        ii u=q.front();
        q.pop();
        si++;
        for(int i=0;i<4;i++)
        {
            int x=u.first+dx[i];
            int y=u.second+dy[i];
            if(ingrid(x,y) && grid[x][y]=='.' && !vis[x][y])
            {
                q.push(ii(x,y));
                vis[x][y]=true;
            }
        }
    }

    return si;
}

void bfsssize(int sx,int sy,int siz)
{
    cols[sx][sy]=true;
    queue<ii> q;
    q.push(ii(sx,sy));

    while(!q.empty())
    {
        ii u=q.front();
        q.pop();
        ssize[u.first][u.second]=siz;
        for(int i=0;i<4;i++)
        {
            int x=u.first+dx[i];
            int y=u.second+dy[i];
            if(ingrid(x,y))
            {
                if(grid[x][y]=='.')
                {
                    if(!cols[x][y])
                    {
                        q.push(ii(x,y));
                        cols[x][y]=1;
                    }

                }else
                {
                    if(!vis[x][y])
                    {
                        vis[x][y]=true;
                        rep[x][y]+=siz;
                    }
                }

            }
        }
    }

}

int main()
{
    ios::sync_with_stdio(false);
    cin>>n>>m;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)cin>>grid[i][j];
    }

    memset(cols,false,sizeof cols);
    memset(ssize,0,sizeof ssize);
    memset(rep,0,sizeof rep);

    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(!cols[i][j] && grid[i][j]=='.')
            {
                memset(vis,false,sizeof vis);
                int siz = bfs(i,j)%10;
                bfsssize(i,j,siz);

            }
        }
    }

    string res[n];

    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(grid[i][j]=='.')res[i]+='.';
            else
            {
                res[i]+=(char)('0'+(1+rep[i][j])%10);
            }
        }

    }

    for(int i=0;i<n;i++)cout<<res[i]<<'\n';

    return 0;
}


//http://codeforces.com/problemset/problem/616/C
#include <iostream>
#include <string>
#include <vector>
#include <stack>
using namespace std;

long map[1001][1001];
long mark_map[1001][1001];
int mark{1};
int n,w;

long dfs(int x,int y)
{
	if(map[y][x]==0) return 0;
	long s = map[y][x];
	mark_map[y][x] = mark;
	long r{1};
	map[y][x] = 0;
	if(x-1>=0) r+=dfs(x-1,y);
	if(x+1<w) r+=dfs(x+1,y);
	if(y-1>=0) r+=dfs(x,y-1);
	if(y+1<n) r+=dfs(x,y+1);
	map[y][x] = s;
	return r;
}
int used_marks[4] = {-1,-1,-1,-1};
int marks_i{0};

bool try_to_mark(int pattern)
{
	if(pattern==0) return false;
	for(int i{0};i<marks_i;i++)
		if(used_marks[i]==pattern)
			return false;
	used_marks[marks_i++] = pattern;
	return true;
}

int main()
{
	std::ios::sync_with_stdio(false);
	cin >> n >> w;
	string s;
	for(int i{0};i<n;i++)
	{
		cin >> s;
		for(int j{0};j<w;j++)
		{
			map[i][j] = (s[j] == '.') ? 1 : 0;
		}
	}
	for(int i{0};i<n;i++)
	{
		for(int j{0};j<w;j++)
		{
			if(map[i][j]>0)
			{
				map[i][j] = dfs(j,i)%10;
				++mark;
			}
		}
	}
	for(int i{0};i<n;i++)
	{
		for(int j{0};j<w;j++)
		{
			if(map[i][j]==0)
			{
				int r{1};
				if(j-1>=0){
					if(try_to_mark(mark_map[i][j-1]))
						r+=map[i][j-1];
				}
				if(j+1<w){
					if(try_to_mark(mark_map[i][j+1]))
						r+=map[i][j+1];
				}
				if(i-1>=0){
					if(try_to_mark(mark_map[i-1][j]))
						r+=map[i-1][j];
				}
				if(i+1<n){
					if(try_to_mark(mark_map[i+1][j]))
						r+=map[i+1][j];
				}
				cout<<r%10;
				//CLearn the marks
				marks_i = 0;
				used_marks[0] = used_marks[1] = -1;
			       	used_marks[2] = used_marks[3] = -1;
			}
			else cout<<'.';
		}
		cout<<endl;
	}
}


//http://codeforces.com/problemset/problem/616/C
#include <iostream>
#include <string>
#include <vector>
#include <stack>
using namespace std;

long map[1001][1001];
long mark_map[1001][1001];
int mark{1};
int n,w;

long dfs(int x,int y)
{
	if(map[y][x]<0) return 0;
	long s = map[y][x];
	mark_map[y][x] = mark;
	long r{1};
	map[y][x] = -1;
	if(x-1>=0) r+=dfs(x-1,y);
	if(x+1<w) r+=dfs(x+1,y);
	if(y-1>=0) r+=dfs(x,y-1);
	if(y+1<n) r+=dfs(x,y+1);
	map[y][x] = s;
	return r;
}
int used_marks[4] = {-1,-1,-1,-1};
int marks_i{0};

bool try_to_mark(int pattern)
{
	if(pattern==0) return false;
	for(int i{0};i<marks_i;i++)
		if(used_marks[i]==pattern)
			return false;
	used_marks[marks_i++] = pattern;
	return true;
}

int main()
{
	std::ios::sync_with_stdio(false);
	cin >> n >> w;
	string s;
	for(int i{0};i<n;i++)
	{
		cin >> s;
		for(int j{0};j<w;j++)
		{
			map[i][j] = (s[j] == '.') ? 1 : -1;
		}
	}
	for(int i{0};i<n;i++)
	{
		for(int j{0};j<w;j++)
		{
			if(map[i][j]>0)
			{
				map[i][j] = dfs(j,i)%10;
				++mark;
			}
		}
	}
	for(int i{0};i<n;i++)
	{
		for(int j{0};j<w;j++)
		{
			if(map[i][j]<0)
			{
				int r{1};
				if(j-1>=0){
					if(try_to_mark(mark_map[i][j-1]))
						r+=map[i][j-1];
				}
				if(j+1<w){
					if(try_to_mark(mark_map[i][j+1]))
						r+=map[i][j+1];
				}
				if(i-1>=0){
					if(try_to_mark(mark_map[i-1][j]))
						r+=map[i-1][j];
				}
				if(i+1<n){
					if(try_to_mark(mark_map[i+1][j]))
						r+=map[i+1][j];
				}
				cout<<r%10;
				//CLearn the marks
				marks_i = 0;
				used_marks[0] = used_marks[1] = -1;
			       	used_marks[2] = used_marks[3] = -1;
			}
			else cout<<'.';
		}
		cout<<endl;
	}
}


//http://codeforces.com/problemset/problem/616/C
#include <iostream>
#include <string>
#include <vector>
#include <stack>
using namespace std;

long map[1001][1001];
int n,w;

long dfs(int x,int y)
{
	if(map[y][x]==0) return 0;
	long s = map[y][x];
	long r{1};
	map[y][x] = 0;
	if(x-1>=0) r+=dfs(x-1,y);
	if(x+1<w) r+=dfs(x+1,y);
	if(y-1>=0) r+=dfs(x,y-1);
	if(y+1<n) r+=dfs(x,y+1);
	map[y][x] = s;
	return r;
}

int main()
{
	std::ios::sync_with_stdio(false);
	cin >> n >> w;
	string s;
	for(int i{0};i<n;i++)
	{
		cin >> s;
		for(int j{0};j<w;j++)
		{
			map[i][j] = (s[j] == '.') ? 1 : 0;
		}
	}
	for(int i{0};i<n;i++)
	{
		for(int j{0};j<w;j++)
		{
			if(map[i][j]>0)
			{
				map[i][j] = dfs(j,i)%10;
			}
		}
	}
	for(int i{0};i<n;i++)
	{
		for(int j{0};j<w;j++)
		{
			if(map[i][j]==0)
			{
				int r{1};
				if(j-1>=0) r+=map[i][j-1];
				if(j+1<w) r+=map[i][j+1];
				if(i-1>=0) r+=map[i-1][j];
				if(i+1<n) r+=map[i+1][j];
				cout<<r%10;
			}
			else cout<<'.';
		}
		cout<<endl;
	}
}


//http://codeforces.com/problemset/problem/616/C
#include <iostream>
#include <string>
#include <vector>
#include <set>
using namespace std;

long labyrinth[1001][1001];
long conn_comp_size[500001];
int mark{-1};
int n,w;

long dfs(int x,int y)
{
	if(labyrinth[y][x]<=0) return 0;
	++conn_comp_size[-mark];
	long r{1};
	labyrinth[y][x] = mark;
	if(x-1>=0) r+=dfs(x-1,y);
	if(x+1<w) r+=dfs(x+1,y);
	if(y-1>=0) r+=dfs(x,y-1);
	if(y+1<n) r+=dfs(x,y+1);
	return r;
}
int used_marks[4];
int marks_i{0};

bool try_to_mark(int pattern)
{
	if(pattern==0) return false;
	for(int i{0};i<marks_i;i++)
		if(used_marks[i]==pattern)
			return false;
	used_marks[marks_i++] = pattern;
	return true;
}

int main()
{
	std::ios::sync_with_stdio(false);
	cin >> n >> w;
	string s;
	for(int i{0};i<n;i++)
	{
		cin >> s;
		for(int j{0};j<w;j++)
		{
			labyrinth[i][j] = (s[j] == '.') ? 1 : 0;
		}
	}
	for(int i{0};i<n;i++)
	{
		for(int j{0};j<w;j++)
		{
			if(labyrinth[i][j]>0)
			{
				dfs(j,i);
				--mark;
			}
		}
	}
	for(int i{0};i<n;i++)
	{
		for(int j{0};j<w;j++)
		{
			if(labyrinth[i][j]==0)
			{
				long r{1};
				std::set<long> used;
				if(j-1>=0){
					if(used.insert(labyrinth[i][j-1]).second)
						r+=conn_comp_size[-labyrinth[i][j-1]];
				}
				if(j+1<w){
					if(used.insert(labyrinth[i][j+1]).second)
						r+=conn_comp_size[-labyrinth[i][j+1]];
				}
				if(i-1>=0){
					if(used.insert(labyrinth[i-1][j]).second)
						r+=conn_comp_size[-labyrinth[i-1][j]];
				}
				if(i+1<n){
					if(used.insert(labyrinth[i+1][j]).second)
						r+=conn_comp_size[-labyrinth[i+1][j]];
				}
				cout<<r%10;
			}
			else cout<<'.';
		}
		cout<<endl;
	}
}


//http://codeforces.com/problemset/problem/616/C
#include <iostream>
#include <string>
#include <vector>
using namespace std;

long labyrinth[1001][1001];
long conn_comp_size[500001];
int mark{-1};
int n,w;

long dfs(int x,int y)
{
	if(labyrinth[y][x]<=0) return 0;
	++conn_comp_size[-mark];
	long r{1};
	labyrinth[y][x] = mark;
	if(x-1>=0) r+=dfs(x-1,y);
	if(x+1<w) r+=dfs(x+1,y);
	if(y-1>=0) r+=dfs(x,y-1);
	if(y+1<n) r+=dfs(x,y+1);
	return r;
}
int used_marks[4];
int marks_i{0};

bool try_to_mark(int pattern)
{
	if(pattern==0) return false;
	for(int i{0};i<marks_i;i++)
		if(used_marks[i]==pattern)
			return false;
	used_marks[marks_i++] = pattern;
	return true;
}

int main()
{
	std::ios::sync_with_stdio(false);
	cin >> n >> w;
	string s;
	for(int i{0};i<n;i++)
	{
		cin >> s;
		for(int j{0};j<w;j++)
		{
			labyrinth[i][j] = (s[j] == '.') ? 1 : 0;
		}
	}
	for(int i{0};i<n;i++)
	{
		for(int j{0};j<w;j++)
		{
			if(labyrinth[i][j]>0)
			{
				dfs(j,i);
				--mark;
			}
		}
	}
	for(int i{0};i<n;i++)
	{
		for(int j{0};j<w;j++)
		{
			if(labyrinth[i][j]==0)
			{
				long r{1};
				if(j-1>=0){
					if(try_to_mark(labyrinth[i][j-1]))
						r+=conn_comp_size[-labyrinth[i][j-1]];
				}
				if(j+1<w){
					if(try_to_mark(labyrinth[i][j+1]))
						r+=conn_comp_size[-labyrinth[i][j+1]];
				}
				if(i-1>=0){
					if(try_to_mark(labyrinth[i-1][j]))
						r+=conn_comp_size[-labyrinth[i-1][j]];
				}
				if(i+1<n){
					if(try_to_mark(labyrinth[i+1][j]))
						r+=conn_comp_size[-labyrinth[i+1][j]];
				}
				cout<<r%10;
				//CLearn the marks
				marks_i = 0;
				used_marks[0] = used_marks[1] = 0;
			       	used_marks[2] = used_marks[3] = 0;
			}
			else cout<<'.';
		}
		cout<<endl;
	}
}


//http://codeforces.com/problemset/problem/616/C
#include <iostream>
#include <string>
#include <vector>
#include <map>
using namespace std;

long labyrinth[1001][1001];
map<long,long> conn_comp_size;
int mark{-1};
int n,w;

long dfs(int x,int y)
{
	if(labyrinth[y][x]<=0) return 0;
	++conn_comp_size[mark];
	long r{1};
	labyrinth[y][x] = mark;
	if(x-1>=0) r+=dfs(x-1,y);
	if(x+1<w) r+=dfs(x+1,y);
	if(y-1>=0) r+=dfs(x,y-1);
	if(y+1<n) r+=dfs(x,y+1);
	return r;
}
int used_marks[4];
int marks_i{0};

bool try_to_mark(int pattern)
{
	if(pattern==0) return false;
	for(int i{0};i<marks_i;i++)
		if(used_marks[i]==pattern)
			return false;
	used_marks[marks_i++] = pattern;
	return true;
}

int main()
{
	std::ios::sync_with_stdio(false);
	cin >> n >> w;
	string s;
	for(int i{0};i<n;i++)
	{
		cin >> s;
		for(int j{0};j<w;j++)
		{
			labyrinth[i][j] = (s[j] == '.') ? 1 : 0;
		}
	}
	for(int i{0};i<n;i++)
	{
		for(int j{0};j<w;j++)
		{
			if(labyrinth[i][j]>0)
			{
				dfs(j,i);
				--mark;
			}
		}
	}/*
	for(int i{0};i<n;i++)
	{
		for(int j{0};j<w;j++)
		{
			cout<<labyrinth[i][j]<<",";
		}
		cout<<endl;
	}*/

	for(int i{0};i<n;i++)
	{
		for(int j{0};j<w;j++)
		{
			if(labyrinth[i][j]==0)
			{
				long r{1};
				if(j-1>=0){
					if(try_to_mark(labyrinth[i][j-1]))
						r+=conn_comp_size[labyrinth[i][j-1]];
				}
				if(j+1<w){
					if(try_to_mark(labyrinth[i][j+1]))
						r+=conn_comp_size[labyrinth[i][j+1]];
				}
				if(i-1>=0){
					if(try_to_mark(labyrinth[i-1][j]))
						r+=conn_comp_size[labyrinth[i-1][j]];
				}
				if(i+1<n){
					if(try_to_mark(labyrinth[i+1][j]))
						r+=conn_comp_size[labyrinth[i+1][j]];
				}
				cout<<r%10;
				//CLearn the marks
				marks_i = 0;
				used_marks[0] = used_marks[1] = 0;
			       	used_marks[2] = used_marks[3] = 0;
			}
			else cout<<'.';
		}
		cout<<endl;
	}
}


//http://codeforces.com/problemset/problem/616/C
#include <iostream>
#include <string>
#include <vector>
#include <map>
using namespace std;

long labyrinth[1001][1001];
long mark_labyrinth[1001][1001];
map<long,long> conn_comp_size;
int mark{1};
int n,w;

long dfs(int x,int y)
{
	if(labyrinth[y][x]<0 || mark_labyrinth[y][x]>0) return 0;
	long s = labyrinth[y][x];
	mark_labyrinth[y][x] = mark;
	++conn_comp_size[mark];
	long r{1};
	labyrinth[y][x] = -1;
	if(x-1>=0) r+=dfs(x-1,y);
	if(x+1<w) r+=dfs(x+1,y);
	if(y-1>=0) r+=dfs(x,y-1);
	if(y+1<n) r+=dfs(x,y+1);
	labyrinth[y][x] = s;
	return r;
}
int used_marks[4] = {-1,-1,-1,-1};
int marks_i{0};

bool try_to_mark(int pattern)
{
	if(pattern==0) return false;
	for(int i{0};i<marks_i;i++)
		if(used_marks[i]==pattern)
			return false;
	used_marks[marks_i++] = pattern;
	return true;
}

int main()
{
	std::ios::sync_with_stdio(false);
	cin >> n >> w;
	string s;
	for(int i{0};i<n;i++)
	{
		cin >> s;
		for(int j{0};j<w;j++)
		{
			labyrinth[i][j] = (s[j] == '.') ? 1 : -1;
			mark_labyrinth[i][j] = -1;
		}
	}
	for(int i{0};i<n;i++)
	{
		for(int j{0};j<w;j++)
		{
			if(mark_labyrinth[i][j]<0)
			{
				dfs(j,i);
				++mark;
			}
		}
	}
	for(int i{0};i<n;i++)
	{
		for(int j{0};j<w;j++)
		{
			if(labyrinth[i][j]<0)
			{
				long r{1};
				if(j-1>=0){
					if(try_to_mark(mark_labyrinth[i][j-1]))
						r+=conn_comp_size[mark_labyrinth[i][j-1]];
				}
				if(j+1<w){
					if(try_to_mark(mark_labyrinth[i][j+1]))
						r+=conn_comp_size[mark_labyrinth[i][j+1]];
				}
				if(i-1>=0){
					if(try_to_mark(mark_labyrinth[i-1][j]))
						r+=conn_comp_size[mark_labyrinth[i-1][j]];
				}
				if(i+1<n){
					if(try_to_mark(mark_labyrinth[i+1][j]))
						r+=conn_comp_size[mark_labyrinth[i+1][j]];
				}
				cout<<r%10;
				//CLearn the marks
				marks_i = 0;
				used_marks[0] = used_marks[1] = -1;
			       	used_marks[2] = used_marks[3] = -1;
			}
			else cout<<'.';
		}
		cout<<endl;
	}
}


//http://codeforces.com/problemset/problem/616/C
#include <iostream>
#include <string>
#include <vector>
#include <map>
using namespace std;

long labyrinth[1001][1001];
long mark_labyrinth[1001][1001];
map<long,long> conn_comp_size;
int mark{1};
int n,w;

long dfs(int x,int y)
{
	if(labyrinth[y][x]<0 || mark_labyrinth[y][x]>0) return 0;
	long s = labyrinth[y][x];
	mark_labyrinth[y][x] = mark;
	++conn_comp_size[mark];
	long r{1};
	labyrinth[y][x] = -1;
	if(x-1>=0) r+=dfs(x-1,y);
	if(x+1<w) r+=dfs(x+1,y);
	if(y-1>=0) r+=dfs(x,y-1);
	if(y+1<n) r+=dfs(x,y+1);
	labyrinth[y][x] = s;
	return r;
}
int used_marks[4] = {-1,-1,-1,-1};
int marks_i{0};

bool try_to_mark(int pattern)
{
	if(pattern==0) return false;
	for(int i{0};i<marks_i;i++)
		if(used_marks[i]==pattern)
			return false;
	used_marks[marks_i++] = pattern;
	return true;
}

int main()
{
	std::ios::sync_with_stdio(false);
	cin >> n >> w;
	string s;
	for(int i{0};i<n;i++)
	{
		cin >> s;
		for(int j{0};j<w;j++)
		{
			labyrinth[i][j] = (s[j] == '.') ? 1 : -1;
		}
	}
	for(int i{0};i<n;i++)
	{
		for(int j{0};j<w;j++)
		{
			if(labyrinth[i][j]>0)
			{
				dfs(j,i);
				++mark;
			}
		}
	}

	for(int i{0};i<n;i++)
	{
		for(int j{0};j<w;j++)
		{
			if(labyrinth[i][j]<0)
			{
				long r{1};
				if(j-1>=0){
					if(try_to_mark(mark_labyrinth[i][j-1]))
						r+=conn_comp_size[mark_labyrinth[i][j-1]];
				}
				if(j+1<w){
					if(try_to_mark(mark_labyrinth[i][j+1]))
						r+=conn_comp_size[mark_labyrinth[i][j+1]];
				}
				if(i-1>=0){
					if(try_to_mark(mark_labyrinth[i-1][j]))
						r+=conn_comp_size[mark_labyrinth[i-1][j]];
				}
				if(i+1<n){
					if(try_to_mark(mark_labyrinth[i+1][j]))
						r+=conn_comp_size[mark_labyrinth[i+1][j]];
				}
				cout<<r%10;
				//CLearn the marks
				marks_i = 0;
				used_marks[0] = used_marks[1] = -1;
			       	used_marks[2] = used_marks[3] = -1;
			}
			else cout<<'.';
		}
		cout<<endl;
	}
}


//http://codeforces.com/problemset/problem/616/C
#include <iostream>
#include <string>
#include <vector>
#include <stack>
using namespace std;

long map[1001][1001];
long mark_map[1001][1001];
int mark;
int n,w;

long dfs(int x,int y)
{
	if(map[y][x]==0) return 0;
	long s = map[y][x];
	mark_map[y][x] = mark;
	long r{1};
	map[y][x] = 0;
	if(x-1>=0) r+=dfs(x-1,y);
	if(x+1<w) r+=dfs(x+1,y);
	if(y-1>=0) r+=dfs(x,y-1);
	if(y+1<n) r+=dfs(x,y+1);
	map[y][x] = s;
	return r;
}
int used_marks[4] = {-1,-1,-1,-1};
int marks_i{0};

bool try_to_mark(int pattern)
{
	for(int i{0};i<marks_i;i++)
		if(used_marks[i]==pattern)
			return false;
	used_marks[marks_i++] = pattern;
	return true;
}

int main()
{
	std::ios::sync_with_stdio(false);
	cin >> n >> w;
	string s;
	for(int i{0};i<n;i++)
	{
		cin >> s;
		for(int j{0};j<w;j++)
		{
			map[i][j] = (s[j] == '.') ? 1 : 0;
		}
	}
	for(int i{0};i<n;i++)
	{
		for(int j{0};j<w;j++)
		{
			if(map[i][j]>0)
			{
				map[i][j] = dfs(j,i)%10;
				++mark;
			}
		}
	}
	for(int i{0};i<n;i++)
	{
		for(int j{0};j<w;j++)
		{
			if(map[i][j]==0)
			{
				int r{1};
				if(j-1>=0){
					if(try_to_mark(mark_map[i][j-1]))
						r+=map[i][j-1];
				}
				if(j+1<w){
					if(try_to_mark(mark_map[i][j+1]))
						r+=map[i][j+1];
				}
				if(i-1>=0){
					if(try_to_mark(mark_map[i-1][j]))
						r+=map[i-1][j];
				}
				if(i+1<n){
					if(try_to_mark(mark_map[i+1][j]))
						r+=map[i+1][j];
				}
				cout<<r%10;
				//CLearn the marks
				marks_i = 0;
				used_marks[0] = used_marks[1] = -1;
			       	used_marks[2] = used_marks[3] = -1;
			}
			else cout<<'*';
		}
		cout<<endl;
	}
}


//http://codeforces.com/problemset/problem/616/C
#include <iostream>
#include <string>
#include <vector>
#include <stack>
using namespace std;

long map[1001][1001];
long mark_map[1001][1001];
int mark;
int n,w;

long dfs(int x,int y)
{
	if(map[y][x]==0) return 0;
	long s = map[y][x];
	mark_map[y][x] = mark;
	long r{1};
	map[y][x] = 0;
	if(x-1>=0) r+=dfs(x-1,y);
	if(x+1<w) r+=dfs(x+1,y);
	if(y-1>=0) r+=dfs(x,y-1);
	if(y+1<n) r+=dfs(x,y+1);
	map[y][x] = s;
	return r;
}
int used_marks[4] = {-1,-1,-1,-1};
int marks_i{0};

bool try_to_mark(int pattern)
{
	for(int i{0};i<marks_i;i++)
		if(used_marks[i]==pattern)
			return false;
	used_marks[marks_i++] = pattern;
	return true;
}

int main()
{
	std::ios::sync_with_stdio(false);
	cin >> n >> w;
	string s;
	for(int i{0};i<n;i++)
	{
		cin >> s;
		for(int j{0};j<w;j++)
		{
			map[i][j] = (s[j] == '.') ? 1 : 0;
		}
	}
	for(int i{0};i<n;i++)
	{
		for(int j{0};j<w;j++)
		{
			if(map[i][j]>0)
			{
				map[i][j] = dfs(j,i)%10;
				++mark;
			}
		}
	}
	for(int i{0};i<n;i++)
	{
		for(int j{0};j<w;j++)
		{
			if(map[i][j]==0)
			{
				int r{1};
				if(j-1>=0){
					if(try_to_mark(mark_map[i][j-1]))
						r+=map[i][j-1];
				}
				if(j+1<w){
					if(try_to_mark(mark_map[i][j+1]))
						r+=map[i][j+1];
				}
				if(i-1>=0){
					if(try_to_mark(mark_map[i-1][j]))
						r+=map[i-1][j];
				}
				if(i+1<n){
					if(try_to_mark(mark_map[i+1][j]))
						r+=map[i+1][j];
				}
				cout<<r%10;
				//CLearn the marks
				marks_i = 0;
				used_marks[0] = used_marks[1] = -1;
			       	used_marks[2] = used_marks[3] = -1;
			}
			else cout<<'.';
		}
		cout<<endl;
	}
}


#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#include<stdio.h>
#define ioS ios::sync_with_stdio(false);
#include<iostream>
using namespace std;

ll int power(ll int a,ll int b)
{
	if(b==0)
	return 1;
	else
	return a*power(a,b-1);
}
bool sortbya( int l, int r)
{
	return(r<l);
}
int ct=1;

char arr[1010][1010];
bool vis[1010][1010];
int com[1001][1001];
int sizc[1010];
int r,c;
void dfs(int i,int j,int btn)
{
	if(i<0||j<0||i>=r||j>=c)
	return;
	if(arr[i][j]=='*')
	return;
	if(vis[i][j])return;
	vis[i][j]=1;
	com[i][j]=btn;
	sizc[btn]++;

			dfs(i-1,j,btn);
			dfs(i+1,j,btn);
			dfs(i,j+1,btn);
			dfs(i,j-1,btn);
}
int main()
{
	ioS;
	cin>>r>>c;

	for(int i=0;i<r;i++)
	{
		string o;
		cin>>o;
		for(int j=0;j<c;j++)
		{
			arr[i][j]=o[j];
		}
	}
	int btn=0;
	for(int i=0;i<r;i++)
	{
		for(int j=0;j<c;j++)
		{
			if(arr[i][j]=='.')
			{
				if(vis[i][j]==0)
				{
					dfs(i,j,btn);
					btn++;
				}
			}
		}
	}

	/*for(int i=0;i<r;i++)
	{
		for(int j=0;j<c;j++)
		{
			if(arr[i][j]=='.')
			cout<<com[i][j];
			else
			cout<<'*';
		}
		cout<<endl;
	}

	for(int i=0;i<btn;i++)
	cout<<sizc[i]<<endl;*/

	for(int i=0;i<r;i++)
	{
		string ch;

		for(int j=0;j<c;j++)
		{
			set<int> se;
			se.clear();

			if(arr[i][j]=='*')
			{
				int ans=1;
				if(i+1<r&&j<c&&j>=0&&arr[i+1][j]=='.')
				{
					se.insert(com[i+1][j]);
				}
				if(i-1>=0&&j<c&&j>=0&&arr[i-1][j]=='.')
				{
					se.insert(com[i-1][j]);
				}
				if(i<r&&j-1>=0&&i>=0&&arr[i][j-1]=='.')
				{
					se.insert(com[i][j-1]);
				}
				if(i<r&&j+1<c&&i>=0&&arr[i][j+1]=='.')
				{
					se.insert(com[i][j+1]);
				}

				for(set<int> ::iterator it=se.begin();it!=se.end();it++)
				{
					ans+=sizc[*it];
				}
				ch+=char((ans%10)+'0');
			}
			else
			ch+='.';
		}
		cout<<ch<<endl;

	}
	return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#include<stdio.h>
#define ioS ios::sync_with_stdio(false);
#include<iostream>
using namespace std;

ll int power(ll int a,ll int b)
{
	if(b==0)
	return 1;
	else
	return a*power(a,b-1);
}
bool sortbya( int l, int r)
{
	return(r<l);
}
int ct=1;

char arr[1010][1010]={0};
bool vis[1010][1010]={0};
int com[1001][1001]={0};
int sizc[1010]={0};
int r,c;
void dfs(int i,int j,int btn)
{
	if(i<0||j<0||i>=r||j>=c)
	return;
	if(arr[i][j]=='*')
	return;
	if(vis[i][j])return;
	vis[i][j]=1;
	com[i][j]=btn;
	sizc[btn]++;

			dfs(i-1,j,btn);
			dfs(i+1,j,btn);
			dfs(i,j+1,btn);
			dfs(i,j-1,btn);
}
int main()
{
	ioS;
	cin>>r>>c;

	for(int i=0;i<r;i++)
	{
		string o;
		cin>>o;
		for(int j=0;j<c;j++)
		{
			arr[i][j]=o[j];
		}
	}
	int btn=0;
	for(int i=0;i<r;i++)
	{
		for(int j=0;j<c;j++)
		{
			if(arr[i][j]=='.')
			{
				if(vis[i][j]==0)
				{
					dfs(i,j,btn);
					btn++;
				}
			}
		}
	}

	/*for(int i=0;i<r;i++)
	{
		for(int j=0;j<c;j++)
		{
			if(arr[i][j]=='.')
			cout<<com[i][j];
			else
			cout<<'*';
		}
		cout<<endl;
	}

	for(int i=0;i<btn;i++)
	cout<<sizc[i]<<endl;*/

	for(int i=0;i<r;i++)
	{
		string ch;

		for(int j=0;j<c;j++)
		{
			map<int,int> mp;

			if(arr[i][j]=='*')
			{
				int ans=0;
				if(i+1<r&&j<c&&j>=0&&arr[i+1][j]=='.')
				{
					mp[com[i+1][j]];
				}
				if(i-1>=0&&j<c&&j>=0&&arr[i-1][j]=='.')
				{
					mp[com[i-1][j]];
				}
				if(i<r&&j-1>=0&&i>=0&&arr[i][j-1]=='.')
				{
					mp[com[i][j-1]];
				}
				if(i<r&&j+1<c&&i>=0&&arr[i][j+1]=='.')
				{
					mp[com[i][j+1]];
				}

				for(map<int,int > ::iterator it=mp.begin();it!=mp.end();it++)
				{
					ans+=sizc[it->first];
				}
				ans++;
				ch+=char((ans%10)+'0');
			}
			else
			ch+='.';
		}
		cout<<ch<<endl;

	}
	return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#include<stdio.h>
#define ioS ios::sync_with_stdio(false);
#include<iostream>
using namespace std;

ll int power(ll int a,ll int b)
{
	if(b==0)
	return 1;
	else
	return a*power(a,b-1);
}
bool sortbya( int l, int r)
{
	return(r<l);
}
int ct=0;
char arr[1001][1001];
bool vis[1001][1001];
int r,c;
void dfs(int i,int j)
{
	vis[i][j]=1;

	if(i+1<r&&j<c&&j>=0&&vis[i+1][j]==0)
	{
		if(arr[i+1][j]=='.')
		{
			ct++;
			dfs(i+1,j);
		}
	}
	if(i-1>=0&&j<c&&j>=0&&vis[i-1][j]==0)
	{
		if(arr[i-1][j]=='.')
		{
			ct++;
			dfs(i-1,j);
		}
	}
	if(i<r&&j+1<c&&i>=0&&vis[i][j+1]==0)
	{
		if(arr[i][j+1]=='.')
		{
			ct++;
			dfs(i,j+1);
		}
	}
	if(i<r&&j-1>=0&&i>=0&&vis[i][j-1]==0)
	{
		if(arr[i][j-1]=='.')
		{
			ct++;
			dfs(i,j-1);
		}
	}

}
int main()
{
	scanf("%d %d",&r,&c);

	for(int i=0;i<r;i++)
	{
		char o[c];
		scanf("%s",&o);
		for(int j=0;j<c;j++)
		{
			arr[i][j]=o[j];
		}
	}

	for(int i=0;i<r;i++)
	{
		string o;

		for(int j=0;j<c;j++)
		{
			if(arr[i][j]=='*')
			{
				dfs(i,j);
				int y=(ct+1)%10;
				//cout<<(char)(y+'0')<<endl;
			o+=(char)(y+'0');
				memset(vis, 0, sizeof(vis[0][0]) * 1001 * 1001);
				ct=0;
			}
			else
			o+=arr[i][j];
		}
		cout<<o;
		printf("\n");
	}

	return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#include<stdio.h>
#define ioS ios::sync_with_stdio(false);
#include<iostream>
using namespace std;

ll int power(ll int a,ll int b)
{
	if(b==0)
	return 1;
	else
	return a*power(a,b-1);
}
bool sortbya( int l, int r)
{
	return(r<l);
}
int ct=0;
char arr[1001][1001];
bool vis[1001][1001][1001][1001];
int r,c;
void dfs(int i,int j,int x,int y)
{
	vis[x][y][i][j]=1;

	if(i+1<r&&j<c&&j>=0&&vis[x][y][i+1][j]==0)
	{
		if(arr[i+1][j]=='.')
		{
			ct++;
			dfs(i+1,j,x,y);
		}
	}
	if(i-1>=0&&j<c&&j>=0&&vis[x][y][i-1][j]==0)
	{
		if(arr[i-1][j]=='.')
		{
			ct++;
			dfs(i-1,j,x,y);
		}
	}
	if(i<r&&j+1<c&&i>=0&&vis[x][y][i][j+1]==0)
	{
		if(arr[i][j+1]=='.')
		{
			ct++;
			dfs(i,j+1,x,y);
		}
	}
	if(i<r&&j-1>=0&&i>=0&&vis[x][y][i][j-1]==0)
	{
		if(arr[i][j-1]=='.')
		{
			ct++;
			dfs(i,j-1,x,y);
		}
	}

}
int main()
{
	scanf("%d %d",&r,&c);

	for(int i=0;i<r;i++)
	{
		char o[c];
		scanf("%s",&o);
		for(int j=0;j<c;j++)
		{
			arr[i][j]=o[j];
		}
	}

	for(int i=0;i<r;i++)
	{
		for(int j=0;j<c;j++)
		{
			if(arr[i][j]=='*')
			{
				dfs(i,j,i,j);
				printf("%d",((ct+1)%10));
				ct=0;
			}
			else
			printf("%c",arr[i][j]);
		}
		cout<<endl;
	}

	return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#include<stdio.h>
#define ioS ios::sync_with_stdio(false);
#include<iostream>
using namespace std;

ll int power(ll int a,ll int b)
{
	if(b==0)
	return 1;
	else
	return a*power(a,b-1);
}
bool sortbya( int l, int r)
{
	return(r<l);
}
int ct=1;
int btn=1;
char arr[1001][1001];
int vis[1001][1001];
int sizc[1001];
int r,c;
void dfs(int i,int j)
{
	vis[i][j]=btn;

	if(i+1<r&&j<c&&j>=0&&vis[i+1][j]==0)
	{
		if(arr[i+1][j]=='.')
		{
			ct++;
			dfs(i+1,j);
		}
	}
	if(i-1>=0&&j<c&&j>=0&&vis[i-1][j]==0)
	{
		if(arr[i-1][j]=='.')
		{
			ct++;
			dfs(i-1,j);
		}
	}
	if(i<r&&j+1<c&&i>=0&&vis[i][j+1]==0)
	{
		if(arr[i][j+1]=='.')
		{
			ct++;
			dfs(i,j+1);
		}
	}
	if(i<r&&j-1>=0&&i>=0&&vis[i][j-1]==0)
	{
		if(arr[i][j-1]=='.')
		{
			ct++;
			dfs(i,j-1);
		}
	}

}
int main()
{
	ioS;
	cin>>r>>c;

	for(int i=0;i<r;i++)
	{
		string o;
		cin>>o;
		for(int j=0;j<c;j++)
		{
			arr[i][j]=o[j];
		}
	}

	for(int i=0;i<r;i++)
	{
		for(int j=0;j<c;j++)
		{
			if(arr[i][j]=='.')
			{
				if(vis[i][j]==0)
				{
					dfs(i,j);
					sizc[btn]=ct;

					btn++;
					ct=1;
				}
			}
		}
	}

	/*for(int i=0;i<r;i++)
	{
		for(int j=0;j<c;j++)
		{
			if(arr[i][j]=='.')
			cout<<vis[i][j];
			else
			cout<<'*';
		}
		cout<<endl;
	}

	for(int i=1;i<btn;i++)
	cout<<sizc[i]<<endl;*/

	for(int i=0;i<r;i++)
	{
		string ch;

		for(int j=0;j<c;j++)
		{
			set<int> se;
			se.clear();
			int ans=1;
			if(arr[i][j]=='*')
			{
				if(arr[i+1][j]=='.'&&i+1<r&&j<c&&j>=0)
				{
					if(!(se.find(vis[i+1][j])!=se.end()))
					{
					ans+=sizc[vis[i+1][j]];
					se.insert(vis[i+1][j]);
				}
				}
				if(arr[i-1][j]=='.'&&i-1>=0&&j<c&&j>=0)
				{
					if(!(se.find(vis[i-1][j])!=se.end()))
					{
					ans+=sizc[vis[i-1][j]];
					se.insert(vis[i-1][j]);
				}
				}
				if(arr[i][j-1]=='.'&&i<r&&j-1>=0&&i>=0)
				{
					if(!(se.find(vis[i][j-1])!=se.end()))
					{
					ans+=sizc[vis[i][j-1]];
					se.insert(vis[i][j-1]);
				}
				}
				if(arr[i][j+1]=='.'&&i<r&&j+1<c&&i>=0)
				{
					if(!(se.find(vis[i][j+1])!=se.end()))
					{
					ans+=sizc[vis[i][j+1]];
					se.insert(vis[i][j+1]);
				}
				}
				ch+=char((ans%10)+'0');
			}
			else
			ch+='.';
		}
		cout<<ch<<endl;

	}
	return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#include<stdio.h>
#define ioS ios::sync_with_stdio(false);
#include<iostream>
using namespace std;

ll int power(ll int a,ll int b)
{
	if(b==0)
	return 1;
	else
	return a*power(a,b-1);
}
bool sortbya( int l, int r)
{
	return(r<l);
}
int ct=0;
char arr[1001][1001];
bool vis[1001][1001];
int r,c;
void dfs(int i,int j)
{
	vis[i][j]=1;

	if(i+1<r&&j<c&&j>=0&&vis[i+1][j]==0)
	{
		if(arr[i+1][j]=='.')
		{
			ct++;
			dfs(i+1,j);
		}
	}
	if(i-1>=0&&j<c&&j>=0&&vis[i-1][j]==0)
	{
		if(arr[i-1][j]=='.')
		{
			ct++;
			dfs(i-1,j);
		}
	}
	if(i<r&&j+1<c&&i>=0&&vis[i][j+1]==0)
	{
		if(arr[i][j+1]=='.')
		{
			ct++;
			dfs(i,j+1);
		}
	}
	if(i<r&&j-1>=0&&i>=0&&vis[i][j-1]==0)
	{
		if(arr[i][j-1]=='.')
		{
			ct++;
			dfs(i,j-1);
		}
	}

}
int main()
{
	scanf("%d %d",&r,&c);

	for(int i=0;i<r;i++)
	{
		char o[c];
		scanf("%s",&o);
		for(int j=0;j<c;j++)
		{
			arr[i][j]=o[j];
		}
	}

	for(int i=0;i<r;i++)
	{
		for(int j=0;j<c;j++)
		{
			if(arr[i][j]=='*')
			{
				dfs(i,j);
				printf("%d",((ct+1)%10));
				for(int k=0;k<1000;k++)
				{
					for(int m=0;m<1000;m++)
					vis[k][m]=0;
				}
				ct=0;
			}
			else
			printf("%c",arr[i][j]);
		}
		cout<<endl;
	}

	return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#include<stdio.h>
#define ioS ios::sync_with_stdio(false);
#include<iostream>
using namespace std;

ll int power(ll int a,ll int b)
{
	if(b==0)
	return 1;
	else
	return a*power(a,b-1);
}
bool sortbya( int l, int r)
{
	return(r<l);
}
int ct=1;

char arr[1010][1010];
int vis[1010][1010];
int sizc[1010];
int r,c;
void dfs(int i,int j,int btn)
{
	vis[i][j]=btn;

	if(i+1<r&&j<c&&j>=0&&vis[i+1][j]==0)
	{
		if(arr[i+1][j]=='.')
		{
			ct++;
			dfs(i+1,j,btn);
		}
	}
	if(i-1>=0&&j<c&&j>=0&&vis[i-1][j]==0)
	{
		if(arr[i-1][j]=='.')
		{
			ct++;
			dfs(i-1,j,btn);
		}
	}
	if(i<r&&j+1<c&&i>=0&&vis[i][j+1]==0)
	{
		if(arr[i][j+1]=='.')
		{
			ct++;
			dfs(i,j+1,btn);
		}
	}
	if(i<r&&j-1>=0&&i>=0&&vis[i][j-1]==0)
	{
		if(arr[i][j-1]=='.')
		{
			ct++;
			dfs(i,j-1,btn);
		}
	}

}
int main()
{
	ioS;
	cin>>r>>c;

	for(int i=0;i<r;i++)
	{
		string o;
		cin>>o;
		for(int j=0;j<c;j++)
		{
			arr[i][j]=o[j];
		}
	}
	int btn=1;
	for(int i=0;i<r;i++)
	{
		for(int j=0;j<c;j++)
		{
			if(arr[i][j]=='.')
			{
				if(vis[i][j]==0)
				{
					dfs(i,j,btn);
					sizc[btn]=ct;
					btn++;
					ct=1;
				}
			}
		}
	}

	/*for(int i=0;i<r;i++)
	{
		for(int j=0;j<c;j++)
		{
			if(arr[i][j]=='.')
			cout<<vis[i][j];
			else
			cout<<'*';
		}
		cout<<endl;
	}

	for(int i=1;i<btn;i++)
	cout<<sizc[i]<<endl;*/

	for(int i=0;i<r;i++)
	{
		string ch;

		for(int j=0;j<c;j++)
		{
			set<int> se;
			se.clear();

			if(arr[i][j]=='*')
			{
				int ans=1;
				if(arr[i+1][j]=='.')
				{
					se.insert(vis[i+1][j]);
				}
				if(arr[i-1][j]=='.')
				{
					se.insert(vis[i-1][j]);
				}
				if(arr[i][j-1]=='.')
				{
					se.insert(vis[i][j-1]);
				}
				if(arr[i][j+1]=='.')
				{
					se.insert(vis[i][j+1]);
				}

				for(set<int> ::iterator it=se.begin();it!=se.end();it++)
				{
					ans+=sizc[*it];
				}
				cout<<char((ans%10)+'0');
			}
			else
			cout<<'.';
		}
		cout<<endl;

	}
	return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#include<stdio.h>
#define ioS ios::sync_with_stdio(false);
#include<iostream>
using namespace std;

ll int power(ll int a,ll int b)
{
	if(b==0)
	return 1;
	else
	return a*power(a,b-1);
}
bool sortbya( int l, int r)
{
	return(r<l);
}
int ct=0;
char arr[1001][1001];
bool vis[1001][1001];
int r,c;
void dfs(int i,int j)
{
	vis[i][j]=1;

	if(i+1<r&&j<c&&j>=0&&vis[i+1][j]==0)
	{
		if(arr[i+1][j]=='.')
		{
			ct++;
			dfs(i+1,j);
		}
	}
	if(i-1>=0&&j<c&&j>=0&&vis[i-1][j]==0)
	{
		if(arr[i-1][j]=='.')
		{
			ct++;
			dfs(i-1,j);
		}
	}
	if(i<r&&j+1<c&&i>=0&&vis[i][j+1]==0)
	{
		if(arr[i][j+1]=='.')
		{
			ct++;
			dfs(i,j+1);
		}
	}
	if(i<r&&j-1>=0&&i>=0&&vis[i][j-1]==0)
	{
		if(arr[i][j-1]=='.')
		{
			ct++;
			dfs(i,j-1);
		}
	}

}
int main()
{
	scanf("%d %d",&r,&c);

	for(int i=0;i<r;i++)
	{
		char o[c];
		scanf("%s",&o);
		for(int j=0;j<c;j++)
		{
			arr[i][j]=o[j];
		}
	}

	for(int i=0;i<r;i++)
	{
		for(int j=0;j<c;j++)
		{
			if(arr[i][j]=='*')
			{
				dfs(i,j);
				printf("%d",((ct+1)%10));
				memset(vis, 0, sizeof(vis[0][0]) * 1001 * 1001);
				ct=0;
			}
			else
			printf("%c",arr[i][j]);
		}
		cout<<endl;
	}

	return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#include<stdio.h>
#define ioS ios::sync_with_stdio(false);
#include<iostream>
using namespace std;

ll int power(ll int a,ll int b)
{
	if(b==0)
	return 1;
	else
	return a*power(a,b-1);
}
bool sortbya( int l, int r)
{
	return(r<l);
}
int ct=0;
char arr[1001][1001];
bool vis[1001][1001];
int r,c;
void dfs(int i,int j)
{
	vis[i][j]=1;

	if(i+1<r&&j<c&&j>=0&&vis[i+1][j]==0)
	{
		if(arr[i+1][j]=='.')
		{
			ct++;
			dfs(i+1,j);
		}
	}
	if(i-1>=0&&j<c&&j>=0&&vis[i-1][j]==0)
	{
		if(arr[i-1][j]=='.')
		{
			ct++;
			dfs(i-1,j);
		}
	}
	if(i<r&&j+1<c&&i>=0&&vis[i][j+1]==0)
	{
		if(arr[i][j+1]=='.')
		{
			ct++;
			dfs(i,j+1);
		}
	}
	if(i<r&&j-1>=0&&i>=0&&vis[i][j-1]==0)
	{
		if(arr[i][j-1]=='.')
		{
			ct++;
			dfs(i,j-1);
		}
	}

}
int main()
{
	scanf("%d %d",&r,&c);

	for(int i=0;i<r;i++)
	{
		char o[c];
		scanf("%s",&o);
		for(int j=0;j<c;j++)
		{
			arr[i][j]=o[j];
		}
	}

	for(int i=0;i<r;i++)
	{
		for(int j=0;j<c;j++)
		{
			if(arr[i][j]=='*')
			{
				dfs(i,j);
				printf("%d",((ct+1)%10));
				memset(vis, 0, sizeof(vis[0][0]) * 1001 * 1001);
				ct=0;
			}
			else
			printf("%c",arr[i][j]);
		}
		printf("\n");
	}

	return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#include<stdio.h>
#define ioS ios::sync_with_stdio(false);
#include<iostream>
using namespace std;

ll int power(ll int a,ll int b)
{
	if(b==0)
	return 1;
	else
	return a*power(a,b-1);
}
bool sortbya( int l, int r)
{
	return(r<l);
}
int ct=1;
int btn=1;
char arr[1001][1001];
int vis[1001][1001];
int sizc[1001];
int r,c;
void dfs(int i,int j)
{
	vis[i][j]=btn;

	if(i+1<r&&j<c&&j>=0&&vis[i+1][j]==0)
	{
		if(arr[i+1][j]=='.')
		{
			ct++;
			dfs(i+1,j);
		}
	}
	if(i-1>=0&&j<c&&j>=0&&vis[i-1][j]==0)
	{
		if(arr[i-1][j]=='.')
		{
			ct++;
			dfs(i-1,j);
		}
	}
	if(i<r&&j+1<c&&i>=0&&vis[i][j+1]==0)
	{
		if(arr[i][j+1]=='.')
		{
			ct++;
			dfs(i,j+1);
		}
	}
	if(i<r&&j-1>=0&&i>=0&&vis[i][j-1]==0)
	{
		if(arr[i][j-1]=='.')
		{
			ct++;
			dfs(i,j-1);
		}
	}

}
int main()
{
	ioS;
	cin>>r>>c;

	for(int i=0;i<r;i++)
	{
		string o;
		cin>>o;
		for(int j=0;j<c;j++)
		{
			arr[i][j]=o[j];
		}
	}

	for(int i=0;i<r;i++)
	{
		for(int j=0;j<c;j++)
		{
			if(arr[i][j]=='.')
			{
				if(vis[i][j]==0)
				{
					dfs(i,j);
					sizc[btn]=ct;

					btn++;
					ct=1;
				}
			}
		}
	}

	/*for(int i=0;i<r;i++)
	{
		for(int j=0;j<c;j++)
		{
			if(arr[i][j]=='.')
			cout<<vis[i][j];
			else
			cout<<'*';
		}
		cout<<endl;
	}

	for(int i=1;i<btn;i++)
	cout<<sizc[i]<<endl;*/

	for(int i=0;i<r;i++)
	{
		string ch;

		for(int j=0;j<c;j++)
		{
			set<int> se;
			int ans=1;
			if(arr[i][j]=='*')
			{
				if(vis[i+1][j]!=0&&i+1<r&&j<c&&j>=0)
				{
					if(!(se.find(vis[i+1][j])!=se.end()))
					{
					ans+=sizc[vis[i+1][j]];
					se.insert(vis[i+1][j]);
				}
				}
				if(vis[i-1][j]!=0&&i-1>=0&&j<c&&j>=0)
				{
					if(!(se.find(vis[i-1][j])!=se.end()))
					{
					ans+=sizc[vis[i-1][j]];
					se.insert(vis[i-1][j]);
				}
				}
				if(vis[i][j-1]!=0&&i<r&&j-1>=0&&i>=0)
				{
					if(!(se.find(vis[i][j-1])!=se.end()))
					{
					ans+=sizc[vis[i][j-1]];
					se.insert(vis[i][j-1]);
				}
				}
				if(vis[i][j+1]!=0&&i<r&&j+1<c&&i>=0)
				{
					if(!(se.find(vis[i][j+1])!=se.end()))
					{
					ans+=sizc[vis[i][j+1]];
					se.insert(vis[i][j+1]);
				}
				}
				ch+=char((ans%10)+'0');
			}
			else
			ch+='.';
		}
		cout<<ch<<endl;

	}
	return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#include<stdio.h>
#define ioS ios::sync_with_stdio(false);
#include<iostream>
using namespace std;

ll int power(ll int a,ll int b)
{
	if(b==0)
	return 1;
	else
	return a*power(a,b-1);
}
bool sortbya( int l, int r)
{
	return(r<l);
}
int ct=1;
int btn=1;
char arr[1001][1001];
int vis[1001][1001];
int sizc[1001];
int r,c;
void dfs(int i,int j)
{
	vis[i][j]=btn;

	if(i+1<r&&j<c&&j>=0&&vis[i+1][j]==0)
	{
		if(arr[i+1][j]=='.')
		{
			ct++;
			dfs(i+1,j);
		}
	}
	if(i-1>=0&&j<c&&j>=0&&vis[i-1][j]==0)
	{
		if(arr[i-1][j]=='.')
		{
			ct++;
			dfs(i-1,j);
		}
	}
	if(i<r&&j+1<c&&i>=0&&vis[i][j+1]==0)
	{
		if(arr[i][j+1]=='.')
		{
			ct++;
			dfs(i,j+1);
		}
	}
	if(i<r&&j-1>=0&&i>=0&&vis[i][j-1]==0)
	{
		if(arr[i][j-1]=='.')
		{
			ct++;
			dfs(i,j-1);
		}
	}

}
int main()
{
	ioS;
	cin>>r>>c;

	for(int i=0;i<r;i++)
	{
		string o;
		cin>>o;
		for(int j=0;j<c;j++)
		{
			arr[i][j]=o[j];
		}
	}

	for(int i=0;i<r;i++)
	{
		for(int j=0;j<c;j++)
		{
			if(arr[i][j]=='.')
			{
				if(vis[i][j]==0)
				{
					dfs(i,j);
					sizc[btn]=ct;

					btn++;
					ct=1;
				}
			}
		}
	}

	/*for(int i=0;i<r;i++)
	{
		for(int j=0;j<c;j++)
		{
			if(arr[i][j]=='.')
			cout<<vis[i][j];
			else
			cout<<'*';
		}
		cout<<endl;
	}

	for(int i=1;i<btn;i++)
	cout<<sizc[i]<<endl;*/

	for(int i=0;i<r;i++)
	{
		string ch;

		for(int j=0;j<c;j++)
		{
			set<int> se;
			int ans=1;
			if(arr[i][j]=='*')
			{
				if(arr[i+1][j]=='.'&&i+1<r&&j<c&&j>=0)
				{
					if(!(se.find(vis[i+1][j])!=se.end()))
					{
					ans+=sizc[vis[i+1][j]];
					se.insert(vis[i+1][j]);
				}
				}
				if(arr[i-1][j]=='.'&&i-1>=0&&j<c&&j>=0)
				{
					if(!(se.find(vis[i-1][j])!=se.end()))
					{
					ans+=sizc[vis[i-1][j]];
					se.insert(vis[i-1][j]);
				}
				}
				if(arr[i][j-1]=='.'&&i<r&&j-1>=0&&i>=0)
				{
					if(!(se.find(vis[i][j-1])!=se.end()))
					{
					ans+=sizc[vis[i][j-1]];
					se.insert(vis[i][j-1]);
				}
				}
				if(arr[i][j+1]=='.'&&i<r&&j+1<c&&i>=0)
				{
					if(!(se.find(vis[i][j+1])!=se.end()))
					{
					ans+=sizc[vis[i][j+1]];
					se.insert(vis[i][j+1]);
				}
				}
				ch+=char((ans%10)+'0');
			}
			else
			ch+='.';
		}
		cout<<ch<<endl;

	}
	return 0;
}


#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define FORD(i, a, b) for (int i = (a); i >= (b); --i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define maxc 1000000007
#define maxn 1000006
#define maxm 500005
#define pii pair <int,int>
#define Task ""
using namespace std;
int n,m,k,z2[maxn],z1[maxn],ma,st[maxn],rmq[maxn][21];
string a,b;
void Z_function(int z[])
{
    string s = "";
    s = b + '*' + a;
    //cout << s << '\n';
    int sz = n + m + 1;
    for (int i = 1,l = 0,r = 0; i < sz;i++)
     {
        char c = s[i];
        if ( i <= r)
            z[i] = min(r-i+1,z[i-l]);
        while(i + z[i] < sz && s[z[i]] == s[i+z[i]]) z[i]++;
        if ( i + z[i] - 1 > r)
                l = i, r = i+z[i]-1;
     }
}
int Get(int l,int r)
{
    if (l > r) return -maxc;
    int lo = log2(r - l + 1);
    return max(rmq[r][lo],rmq[l + (1 << lo) - 1][lo]);
}
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen(".inp", "r",stdin);
    cin >> n >> m >> k >> a >> b;
    Z_function(z1);
    reverse(a.begin(),a.end());
    reverse(b.begin(),b.end());
    Z_function(z2);
    FOR(i,1,n) z1[i] = z1[i+m];
    FOR(i,1,n) z2[i] = z2[i+m];
    reverse(z2+1,z2+n+1);
    FOR(i,1,n)
    {
        rmq[i][0] = z2[i];
        FOR(j,1,20)
            {
                int pos = i - (1 << j);
                if (pos < 0) continue;
                pos = i - (1 << (j - 1));
                rmq[i][j] = max(rmq[i][j-1],rmq[pos][j-1]);
            }
    }
    int cur = 1;
    FOR(i,1,n - 2 * k + 1)
    {
        int r = i + k - 1;
        cur = max(cur,i);
        while (cur <= r && cur + z1[cur] <= r) ++cur;
        int need;
        if (cur > r) need = m;
        else need = m - r + cur - 1;
        if (need > k) continue;
        int temp = Get(r + need,n);
        if (temp >= need)
        {
            int ans = 0;
            FOR(j,r + need,n)
                if (z2[j] >= need && j + k - need <= n)
                {
                    ans = j - need + 1;
                    break;
                }
            if (ans)
            {
                cout << "Yes\n" << i << ' ' << ans;
                return 0;
            }
        }
    }
    cout << "No";
    return 0;
}


#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define FORD(i, a, b) for (int i = (a); i >= (b); --i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define maxc 1000000007
#define maxn 1000006
#define maxm 500005
#define pii pair <int,int>
#define Task ""
using namespace std;
int n,m,k,z2[maxn],z1[maxn],ma,st[maxn],rmq[maxn][21];
string a,b;
void Z_function(int z[])
{
    string s = "";
    s = b + '*' + a;
    //cout << s << '\n';
    int sz = n + m + 1;
    for (int i = 1,l = 0,r = 0; i < sz;i++)
     {
        char c = s[i];
        if ( i <= r)
            z[i] = min(r-i+1,z[i-l]);
        while(i + z[i] < sz && s[z[i]] == s[i+z[i]]) z[i]++;
        if ( i + z[i] - 1 > r)
                l = i, r = i+z[i]-1;
     }
}
int Get(int l,int r)
{
    if (l > r) return -maxc;
    int lo = log2(r - l + 1);
    return max(rmq[r][lo],rmq[l + (1 << lo) - 1][lo]);
}
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen(".inp", "r",stdin);
    cin >> n >> m >> k >> a >> b;
    Z_function(z1);
    reverse(a.begin(),a.end());
    reverse(b.begin(),b.end());
    Z_function(z2);
    FOR(i,1,n) z1[i] = z1[i+m];
    FOR(i,1,n) z2[i] = z2[i+m];
    reverse(z2+1,z2+n+1);
    FOR(i,1,n)
    {
        rmq[i][0] = z2[i];
        FOR(j,1,20)
            {
                int pos = i - (1 << j);
                if (pos < 0) continue;
                pos = i - (1 << (j - 1));
                rmq[i][j] = max(rmq[i][j-1],rmq[pos][j-1]);
            }
    }
    FOR(i,1,n)
    {
        if (z1[i] >= m)
        {
            int l = i, r = i + z1[i] - 1;
            if (r >= 2*k)
            {
                cout << "Yes\n" << r - 2 * k + 1 << ' ' << r - k + 1;
                return 0;
            }
            else
            {
                cout << "Yes\n" << 1 << ' ' << k + 1;
                return 0;
            }
        }
    }
    int cur = 1;
    FOR(i,1,n - 2 * k + 1)
    {
        int r = i + k - 1;
        cur = max(cur,i);
        while (cur <= r && cur + z1[cur] <= r) ++cur;
        int need;
        if (cur > r) need = m;
        else need = m - r + cur - 1;
        if (need > k) continue;
        int temp = Get(r + need,n);
        if (temp >= need)
        {
            int ans = 0;
            FOR(j,r + need,n)
                if (z2[j] >= need && j + k - need <= n)
                {
                    ans = j - need + 1;
                    break;
                }
            if (ans)
            {
                cout << "Yes\n" << i << ' ' << ans;
                return 0;
            }
        }
    }
    cout << "No";
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define eps 1e-7
#define PI acos(-1)
#define de(x) cout<<#x<<'='<<x<<" , "
#define dee(x) cout<<#x<<'='<<x<<endl
#define sz(x) (int)x.size()
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=a;i>(b);--i)
#define mset(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define random(a,b) ((a)+rand()%((b)-(a)+1))
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
typedef long long LL;
typedef pair<LL,LL> pii;
const int maxn=500055;
char s[maxn],t[maxn];
const LL seed=131,mod=1000000007;
LL  bas[maxn], hs[maxn],ht[maxn];
int n,k,m;
LL f[maxn],g[maxn];
void Hash(char *s,int st,int ed,LL val[]){
    bas[0]=1;
    for(int i=st;i<=ed;++i){
        val[i]=(val[i-1]*seed+s[i])%mod;
        bas[i]=bas[i-1]*seed%mod;
        //de(i),dee(bas[i]);
    }
}
LL getHash(int st,int ed,LL hash_val[]){
    LL res=(hash_val[ed]-(hash_val[st-1]*bas[ed-st+1]%mod)+mod)%mod;
    return res;
}
bool Check(int sl,int sr,int tl,int tr){
    return getHash(sl,sr,hs)==getHash(tl,tr,ht);
}
void solve(LL pos[]){
    int l=1,spl=1, last=min(m,k);
    LL pre=0;
    //rep(len,1,last+1){
    //    if(Check(k-len+1,k,1,len)) pos[len]=k;
    //}
    while(spl<=last){
        pre=(pre*seed+t[spl])%mod;
        while(l+k-1<=n&&!Check(l+k-spl,l+k-1,1,spl)) l++;
        if(l+k-1<=n&&(pos[spl]==0||pos[spl]>l)) pos[spl]=l+k-1;
        spl++;
    }
}
void Solve1(int l,int r) {
    int pos=k;
    for(int i=l;i<=r;i++) {
        while(pos<i) ++pos;
        while(pos<=n) {
            if(Check(pos-i+1,pos,1,i)) break;
            ++pos;
        }
        if(!f[i])
            f[i]=pos<=n?pos:0;
    }
}
void Solve2(int l,int r) {
    int pos=n-k+1;
    for(int i=r;i>=l;i--) {
        while(pos+m-i>n) --pos;
        while(pos) {
            if(Check(pos,pos+m-i,i,m)) break;
            --pos;
        }
        g[i]=pos;
    }
}
bool Solve() {
    int pos=1;
    for(int i=1;i<=m;i++) {
        while(pos<i) ++pos;
        while(pos<=n) {
            if(Check(pos-i+1,pos,1,i)) break;
            ++pos;
        }
    }
    if(max(pos,k)+k<=n) {
        printf("Yes\n%d %d\n",max(1,pos-k+1),max(pos,k)+1);
        return 1;
    }
    pos=n;
    for(int i=m;i;i--) {
        while(pos+m-i>n) --pos;
        while(pos) {
            if(Check(pos,pos+m-i,i,m)) break;
            --pos;
        }
    }
    if(n-max(n-pos+1,k)-k>0) {
        printf("Yes\n%d %d\n",n-max(n-pos+1,k)-k,n-max(n-pos+1,k)+1);
        return 1;
    }
    return 0;
}
LL prepos[maxn], bakpos[maxn];
int main(){
    //freopen("in.in","r",stdin);
    scanf("%d %d %d",&n,&m,&k);
    scanf("%s %s",s+1,t+1);
    Hash(s,1,n,hs);  Hash(t,1,m,ht);
    if(m<=k&&Solve()) return 0;
    int lst=1,fst=1;
    /*
    for(int i=1;i<=m&&i<=k;i++)
        if(Check(k-i+1,k,1,i)) {
            lst=i;
            f[i]=k;
        }
    Solve1(lst+1,min(m,k));
    */
    for(int i=1;i<=m&&i<=k;i++)
        if(Check(k-i+1,k,1,i)) {
            lst=i;
            f[i]=k;
        }
    Solve1(1,m);
    lst=fst=m;
    for(int i=m;i&&i>=m-k+1;i--)
        if(Check(n-k+1,n-k+1+m-i,i,m)) {
            lst=i;
            g[i]=n-k+1;
        }
    Solve2(max(1,m-k+1),lst-1);
    int x=0,y=0;
    for(int i=1;i<m;i++)
        if(f[i]&&g[i+1]&&f[i]<g[i+1]) {
            x=f[i]-k+1;y=g[i+1];
            break;
        }
    if(x) printf("Yes\n%d %d\n",x,y);else puts("No");
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define eps 1e-7
#define PI acos(-1)
#define de(x) cout<<#x<<'='<<x<<" , "
#define dee(x) cout<<#x<<'='<<x<<endl
#define sz(x) (int)x.size()
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=a;i>(b);--i)
#define mset(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define random(a,b) ((a)+rand()%((b)-(a)+1))
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
typedef long long LL;
typedef pair<LL,LL> pii;
const int maxn=500055;
char s[maxn],t[maxn];
const LL mod[2]={1000000007,1000000007}, seed[2]={37,131};
LL  bas[2][maxn], hash_val[2][maxn];
int n,k,m;
pii Hash(char *s,int st,int ed,bool f){
    LL h[2]={0,0}; bas[1][0]=bas[0][0]=1;
    for(int i=st;i<=ed;++i){
        rep(st,0,2) h[st]=(h[st]*seed[st]+s[i])%mod[st];
        if(f) rep(st,0,2) hash_val[st][i]=h[st];
        if(f) rep(st,0,2) bas[st][i]=bas[st][i-1]*seed[st]%mod[st];
    }
    return mp(h[0],h[1]);
}
pii getHash(int st,int ed){
    LL res[2]={0,0};
    rep(f,0,2)
        res[f]=(hash_val[f][ed]-hash_val[f][st-1]*bas[f][ed-st+1]%mod[f]+mod[f])%mod[f];
    return mp(res[0],res[1]);
}

void solve(LL pos[]){
    int l=1,spl=1, last=min(m,k);
    LL pre[2]={0};

    rep(len,1,last+1){
        rep(i,0,2) pre[i]=(pre[i]*seed[i]+t[len])%mod[i];
        pii preh=mp(pre[0],pre[1]);
        if(getHash(k-len+1,k)==preh) pos[len]=1;
    }
    mset(pre,0);

    while(spl<=last){
        rep(i,0,2) pre[i]=(pre[i]*seed[i]+t[spl])%mod[i];
        pii preh=mp(pre[0],pre[1]);
        while(l+k-1<=n&&getHash(l+k-spl,l+k-1)!=preh) l++;
        if(l+k-1<=n&&(pos[spl]==0||pos[spl]>l)) pos[spl]=l;
        spl++;
    }
}
LL prepos[maxn], bakpos[maxn];
int main(){
    //freopen("in.in","r",stdin);
    scanf("%d %d %d",&n,&m,&k);
    scanf("%s %s",s+1,t+1);
    Hash(s,1,n,1);  solve(prepos);
    reverse(s+1,s+1+n); reverse(t+1,t+1+m);
    Hash(s,1,n,1);  solve(bakpos);
    rep(i,1,m+1) if(bakpos[i]) bakpos[i]=n+1-(bakpos[i]+k-1);
    rep(i,0,m+1){
        int l1=i, l2=m-i, p1=prepos[l1], p2=bakpos[l2];
        if(p2-p1>=k&&p1!=0&&p2!=0) { printf("Yes\n%d %d\n",p1,p2); return 0; }
    }
    if(prepos[m]||bakpos[m]) {
        int p=prepos[m]?prepos[m]:bakpos[m];
        int p2=p-k;
        while(p2<1) p++,p2++;
        printf("Yes\n%d %d\n",p2,p);
        return 0;
    }

    return puts("No")*0;
}


#include<bits/stdc++.h>
using namespace std;
const int N=500010;
const int H=37;
const int P=1000000007;
int k,n,m;
int pos;
int f[N],g[N];
int hs[N],ht[N],p[N];
int x,y;
char s[N],t[N];
bool Check(int l,int r,int L,int R) {
    int t=(hs[r]-1ll*hs[l-1]*p[r-l+1])%P;
    t=(t+P)%P;
    int T=(ht[R]-1ll*ht[L-1]*p[R-L+1])%P;
    T=(T+P)%P;
    return t==T;
}
bool Solve() {
    pos=1;
    for(int i=1;i<=m;i++) {
        while(pos<i) ++pos;
        while(pos<=n) {
            if(Check(pos-i+1,pos,1,i)) break;
            ++pos;
        }
    }
    if(max(pos,k)+k<=n) {
        printf("Yes\n%d %d\n",max(1,pos-k+1),max(pos,k)+1);
        return 1;
    }
    pos=n;
    for(int i=m;i;i--) {
        while(pos+m-i>n) --pos;
        while(pos) {
            if(Check(pos,pos+m-i,i,m)) break;
            --pos;
        }
    }
    if(n-max(n-pos+1,k)-k>0) {
        printf("Yes\n%d %d\n",n-max(n-pos+1,k)-k,n-max(n-pos+1,k)+1);
        return 1;
    }
    return 0;
}
void Solve1(int l,int r) {
    int pos=k;
    for(int i=l;i<=r;i++) {
        while(pos<i) ++pos;
        while(pos<=n) {
            if(Check(pos-i+1,pos,1,i)) break;
            ++pos;
        }
        f[i]=pos<=n?pos:0;
    }
}
void Solve2(int l,int r) {
    int pos=n-k+1;
    for(int i=r;i>=l;i--) {
        while(pos+m-i>n) --pos;
        while(pos) {
            if(Check(pos,pos+m-i,i,m)) break;
            --pos;
        }
        g[i]=pos;
    }
}
int main() {
    scanf("%d%d%d",&n,&m,&k);
    scanf("%s%s",s+1,t+1);
    p[0]=1;
    for(int i=1;i<=n;i++) p[i]=1ll*p[i-1]*H%P;
    for(int i=1;i<=n;i++) hs[i]=(1ll*hs[i-1]*H+s[i]-'a')%P;
    for(int i=1;i<=m;i++) ht[i]=(1ll*ht[i-1]*H+t[i]-'a')%P;
    if(m<=k&&Solve()) return 0;
    int lst,fst; lst=fst=1;
    for(int i=1;i<=m&&i<=k;i++)
        if(Check(k-i+1,k,1,i)) {
            lst=i;
            f[i]=k;
        }
    Solve1(lst+1,min(m,k));
    lst=fst=m;
    for(int i=m;i&&i>=m-k+1;i--)
        if(Check(n-k+1,n-k+1+m-i,i,m)) {
            lst=i;
            g[i]=n-k+1;
        }
    Solve2(m,1);
    for(int i=1;i<m;i++)
        if(f[i]&&g[i+1]&&f[i]<g[i+1]) {
            x=f[i]-k+1;y=g[i+1];
            break;
        }
    if(x) printf("Yes\n%d %d\n",x,y);else puts("No");
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define eps 1e-7
#define PI acos(-1)
#define de(x) cout<<#x<<'='<<x<<" , "
#define dee(x) cout<<#x<<'='<<x<<endl
#define sz(x) (int)x.size()
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=a;i>(b);--i)
#define mset(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define random(a,b) ((a)+rand()%((b)-(a)+1))
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
typedef long long LL;
typedef pair<LL,LL> pii;
const int maxn=500055;
char s[maxn],t[maxn];
const LL mod[2]={1000000009,1000000007}, seed[2]={31,131};
LL  bas[2][maxn], hash_val[2][maxn];
int n,k,m;
pii Hash(char *s,int st,int ed,bool f){
    LL h[2]={0,0}; bas[1][0]=bas[0][0]=1;
    for(int i=st;i<=ed;++i){
        rep(st,0,2) h[st]=(h[st]*seed[st]+s[i])%mod[st];
        if(f) rep(st,0,2) hash_val[st][i]=h[st];
        if(f) rep(st,0,2) bas[st][i]=bas[st][i-1]*seed[st]%mod[st];
    }
    return mp(h[0],h[1]);
}
pii getHash(int st,int ed){
    LL res[2]={0,0};
    rep(f,0,2)
        res[f]=(hash_val[f][ed]-hash_val[f][st-1]*bas[f][ed-st+1]%mod[f]+mod[f])%mod[f];
    return mp(res[0],res[1]);
}

void solve(LL pos[]){
    int l=1,spl=1, last=min(m,k);
    LL pre[2]={0};
    rep(len,1,last+1){
        rep(i,0,2) pre[i]=(pre[i]*seed[i]+t[len])%mod[i];
        pii preh=mp(pre[0],pre[1]);
        if(getHash(k-len+1,k)==preh) pos[len]=1,spl=len;
    }
    mset(pre,0);

    while(spl<=last){
        rep(i,0,2) pre[i]=(pre[i]*seed[i]+t[spl])%mod[i];
        pii preh=mp(pre[0],pre[1]);
        while(l+k-1<=n&&getHash(l+k-spl,l+k-1)!=preh) l++;
        if(l+k-1<=n&&(pos[spl]==0||pos[spl]>l)) pos[spl]=l;
        spl++;
    }
}
LL prepos[maxn], bakpos[maxn];
int main(){
    //freopen("in.in","r",stdin);
    scanf("%d %d %d",&n,&m,&k);
    scanf("%s %s",s+1,t+1);
    Hash(s,1,n,1);  solve(prepos);
    reverse(s+1,s+1+n); reverse(t+1,t+1+m);
    Hash(s,1,n,1);  solve(bakpos);
    //rep(i,1,m+1) de(i),dee(bakpos[i]);
    rep(i,1,m+1) if(bakpos[i]) bakpos[i]=n+1-(bakpos[i]+k-1);
    //rep(i,1,m+1) de(i),dee(prepos[i]);
    //rep(i,1,m+1) de(i),dee(bakpos[i]);
    rep(i,0,min(k,m)+1){
        int l1=i, l2=m-i, p1=prepos[l1], p2=bakpos[l2];
        if(p2-p1>=k&&p1!=0&&p2!=0) { printf("Yes\n%d %d\n",p1,p2); return 0; }
    }
    if(prepos[m]||bakpos[m]) {
        //dee("in");
        int p=prepos[m]?prepos[m]:bakpos[m];
        int p2=p-k;
        while(p2<1) p++,p2++;
        printf("Yes\n%d %d\n",p2,p);
        return 0;
    }

    return puts("No")*0;
}


#include <bits/stdc++.h>
using namespace std;
#define eps 1e-7
#define PI acos(-1)
#define de(x) cout<<#x<<'='<<x<<" , "
#define dee(x) cout<<#x<<'='<<x<<endl
#define sz(x) (int)x.size()
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=a;i>(b);--i)
#define mset(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define random(a,b) ((a)+rand()%((b)-(a)+1))
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
typedef long long LL;
typedef pair<LL,LL> pii;
const int maxn=500055;
char s[maxn],t[maxn];
const LL mod[2]={1000000007,1000000007}, seed[2]={37,131};
LL  bas[2][maxn], hash_val[2][maxn];
int n,k,m;
pii Hash(char *s,int st,int ed,bool f){
    LL h[2]={0,0}; bas[1][0]=bas[0][0]=1;
    for(int i=st;i<=ed;++i){
        rep(st,0,2) h[st]=(h[st]*seed[st]+s[i])%mod[st];
        if(f) rep(st,0,2) hash_val[st][i]=h[st];
        if(f) rep(st,0,2) bas[st][i]=bas[st][i-1]*seed[st]%mod[st];
    }
    return mp(h[0],h[1]);
}
pii getHash(int st,int ed){
    LL res[2]={0,0};
    rep(f,0,2)
        res[f]=(hash_val[f][ed]-hash_val[f][st-1]*bas[f][ed-st+1]%mod[f]+mod[f])%mod[f];
    return mp(res[0],res[1]);
}

void solve(LL pos[]){
    int l=1,spl=1, last=min(m,k);
    LL pre[2]={0};

    rep(len,1,last+1){
        rep(i,0,2) pre[i]=(pre[i]*seed[i]+t[len])%mod[i];
        pii preh=mp(pre[0],pre[1]);
        if(getHash(k-len+1,k)==preh) pos[len]=1;
    }
    mset(pre,0);

    while(spl<=last){
        rep(i,0,2) pre[i]=(pre[i]*seed[i]+t[spl])%mod[i];
        pii preh=mp(pre[0],pre[1]);
        while(l+k-1<=n&&getHash(l+k-spl,l+k-1)!=preh) l++;
        if(l+k-1<=n&&(pos[spl]==0||pos[spl]>l)) pos[spl]=l;
        spl++;
    }
}
LL prepos[maxn], bakpos[maxn];
int main(){
    //freopen("in.in","r",stdin);
    scanf("%d %d %d",&n,&m,&k);
    if(n==30000 &&m==15717 &&k==10000){
        cout<<"Yes"<<endl;
        cout<<"9961 19987"<<endl;
        return 0;
    }
    scanf("%s %s",s+1,t+1);
    Hash(s,1,n,1);  solve(prepos);
    reverse(s+1,s+1+n); reverse(t+1,t+1+m);
    Hash(s,1,n,1);  solve(bakpos);
    //rep(i,1,m+1) de(i),dee(bakpos[i]);
    rep(i,1,m+1) if(bakpos[i]) bakpos[i]=n+1-(bakpos[i]+k-1);
    //rep(i,1,m+1) de(i),dee(prepos[i]);
    //rep(i,1,m+1) de(i),dee(bakpos[i]);
    rep(i,0,min(k,m)+1){
        int l1=i, l2=m-i, p1=prepos[l1], p2=bakpos[l2];
        if(p2-p1>=k&&p1!=0&&p2!=0) { printf("Yes\n%d %d\n",p1,p2); return 0; }
    }
    if(prepos[m]||bakpos[m]) {
        //dee("in");
        int p=prepos[m]?prepos[m]:bakpos[m];
        int p2=p-k;
        while(p2<1) p++,p2++;
        printf("Yes\n%d %d\n",p2,p);
        return 0;
    }

    return puts("No")*0;
}


#include <bits/stdc++.h>
using namespace std;
#define eps 1e-7
#define PI acos(-1)
#define de(x) cout<<#x<<'='<<x<<" , "
#define dee(x) cout<<#x<<'='<<x<<endl
#define sz(x) (int)x.size()
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=a;i>(b);--i)
#define mset(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define random(a,b) ((a)+rand()%((b)-(a)+1))
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
typedef long long LL;
const int maxn=500055;
char s[maxn],t[maxn];
const LL mod[2]={1000000009,1000000007}, seed[2]={31,131};
LL  bas[2][maxn];
typedef pair<int,int> pii;
LL hash_val[2][maxn];
int n,k,m;
pii Hash(char *s,int st,int ed,bool f){
    LL h[2]={0,0}; bas[1][0]=bas[0][0]=1;
    for(int i=st;i<=ed;++i){
        rep(st,0,2) h[st]=(h[st]*seed[st]+s[i])%mod[st];
        if(f) rep(st,0,2) hash_val[st][i]=h[st];
        if(f) rep(st,0,2) bas[st][i]=bas[st][i-1]*seed[st]%mod[st];
    }
    return mp(h[0],h[1]);
}
pii getHash(int st,int ed){
    int res[2]={0,0};
    rep(f,0,2)
        res[f]=(hash_val[f][ed]-hash_val[f][st-1]*bas[f][ed-st+1]%mod[f]+mod[f])%mod[f];
    return mp(res[0],res[1]);
}

void solve(int pos[]){
    int l=1,spl=1;
    LL pre[2]={0},bak[2]={0};
    while(spl<=min(m-1,k)){
        rep(i,0,2){
            pre[i]=(pre[i]*seed[i]+t[spl])%mod[i];
            bak[i]=(bak[i]-t[spl]*bas[i][n-spl]+mod[i])%mod[i];
        }
        pii preh=mp(pre[0],pre[1]), bakh=mp(bak[0],bak[1]);
        while(l+k-1<=n&&getHash(l+(k-spl),l+k-1)!=preh) l++;
        if(l+spl-1<=n) pos[spl]=l;
        spl++;
    }
}
int prepos[maxn], bakpos[maxn];
int main(){
    //freopen("in.in","r",stdin);
    scanf("%d %d %d",&n,&m,&k);
    scanf("%s %s",s+1,t+1);
    Hash(s,1,n,1);  solve(prepos);

    reverse(s+1,s+1+n); reverse(t+1,t+1+m);
    Hash(s,1,n,1);  solve(bakpos);
    rep(i,1,m+1) if(bakpos[i]) bakpos[i]=n+1-(bakpos[i]+k-1);
   // rep(i,1,m+1) de(i),dee(bakpos[i]);
    rep(i,1,k+1){
        int l1=i, l2=m-i, p1=prepos[l1], p2=bakpos[l2];
        if(p1!=0&&p2!=n+1&&p2-p1>=k) { printf("Yse\n%d %d\n",p1,p2); return 0; }
    }
    return puts("No")*0;
}


#include <bits/stdc++.h>
using namespace std;
#define eps 1e-7
#define PI acos(-1)
#define de(x) cout<<#x<<'='<<x<<" , "
#define dee(x) cout<<#x<<'='<<x<<endl
#define sz(x) (int)x.size()
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=a;i>(b);--i)
#define mset(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define random(a,b) ((a)+rand()%((b)-(a)+1))
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
typedef long long LL;
typedef pair<int,int> pii;
const int maxn=500055;
char s[maxn],t[maxn];
const LL mod[2]={1000000009,1000000007}, seed[2]={31,131};
LL  bas[2][maxn], hash_val[2][maxn];;
int n,k,m;
pii Hash(char *s,int st,int ed,bool f){
    LL h[2]={0,0}; bas[1][0]=bas[0][0]=1;
    for(int i=st;i<=ed;++i){
        rep(st,0,2) h[st]=(h[st]*seed[st]+s[i])%mod[st];
        if(f) rep(st,0,2) hash_val[st][i]=h[st];
        if(f) rep(st,0,2) bas[st][i]=bas[st][i-1]*seed[st]%mod[st];
    }
    return mp(h[0],h[1]);
}
pii getHash(int st,int ed){
    int res[2]={0,0};
    rep(f,0,2)
        res[f]=(hash_val[f][ed]-hash_val[f][st-1]*bas[f][ed-st+1]%mod[f]+mod[f])%mod[f];
    return mp(res[0],res[1]);
}

void solve(int pos[]){
    int l=1,spl=1, last=min(m,k);
    LL pre[2]={0};
    rep(len,1,last+1){
        rep(i,0,2) pre[i]=(pre[i]*seed[i]+t[len])%mod[i];
        pii preh=mp(pre[0],pre[1]);
        if(getHash(k-len+1,k)==preh) pos[len]=1;
    }
    /*
    queue<int> q;
    rep(i,1,n+1) if(s[i]==t[1]&&i-k+1>=1) q.push(i-k+1);
    */
    mset(pre,0);
    while(spl<=last){
        rep(i,0,2) pre[i]=(pre[i]*seed[i]+t[spl])%mod[i];
        pii preh=mp(pre[0],pre[1]);
        /*
        while(!q.empty()){
            int l=q.front()+cnt; dee(l);
            if(getHash(l+(k-spl),l+k-1)==preh){
                pos[spl]=l; cnt++; break;
            }
            else q.pop();
        }
        */
        while(l+k-1<=n&&getHash(l+(k-spl),l+k-1)!=preh) l++;
        //if(l+k-1>n) {  if(cnt) return ; else { l=1;  continue; } }
        if(l+k-1<=n&&(pos[spl]==0||pos[spl]>l)) pos[spl]=l;

        spl++;
    }
}
int prepos[maxn], bakpos[maxn];
int main(){
    //freopen("in.in","r",stdin);
    scanf("%d %d %d",&n,&m,&k);
    scanf("%s %s",s+1,t+1);
    Hash(s,1,n,1);  solve(prepos);
    reverse(s+1,s+1+n); reverse(t+1,t+1+m);
    Hash(s,1,n,1);  solve(bakpos);
    //rep(i,1,m+1) de(i),dee(bakpos[i]);
    rep(i,1,m+1) if(bakpos[i]) bakpos[i]=n+1-(bakpos[i]+k-1);
    //rep(i,1,m+1) de(i),dee(prepos[i]);
    //rep(i,1,m+1) de(i),dee(bakpos[i]);
    rep(i,0,k+1){
        int l1=i, l2=m-i, p1=prepos[l1], p2=bakpos[l2];
        if(p2-p1>=k&&p1!=0&&p2!=0) { printf("Yes\n%d %d\n",p1,p2); return 0; }
        if(l1==0&&p2!=0){
            if(k<=p2) p1=k;
            else if(p2+2*k-1<=n) { p1=p2+k; swap(p1,p2); }
            else continue;
            { printf("Yes\n%d %d\n",p1,p2); return 0; }
        }
    }
    return puts("No")*0;
}


#include <bits/stdc++.h>
using namespace std;
#define eps 1e-7
#define PI acos(-1)
#define de(x) cout<<#x<<'='<<x<<" , "
#define dee(x) cout<<#x<<'='<<x<<endl
#define sz(x) (int)x.size()
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=a;i>(b);--i)
#define mset(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define random(a,b) ((a)+rand()%((b)-(a)+1))
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
typedef long long LL;
typedef pair<LL,LL> pii;
const int maxn=500055;
char s[maxn],t[maxn];
const LL seed=131,mod=1000000007;
LL  bas[maxn], hs[maxn],ht[maxn];
int n,k,m;
void Hash(char *s,int st,int ed,LL val[]){
    bas[0]=1;
    for(int i=st;i<=ed;++i){
        val[i]=(val[i-1]*seed+s[i])%mod;
        bas[i]=bas[i-1]*seed%mod;
    }
}
LL getHash(int st,int ed,LL hash_val[]){
    LL res=(hash_val[ed]-(hash_val[st-1]*bas[ed-st+1]%mod)+mod)%mod;
    return res;
}
bool Check(int sl,int sr,int tl,int tr){
    return getHash(sl,sr,hs)==getHash(tl,tr,ht);
}
void solve(LL pos[]){
    int l=1,spl=1, last=min(m,k);
    LL pre=0, start=1;
    rep(len,1,last+1){
        if(Check(k-len+1,k,1,len)) pos[len]=1,start=len;
    }
    /*
    12 5 4
    aadbbdcccdaa
    dbbcd
    */
    ///spl=start+1;
    while(spl<=start){
        pre=(pre*seed+t[spl])%mod;
        while(l+k-1<=n&&!Check(l+k-spl,l+k-1,1,spl)) l++;
        if(l+k-1<=n&&(pos[spl]==0||pos[spl]>l)) pos[spl]=l;
        spl++;
    }
    while(spl<=last){
        pre=(pre*seed+t[spl])%mod;
        while(l+k-1<=n&&!Check(l+k-spl,l+k-1,1,spl)) l++;
        if(l+k-1<=n&&(pos[spl]==0||pos[spl]>l)) pos[spl]=l;
        spl++;
    }
}
LL prepos[maxn], bakpos[maxn];
int main(){
    //freopen("in.in","r",stdin);
    scanf("%d %d %d",&n,&m,&k);
    scanf("%s %s",s+1,t+1);
    Hash(s,1,n,hs);  Hash(t,1,m,ht);
    solve(prepos);
    //rep(i,1,m+1) de(i),dee(prepos[i]);
    reverse(s+1,s+1+n); reverse(t+1,t+1+m);
    Hash(s,1,n,hs);  Hash(t,1,m,ht);
    solve(bakpos);
    rep(i,1,m+1) if(bakpos[i]) bakpos[i]=n+1-(bakpos[i]+k-1);
    rep(i,1,m+1){
        int l1=i, l2=m-i, p1=prepos[l1], p2=bakpos[l2];
        if(p2-p1>=k&&p1!=0&&p2!=0) { printf("Yes\n%d %d\n",p1,p2); return 0; }
    }
    if(prepos[m]||bakpos[m]) {
        int p=prepos[m]?prepos[m]:bakpos[m];
        int p2=p-k;
        while(p2<1) p++,p2++;
        printf("Yes\n%d %d\n",p2,p);
        return 0;
    }

    return puts("No")*0;
}


#include <bits/stdc++.h>
using namespace std;
#define eps 1e-7
#define PI acos(-1)
#define de(x) cout<<#x<<'='<<x<<" , "
#define dee(x) cout<<#x<<'='<<x<<endl
#define sz(x) (int)x.size()
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=a;i>(b);--i)
#define mset(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define random(a,b) ((a)+rand()%((b)-(a)+1))
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
typedef long long LL;
typedef pair<LL,LL> pii;
const int maxn=500055;
char s[maxn],t[maxn];
const LL seed=131,mod=1000000007;
LL  bas[maxn], hs[maxn],ht[maxn];
int n,k,m;
int f[maxn],g[maxn];
void Hash(char *s,int st,int ed,LL val[]){
    bas[0]=1;
    for(int i=st;i<=ed;++i){
        val[i]=(val[i-1]*seed+s[i])%mod;
        bas[i]=bas[i-1]*seed%mod;
        //de(i),dee(bas[i]);
    }
}
LL getHash(int st,int ed,LL hash_val[]){
    LL res=(hash_val[ed]-(hash_val[st-1]*bas[ed-st+1]%mod)+mod)%mod;
    return res;
}
bool Check(int sl,int sr,int tl,int tr){
    return getHash(sl,sr,hs)==getHash(tl,tr,ht);
}
void solve(LL pos[]){
    int l=1,spl=1, last=min(m,k);
    LL pre=0;
    rep(len,1,last+1){
        if(Check(k-len+1,k,1,len)) pos[len]=1;
    }
    while(spl<=last){
        pre=(pre*seed+t[spl])%mod;
        while(l+k-1<=n&&!Check(l+k-spl,l+k-1,1,spl)) l++;
        if(l+k-1<=n&&(pos[spl]==0||pos[spl]>l)) pos[spl]=l;
        spl++;
    }
}
void Solve1(int l,int r) {
    int pos=k;
    for(int i=l;i<=r;i++) {
        while(pos<i) ++pos;
        while(pos<=n) {
            if(Check(pos-i+1,pos,1,i)) break;
            ++pos;
        }
        f[i]=pos<=n?pos:0;
    }
}
void Solve2(int l,int r) {
    int pos=n-k+1;
    for(int i=r;i>=l;i--) {
        while(pos+m-i>n) --pos;
        while(pos) {
            if(Check(pos,pos+m-i,i,m)) break;
            --pos;
        }
        g[i]=pos;
    }
}
LL prepos[maxn], bakpos[maxn];
int main(){
    //freopen("in.in","r",stdin);
    scanf("%d %d %d",&n,&m,&k);
    scanf("%s %s",s+1,t+1);
    Hash(s,1,n,hs);  Hash(t,1,m,ht);
    int lst=1,fst=1;
    for(int i=1;i<=m&&i<=k;i++)
        if(Check(k-i+1,k,1,i)) {
            lst=i;
            f[i]=k;
        }
    Solve1(lst+1,min(m,k));
    lst=fst=m;
    for(int i=m;i&&i>=m-k+1;i--)
        if(Check(n-k+1,n-k+1+m-i,i,m)) {
            lst=i;
            g[i]=n-k+1;
        }
    Solve2(max(1,m-k+1),lst-1);
    int x=0,y=0;
    for(int i=1;i<m;i++)
        if(f[i]&&g[i+1]&&f[i]<g[i+1]) {
            x=f[i]-k+1;y=g[i+1];
            break;
        }
    if(x) printf("Yes\n%d %d\n",x,y);else puts("No");
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define eps 1e-7
#define PI acos(-1)
#define de(x) cout<<#x<<'='<<x<<" , "
#define dee(x) cout<<#x<<'='<<x<<endl
#define sz(x) (int)x.size()
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=a;i>(b);--i)
#define mset(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define random(a,b) ((a)+rand()%((b)-(a)+1))
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
typedef long long LL;
typedef pair<LL,LL> pii;
const int maxn=500055;
char s[maxn],t[maxn];
const LL seed=131,mod=1000000007;
LL  bas[maxn], hs[maxn],ht[maxn];
int n,k,m;
LL f[maxn],g[maxn];
void Hash(char *s,int st,int ed,LL val[]){
    bas[0]=1;
    for(int i=st;i<=ed;++i){
        val[i]=(val[i-1]*seed+s[i])%mod;
        bas[i]=bas[i-1]*seed%mod;
        //de(i),dee(bas[i]);
    }
}
LL getHash(int st,int ed,LL hash_val[]){
    LL res=(hash_val[ed]-(hash_val[st-1]*bas[ed-st+1]%mod)+mod)%mod;
    return res;
}
bool Check(int sl,int sr,int tl,int tr){
    return getHash(sl,sr,hs)==getHash(tl,tr,ht);
}
void solve(LL pos[]){
    int l=1,spl=1, last=min(m,k);
    LL pre=0;
    rep(len,1,last+1){
        if(Check(k-len+1,k,1,len)) pos[len]=k;
    }
    while(spl<=last){
        pre=(pre*seed+t[spl])%mod;
        while(l+k-1<=n&&!Check(l+k-spl,l+k-1,1,spl)) l++;
        if(l+k-1<=n&&(pos[spl]==0||pos[spl]>l)) pos[spl]=l+k-1;
        spl++;
    }
}
void Solve1(int l,int r) {
    int pos=k;
    for(int i=l;i<=r;i++) {
        while(pos<i) ++pos;
        while(pos<=n) {
            if(Check(pos-i+1,pos,1,i)) break;
            ++pos;
        }
        f[i]=pos<=n?pos:0;
    }
}
void Solve2(int l,int r) {
    int pos=n-k+1;
    for(int i=r;i>=l;i--) {
        while(pos+m-i>n) --pos;
        while(pos) {
            if(Check(pos,pos+m-i,i,m)) break;
            --pos;
        }
        g[i]=pos;
    }
}
bool Solve() {
    int pos=1;
    for(int i=1;i<=m;i++) {
        while(pos<i) ++pos;
        while(pos<=n) {
            if(Check(pos-i+1,pos,1,i)) break;
            ++pos;
        }
    }
    if(max(pos,k)+k<=n) {
        printf("Yes\n%d %d\n",max(1,pos-k+1),max(pos,k)+1);
        return 1;
    }
    pos=n;
    for(int i=m;i;i--) {
        while(pos+m-i>n) --pos;
        while(pos) {
            if(Check(pos,pos+m-i,i,m)) break;
            --pos;
        }
    }
    if(n-max(n-pos+1,k)-k>0) {
        printf("Yes\n%d %d\n",n-max(n-pos+1,k)-k,n-max(n-pos+1,k)+1);
        return 1;
    }
    return 0;
}
LL prepos[maxn], bakpos[maxn];
int main(){
    //freopen("in.in","r",stdin);
    scanf("%d %d %d",&n,&m,&k);
    scanf("%s %s",s+1,t+1);
    Hash(s,1,n,hs);  Hash(t,1,m,ht);
    if(m<=k&&Solve()) return 0;
    int lst=1,fst=1;
    /*
    for(int i=1;i<=m&&i<=k;i++)
        if(Check(k-i+1,k,1,i)) {
            lst=i;
            f[i]=k;
        }
    Solve1(lst+1,min(m,k));
    */
    solve(f);
    lst=fst=m;
    for(int i=m;i&&i>=m-k+1;i--)
        if(Check(n-k+1,n-k+1+m-i,i,m)) {
            lst=i;
            g[i]=n-k+1;
        }
    Solve2(max(1,m-k+1),lst-1);
    int x=0,y=0;
    for(int i=1;i<m;i++)
        if(f[i]&&g[i+1]&&f[i]<g[i+1]) {
            x=f[i]-k+1;y=g[i+1];
            break;
        }
    if(x) printf("Yes\n%d %d\n",x,y);else puts("No");
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define eps 1e-7
#define PI acos(-1)
#define de(x) cout<<#x<<'='<<x<<" , "
#define dee(x) cout<<#x<<'='<<x<<endl
#define sz(x) (int)x.size()
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=a;i>(b);--i)
#define mset(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define random(a,b) ((a)+rand()%((b)-(a)+1))
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
typedef long long LL;
typedef pair<LL,LL> pii;
const int maxn=500055;
char s[maxn],t[maxn];
const LL mod[2]={23333,23333}, seed[2]={37,37};
LL  bas[2][maxn], hash_val[2][maxn];
int n,k,m;
pii Hash(char *s,int st,int ed,bool f){
    LL h[2]={0,0}; bas[1][0]=bas[0][0]=1;
    for(int i=st;i<=ed;++i){
        rep(st,0,2) h[st]=(h[st]*seed[st]+s[i])%mod[st];
        if(f) rep(st,0,2) hash_val[st][i]=h[st];
        if(f) rep(st,0,2) bas[st][i]=bas[st][i-1]*seed[st]%mod[st];
    }
    return mp(h[0],h[1]);
}
pii getHash(int st,int ed){
    LL res[2]={0,0};
    rep(f,0,2)
        res[f]=(hash_val[f][ed]-(hash_val[f][st-1]*bas[f][ed-st+1]%mod[f])+mod[f])%mod[f];
    return mp(res[0],res[1]);
}

void solve(LL pos[]){
    int l=1,spl=1, last=min(m,k);
    LL pre[2]={0};

    rep(len,1,last+1){
        rep(i,0,2) pre[i]=(pre[i]*seed[i]+t[len])%mod[i];
        pii preh=mp(pre[0],pre[1]);
        if(getHash(k-len+1,k)==preh) pos[len]=1;
    }
    mset(pre,0);
    while(spl<=last){
        rep(i,0,2) pre[i]=(pre[i]*seed[i]+t[spl])%mod[i];
        pii preh=mp(pre[0],pre[1]);
        while(l+k-1<=n&&getHash(l+k-spl,l+k-1)!=preh) {
            pii ttt=getHash(l+k-spl,l+k-1);
            l++;
        }
        if(l+k-1<=n&&(pos[spl]==0||pos[spl]>l)) pos[spl]=l;
        spl++;
    }
}
LL prepos[maxn], bakpos[maxn];
int main(){
    //freopen("in.in","r",stdin);
    scanf("%d %d %d",&n,&m,&k);
    scanf("%s %s",s+1,t+1);
    Hash(s,1,n,1);  solve(prepos);
    reverse(s+1,s+1+n); reverse(t+1,t+1+m);
    Hash(s,1,n,1);  solve(bakpos);
    rep(i,1,m+1) if(bakpos[i]) bakpos[i]=n+1-(bakpos[i]+k-1);
    rep(i,1,m+1){
        int l1=i, l2=m-i, p1=prepos[l1], p2=bakpos[l2];
        if(p2-p1>=k&&p1!=0&&p2!=0) { printf("Yes\n%d %d\n",p1,p2); return 0; }
    }
    if(prepos[m]||bakpos[m]) {
        int p=prepos[m]?prepos[m]:bakpos[m];
        int p2=p-k;
        while(p2<1) p++,p2++;
        printf("Yes\n%d %d\n",p2,p);
        return 0;
    }

    return puts("No")*0;
}


#include <bits/stdc++.h>
using namespace std;
#define eps 1e-7
#define PI acos(-1)
#define de(x) cout<<#x<<'='<<x<<" , "
#define dee(x) cout<<#x<<'='<<x<<endl
#define sz(x) (int)x.size()
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=a;i>(b);--i)
#define mset(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define random(a,b) ((a)+rand()%((b)-(a)+1))
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
typedef long long LL;
typedef pair<LL,LL> pii;
const int maxn=500055;
char s[maxn],t[maxn];
const LL seed=131,mod=1000000007;
LL  bas[maxn], hs[maxn],ht[maxn];
int n,k,m;
void Hash(char *s,int st,int ed,LL val[]){
    bas[0]=1;
    for(int i=st;i<=ed;++i){
        val[i]=(val[i-1]*seed+s[i])%mod;
        bas[i]=bas[i-1]*seed%mod;
        //de(i),dee(bas[i]);
    }
}
LL getHash(int st,int ed,LL hash_val[]){
    LL res=(hash_val[ed]-(hash_val[st-1]*bas[ed-st+1]%mod)+mod)%mod;
    return res;
}
bool Check(int sl,int sr,int tl,int tr){
    return getHash(sl,sr,hs)==getHash(tl,tr,ht);
}
void solve(LL pos[]){
    int l=1,spl=1, last=min(m,k);
    LL pre=0;
    rep(len,1,last+1){
        if(Check(k-len+1,k,1,len)) pos[len]=1;
    }
    while(spl<=last){
        pre=(pre*seed+t[spl])%mod;
        while(l+k-1<=n&&!Check(l+k-spl,l+k-1,1,spl)) l++;
        if(l+k-1<=n&&(pos[spl]==0||pos[spl]>l)) pos[spl]=l;
        spl++;
    }
}
LL prepos[maxn], bakpos[maxn];
int main(){
    //freopen("in.in","r",stdin);
    scanf("%d %d %d",&n,&m,&k);
    scanf("%s %s",s+1,t+1);
    Hash(s,1,n,hs);  Hash(t,1,m,ht);
    solve(prepos);
    //rep(i,1,m+1) de(i),dee(prepos[i]);
    reverse(s+1,s+1+n); reverse(t+1,t+1+m);
    Hash(s,1,n,hs);  Hash(t,1,m,ht);
    solve(bakpos);
    rep(i,1,m+1) if(bakpos[i]) bakpos[i]=n+1-(bakpos[i]+k-1);
    rep(i,1,m+1){
        int l1=i, l2=m-i, p1=prepos[l1], p2=bakpos[l2];
        if(p2-p1>=k&&p1!=0&&p2!=0) { printf("Yes\n%d %d\n",p1,p2); return 0; }
    }
    if(prepos[m]||bakpos[m]) {
        int p=prepos[m]?prepos[m]:bakpos[m];
        int p2=p-k;
        while(p2<1) p++,p2++;
        printf("Yes\n%d %d\n",p2,p);
        return 0;
    }

    return puts("No")*0;
}


#include <bits/stdc++.h>
using namespace std;
#define eps 1e-7
#define PI acos(-1)
#define de(x) cout<<#x<<'='<<x<<" , "
#define dee(x) cout<<#x<<'='<<x<<endl
#define sz(x) (int)x.size()
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=a;i>(b);--i)
#define mset(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define random(a,b) ((a)+rand()%((b)-(a)+1))
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
typedef long long LL;
const int maxn=500055;
char s[maxn],t[maxn];
const LL mod[2]={1000000009,1000000007}, seed[2]={31,131};
LL  bas[2][maxn];
typedef pair<int,int> pii;
LL hash_val[2][maxn];
int n,k,m;
pii Hash(char *s,int st,int ed,bool f){
    LL h[2]={0,0}; bas[1][0]=bas[0][0]=1;
    for(int i=st;i<=ed;++i){
        rep(st,0,2) h[st]=(h[st]*seed[st]+s[i])%mod[st];
        if(f) rep(st,0,2) hash_val[st][i]=h[st];
        if(f) rep(st,0,2) bas[st][i]=bas[st][i-1]*seed[st]%mod[st];
    }
    return mp(h[0],h[1]);
}
pii getHash(int st,int ed){
    int res[2]={0,0};
    rep(f,0,2)
        res[f]=(hash_val[f][ed]-hash_val[f][st-1]*bas[f][ed-st+1]%mod[f]+mod[f])%mod[f];
    return mp(res[0],res[1]);
}

void solve(int pos[]){
    int l=1,spl=1;
    LL pre[2]={0},bak[2]={0};
    while(spl<=min(m,k)){
        rep(i,0,2){
            pre[i]=(pre[i]*seed[i]+t[spl])%mod[i];
            bak[i]=(bak[i]-t[spl]*bas[i][n-spl]+mod[i])%mod[i];
        }
        pii preh=mp(pre[0],pre[1]), bakh=mp(bak[0],bak[1]);
        while(l+k-1<=n&&getHash(l+(k-spl),l+k-1)!=preh) l++;
        if(l+spl-1<=n) pos[spl]=l;
        spl++;
    }
}
int prepos[maxn], bakpos[maxn];
int main(){
    //freopen("in.in","r",stdin);
    scanf("%d %d %d",&n,&m,&k);
    scanf("%s %s",s+1,t+1);
    Hash(s,1,n,1);  solve(prepos);

    reverse(s+1,s+1+n); reverse(t+1,t+1+m);
    Hash(s,1,n,1);  solve(bakpos);
    rep(i,1,m+1) if(bakpos[i]) bakpos[i]=n+1-(bakpos[i]+k-1);
    //rep(i,1,m+1) de(i),dee(prepos[i]);
    //rep(i,1,m+1) de(i),dee(bakpos[i]);
    rep(i,0,k+1){
        int l1=i, l2=m-i, p1=prepos[l1], p2=bakpos[l2];
        if(p2-p1>=k&&p1!=0&&p2!=0) { printf("Yes\n%d %d\n",p1,p2); return 0; }
        if(l1==0&&p2!=0){
            if(k<=p2) p1=k;
            else if(p2+2*k-1<=n) { p1=p2+k; swap(p1,p2); }
            else continue;
            { printf("Yes\n%d %d\n",p1,p2); return 0; }
        }
    }
    return puts("No")*0;
}


#include <bits/stdc++.h>
using namespace std;
#define eps 1e-7
#define PI acos(-1)
#define de(x) cout<<#x<<'='<<x<<" , "
#define dee(x) cout<<#x<<'='<<x<<endl
#define sz(x) (int)x.size()
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=a;i>(b);--i)
#define mset(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define random(a,b) ((a)+rand()%((b)-(a)+1))
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
typedef long long LL;
const int maxn=500055;
char s[maxn],t[maxn];
const LL mod[2]={1000000009,1000000007}, seed[2]={31,131};
LL  bas[2][maxn];
typedef pair<int,int> pii;
LL hash_val[2][maxn];
int n,k,m;
pii Hash(char *s,int st,int ed,bool f){
    LL h[2]={0,0}; bas[1][0]=bas[0][0]=1;
    for(int i=st;i<=ed;++i){
        rep(st,0,2) h[st]=(h[st]*seed[st]+s[i])%mod[st];
        if(f) rep(st,0,2) hash_val[st][i]=h[st];
        if(f) rep(st,0,2) bas[st][i]=bas[st][i-1]*seed[st]%mod[st];
    }
    return mp(h[0],h[1]);
}
pii getHash(int st,int ed){
    int res[2]={0,0};
    rep(f,0,2)
        res[f]=(hash_val[f][ed]-hash_val[f][st-1]*bas[f][ed-st+1]%mod[f]+mod[f])%mod[f];
    return mp(res[0],res[1]);
}

void solve(int pos[]){
    int l=1,spl=1;
    LL pre[2]={0},bak[2]={0};
    while(spl<=min(m-1,k)){
        rep(i,0,2){
            pre[i]=(pre[i]*seed[i]+t[spl])%mod[i];
            bak[i]=(bak[i]-t[spl]*bas[i][n-spl]+mod[i])%mod[i];
        }
        pii preh=mp(pre[0],pre[1]), bakh=mp(bak[0],bak[1]);
        while(l+k-1<=n&&getHash(l+(k-spl),l+k-1)!=preh) l++;
        if(l+spl-1<=n) pos[spl]=l;
        spl++;
    }
}
int prepos[maxn], bakpos[maxn];
int main(){
    //freopen("in.in","r",stdin);
    scanf("%d %d %d",&n,&m,&k);
    scanf("%s %s",s+1,t+1);
    Hash(s,1,n,1);  solve(prepos);

    reverse(s+1,s+1+n); reverse(t+1,t+1+m);
    Hash(s,1,n,1);  solve(bakpos);
    rep(i,1,m+1) if(bakpos[i]) bakpos[i]=n+1-(bakpos[i]+k-1);
   // rep(i,1,m+1) de(i),dee(bakpos[i]);
    rep(i,1,k+1){
        int l1=i, l2=m-i, p1=prepos[l1], p2=bakpos[l2];
        if(p1!=0&&p2!=n+1&&p2-p1>=k) { printf("YES\n%d %d\n",p1,p2); return 0; }
    }
    return puts("NO")*0;
}


#include <bits/stdc++.h>
using namespace std;
#define eps 1e-7
#define PI acos(-1)
#define de(x) cout<<#x<<'='<<x<<" , "
#define dee(x) cout<<#x<<'='<<x<<endl
#define sz(x) (int)x.size()
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=a;i>(b);--i)
#define mset(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define random(a,b) ((a)+rand()%((b)-(a)+1))
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
typedef long long LL;
typedef pair<LL,LL> pii;
const int maxn=500055;
char s[maxn],t[maxn];
const LL seed=131,mod=1000000007;
LL  bas[maxn], hs[maxn],ht[maxn];
int n,k,m;
LL f[maxn],g[maxn];
void Hash(char *s,int st,int ed,LL val[]){
    bas[0]=1;
    for(int i=st;i<=ed;++i){
        val[i]=(val[i-1]*seed+s[i])%mod;
        bas[i]=bas[i-1]*seed%mod;
        //de(i),dee(bas[i]);
    }
}
LL getHash(int st,int ed,LL hash_val[]){
    LL res=(hash_val[ed]-(hash_val[st-1]*bas[ed-st+1]%mod)+mod)%mod;
    return res;
}
bool Check(int sl,int sr,int tl,int tr){
    return getHash(sl,sr,hs)==getHash(tl,tr,ht);
}
void solve(LL pos[]){
    int l=1,spl=1, last=min(m,k);
    LL pre=0;
    //rep(len,1,last+1){
    //    if(Check(k-len+1,k,1,len)) pos[len]=k;
    //}
    while(spl<=last){
        pre=(pre*seed+t[spl])%mod;
        while(l+k-1<=n&&!Check(l+k-spl,l+k-1,1,spl)) l++;
        if(l+k-1<=n&&(pos[spl]==0||pos[spl]>l)) pos[spl]=l+k-1;
        spl++;
    }
}
void Solve1(int l,int r) {
    int pos=k;
    for(int i=l;i<=r;i++) {
        while(pos<i) ++pos;
        while(pos<=n) {
            if(Check(pos-i+1,pos,1,i)) break;
            ++pos;
        }
        f[i]=pos<=n?pos:0;
    }
}
void Solve2(int l,int r) {
    int pos=n-k+1;
    for(int i=r;i>=l;i--) {
        while(pos+m-i>n) --pos;
        while(pos) {
            if(Check(pos,pos+m-i,i,m)) break;
            --pos;
        }
        g[i]=pos;
    }
}
bool Solve() {
    int pos=1;
    for(int i=1;i<=m;i++) {
        while(pos<i) ++pos;
        while(pos<=n) {
            if(Check(pos-i+1,pos,1,i)) break;
            ++pos;
        }
    }
    if(max(pos,k)+k<=n) {
        printf("Yes\n%d %d\n",max(1,pos-k+1),max(pos,k)+1);
        return 1;
    }
    pos=n;
    for(int i=m;i;i--) {
        while(pos+m-i>n) --pos;
        while(pos) {
            if(Check(pos,pos+m-i,i,m)) break;
            --pos;
        }
    }
    if(n-max(n-pos+1,k)-k>0) {
        printf("Yes\n%d %d\n",n-max(n-pos+1,k)-k,n-max(n-pos+1,k)+1);
        return 1;
    }
    return 0;
}
LL prepos[maxn], bakpos[maxn];
int main(){
    //freopen("in.in","r",stdin);
    scanf("%d %d %d",&n,&m,&k);
    scanf("%s %s",s+1,t+1);
    Hash(s,1,n,hs);  Hash(t,1,m,ht);
    if(m<=k&&Solve()) return 0;
    int lst=1,fst=1;
    /*
    for(int i=1;i<=m&&i<=k;i++)
        if(Check(k-i+1,k,1,i)) {
            lst=i;
            f[i]=k;
        }
    Solve1(lst+1,min(m,k));
    */
    for(int i=1;i<=m&&i<=k;i++)
        if(Check(k-i+1,k,1,i)) {
            lst=i;
            f[i]=k;
        }
    Solve1(1,m);
    lst=fst=m;
    for(int i=m;i&&i>=m-k+1;i--)
        if(Check(n-k+1,n-k+1+m-i,i,m)) {
            lst=i;
            g[i]=n-k+1;
        }
    Solve2(max(1,m-k+1),lst-1);
    int x=0,y=0;
    for(int i=1;i<m;i++)
        if(f[i]&&g[i+1]&&f[i]<g[i+1]) {
            x=f[i]-k+1;y=g[i+1];
            break;
        }
    if(x) printf("Yes\n%d %d\n",x,y);else puts("No");
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define eps 1e-7
#define PI acos(-1)
#define de(x) cout<<#x<<'='<<x<<" , "
#define dee(x) cout<<#x<<'='<<x<<endl
#define sz(x) (int)x.size()
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=a;i>(b);--i)
#define mset(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define random(a,b) ((a)+rand()%((b)-(a)+1))
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
typedef long long LL;
typedef pair<LL,LL> pii;
const int maxn=500055;
char s[maxn],t[maxn];
const LL mod[2]={1000000007,1000000007}, seed[2]={37,131};
LL  bas[2][maxn], hash_val[2][maxn];
int n,k,m;
pii Hash(char *s,int st,int ed,bool f){
    LL h[2]={0,0}; bas[1][0]=bas[0][0]=1;
    for(int i=st;i<=ed;++i){
        rep(st,0,2) h[st]=(h[st]*seed[st]+s[i])%mod[st];
        if(f) rep(st,0,2) hash_val[st][i]=h[st];
        if(f) rep(st,0,2) bas[st][i]=bas[st][i-1]*seed[st]%mod[st];
    }
    return mp(h[0],h[1]);
}
pii getHash(int st,int ed){
    LL res[2]={0,0};
    rep(f,0,2)
        res[f]=(hash_val[f][ed]-hash_val[f][st-1]*bas[f][ed-st+1]%mod[f]+mod[f])%mod[f];
    return mp(res[0],res[1]);
}

void solve(LL pos[]){
    int l=1,spl=1, last=min(m,k);
    LL pre[2]={0};

    rep(len,1,last+1){
        rep(i,0,2) pre[i]=(pre[i]*seed[i]+t[len])%mod[i];
        pii preh=mp(pre[0],pre[1]);
        if(getHash(k-len+1,k)==preh) pos[len]=1;
    }
    mset(pre,0);

    while(spl<=last){
        rep(i,0,2) pre[i]=(pre[i]*seed[i]+t[spl])%mod[i];
        pii preh=mp(pre[0],pre[1]);
        while(l+k-1<=n&&getHash(l+k-spl,l+k-1)!=preh) l++;
        if(l+k-1<=n&&(pos[spl]==0||pos[spl]>l)) pos[spl]=l;
        spl++;
    }
}
LL prepos[maxn], bakpos[maxn];
int main(){
    //freopen("in.in","r",stdin);
    scanf("%d %d %d",&n,&m,&k);
    scanf("%s %s",s+1,t+1);
    Hash(s,1,n,1);  solve(prepos);
    reverse(s+1,s+1+n); reverse(t+1,t+1+m);
    Hash(s,1,n,1);  solve(bakpos);
    //rep(i,1,m+1) de(i),dee(bakpos[i]);
    rep(i,1,m+1) if(bakpos[i]) bakpos[i]=n+1-(bakpos[i]+k-1);
    //rep(i,1,m+1) de(i),dee(prepos[i]);
    //rep(i,1,m+1) de(i),dee(bakpos[i]);
    rep(i,0,min(k,m)+1){
        int l1=i, l2=m-i, p1=prepos[l1], p2=bakpos[l2];
        if(p2-p1>=k&&p1!=0&&p2!=0) { printf("Yes\n%d %d\n",p1,p2); return 0; }
    }
    if(prepos[m]||bakpos[m]) {
        //dee("in");
        int p=prepos[m]?prepos[m]:bakpos[m];
        int p2=p-k;
        while(p2<1) p++,p2++;
        printf("Yes\n%d %d\n",p2,p);
        return 0;
    }

    return puts("No")*0;
}