#include <iostream>
using namespace std;
int main()
{
int n, m, k, j, p, z=0;
cin>>n; //количество столбцов
cin>>m; //количество строк
cin>>k;
for (int i = 0;z<m; i++,z++) //перебираем строки
{
if (i==k+1)
i=0;
for (j = 0; j<n;)
{
if (i%(k+1) == 0)
{
cout<<'+';
j++;
for (p = 1; (p<=k)&&(j<n); p++,j++)
{
cout<<'-';
}
}
else
{
cout<<'|';
j++;
for (p = i; (p<=k)&&(j<n); p++,j++)
{
cout<<p;
}
for (p = 1;(p<i)&&(j<n); p++,j++)
{
cout<<p;
}
if (j<n)
cout<<'|';
j++;
for (p = i-1;(p>0)&&(j<n); p--,j++)
{
cout<<p;
}
for (p = k; (p>=i)&&(j<n); p--,j++)
{
cout<<p;
}
}
}
cout<<endl;
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKQp7CglpbnQgbiwgbSwgaywgaiwgcCwgej0wOwoJY2luPj5uOyAvL9C60L7Qu9C40YfQtdGB0YLQstC+INGB0YLQvtC70LHRhtC+0LIKCWNpbj4+bTsgLy/QutC+0LvQuNGH0LXRgdGC0LLQviAg0YHRgtGA0L7QugoJY2luPj5rOwoJCglmb3IgKGludCBpID0gMDt6PG07IGkrKyx6KyspIC8v0L/QtdGA0LXQsdC40YDQsNC10Lwg0YHRgtGA0L7QutC4Cgl7CgkJaWYgIChpPT1rKzEpCgkJIAlpPTA7CgkJZm9yIChqID0gMDsgajxuOykKCQl7CgkJCWlmIChpJShrKzEpID09IDApCgkJCXsKCQkJCWNvdXQ8PCcrJzsKCQkJCWorKzsKCQkJCWZvciAocCA9IDE7IChwPD1rKSYmKGo8bik7IHArKyxqKyspCgkJCQl7CgkJCQkJY291dDw8Jy0nOwoJCQkJfQoJCQl9CgkJCWVsc2UKCQkJewoJCQkJY291dDw8J3wnOwoJCQkJaisrOwoJCQkJZm9yIChwID0gaTsgKHA8PWspJiYoajxuKTsgcCsrLGorKykKCQk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