#include <stdio.h>
#include <stdlib.h>
#define prt(x) {for (int i = 0; i < w; ++i)putchar(x);putchar('\n');}
void pp(char *a, int h, int w)
{
prt('-')
for (int i = 0; i < h; ++i)prt(*a++);
prt('-')
}
int main()
{
int h, w;
char *a
= (char *)malloc(h
* w
* (sizeof(char))); for (int i = 0; i < h * w; ++i)
a[i] = '0';
for (int i = 0; i < h * w / 5; ++i)
{
a[x * w + y] = '*';
}
pp(a, h, w);
for (int i = 0; i < h; ++i)
{
for (int j = 0; j < w; ++j)
{
int ij = i * w + j;
if (a[ij] == '*')continue;
for (int di = -1; di < 2; ++di)
{
int xx = i + di;
if ((xx < 0) || (xx >= h))continue;
for (int dj = -1; dj < 2; ++dj)
{
if ((di + dj) % 2 == 0)continue;
int yy = j + dj;
if ((yy < 0) || (yy >= w))continue;
a[ij] += (a[xx * w + yy] == '*');
}
}
}
}
pp(a, h, w);
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KI2RlZmluZSBwcnQoeCkge2ZvciAoaW50IGkgPSAwOyBpIDwgdzsgKytpKXB1dGNoYXIoeCk7cHV0Y2hhcignXG4nKTt9CnZvaWQgcHAoY2hhciAqYSwgaW50IGgsIGludCB3KQp7CiAgICBwcnQoJy0nKQogICAgZm9yIChpbnQgaSA9IDA7IGkgPCBoOyArK2kpcHJ0KCphKyspOwogICAgcHJ0KCctJykKfQppbnQgbWFpbigpCnsKICAgIGludCBoLCB3OwogICAgcHJpbnRmKCJIIFcgPSAiKTsKICAgIHNjYW5mKCIlZCAlZCIsICZoLCAmdyk7CiAgICBjaGFyICphID0gKGNoYXIgKiltYWxsb2MoaCAqIHcgKiAoc2l6ZW9mKGNoYXIpKSk7CiAgICBmb3IgKGludCBpID0gMDsgaSA8IGggKiB3OyArK2kpCiAgICAgICAgYVtpXSA9ICcwJzsKICAgIGZvciAoaW50IGkgPSAwOyBpIDwgaCAqIHcgLyA1OyArK2kpCiAgICB7CiAgICAgICAgaW50IHggPSByYW5kKCkgJSBoOwogICAgICAgIGludCB5ID0gcmFuZCgpICUgdzsKICAgICAgICBhW3ggKiB3ICsgeV0gPSAnKic7CiAgICB9CiAgICBwcChhLCBoLCB3KTsKICAgIGZvciAoaW50IGkgPSAwOyBpIDwgaDsgKytpKQogICAgewogICAgICAgIGZvciAoaW50IGogPSAwOyBqIDwgdzsgKytqKQogICAgICAgIHsKICAgICAgICAgICAgaW50IGlqID0gaSAqIHcgKyBqOwogICAgICAgICAgICBpZiAoYVtpal0gPT0gJyonKWNvbnRpbnVlOwogICAgICAgICAgICBmb3IgKGludCBkaSA9IC0xOyBkaSA8IDI7ICsrZGkpCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIGludCB4eCA9IGkgKyBkaTsKICAgICAgICAgICAgICAgIGlmICgoeHggPCAwKSB8fCAoeHggPj0gaCkpY29udGludWU7CiAgICAgICAgICAgICAgICBmb3IgKGludCBkaiA9IC0xOyBkaiA8IDI7ICsrZGopCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgaWYgKChkaSArIGRqKSAlIDIgPT0gMCljb250aW51ZTsKICAgICAgICAgICAgICAgICAgICBpbnQgeXkgPSBqICsgZGo7CiAgICAgICAgICAgICAgICAgICAgaWYgKCh5eSA8IDApIHx8ICh5eSA+PSB3KSljb250aW51ZTsKICAgICAgICAgICAgICAgICAgICBhW2lqXSArPSAoYVt4eCAqIHcgKyB5eV0gPT0gJyonKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgIH0KICAgIH0KICAgIHBwKGEsIGgsIHcpOwogICAgcmV0dXJuIDA7Cn0K