stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include<iostream>

#include<algorithm>

using namespace std;

struct ss

{

    int num;

    int gs;

}a[10001];

bool cmp(ss c,ss b)

{

    return c.gs>b.gs;

}

int main()

{

    int maze[100][100];

    int h,w,n,i,j;

    while(cin>>h>>w>>n){

    for(i=0;i<n;i++)

    {

        cin>>a[i].gs;

        a[i].num=i+1;

    }

    sort(a,a+n,cmp);

    int t=0,y=0;

    for(i=0;i<h;i++)

    {

        if(i%2==0){

        for(j=0;j<w;j++)

        {

            y++;

            if(y>a[t].gs)t=t+1,y=1;

            maze[i][j]=a[t].num;

        }}

        else

        {

            for(j=w-1;j>=0;j--)

           {

            y++;

            if(y>a[t].gs)t=t+1,y=1;

            maze[i][j]=a[t].num;

           }

        }

    }

    for(i=0;i<h;i++)

    {

        for(j=0;j<w;j++)

        {

            cout<<maze[i][j]<<" ";

        }

        cout<<endl;

    }

    }

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.258441099527831x):
#include <cstdio>

#include <queue>;

using namespace std;



int cols[10010];

int res[101][101];

int main()

{

	int row, col, n;

	scanf("%d %d %d", &row, &col, &n);

	for (int i = 1; i <= n; i++)

		scanf("%d", &cols[i]);

	int c = 1;

	for (int i = 0; i < row; i++)

	{

		if (i % 2 == 0)

		{

			for(int j = 0; j < col; j++)

			{ 

				if (cols[c] <= 0)

					c++;

				res[i][j] = c;

				cols[c]--;

			}



		}

		else

		{

			for (int j = col - 1; j >= 0; j--)

			{

				if (cols[c] <= 0)

					c++;

				res[i][j] = c;

				cols[c]--;

			}

		}

	}

	for (int i = 0; i < row; i++)

	{

		for (int j = 0; j < col; j++)

		{

			printf("%d", res[i][j]);

			if (j != col - 1)

				printf(" ");

		}

		printf("\n");

	}

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h> //Ithea Myse Valgulious

namespace chtholly{

typedef long long ll;

#define re0 register int

#define rec register char

#define rel register ll

#define gc getchar

#define pc putchar

#define p32 pc(' ')

#define pl puts("")

/*By Citrus*/

inline int read(){

  int x=0,f=1;char c=gc();

  for (;!isdigit(c);c=gc()) f^=c=='-';

  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');

  return f?x:-x;

  }

template <typename mitsuha>

inline bool read(mitsuha &x){

  x=0;int f=1;char c=gc();

  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';

  if (!~c) return 0;

  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');

  return x=f?x:-x,1;

  }

template <typename mitsuha>

inline int write(mitsuha x){

  if (!x) return pc(48);

  if (x<0) x=-x,pc('-');

  int bit[20],i,p=0;

  for (;x;x/=10) bit[++p]=x%10;

  for (i=p;i;--i) pc(bit[i]+48);

  return 0;

  }

inline char fuhao(){

  char c=gc();

  for (;isspace(c);c=gc());

  return c;

  }

}using namespace chtholly;

using namespace std;

int h=read(),w=read(),n=read(),ans[150][150],nx=1,ny=1;



int main(){

int i;

for (i=1;i<=n;++i){

  int x=read();

  for (;nx<=h&&x>0;){

    if (nx&1){

      for (int &k=ny;k<=w&&x-->0;++k) ans[nx][k]=i;

	  }

	else{

	  for (int &k=ny;k&&x-->0;--k) ans[nx][k]=i;

	  }

	if (!ny||ny>w){

	  ++nx;

	  if (!ny) ++ny;

	  if (ny>w) --ny;

	  } 

    }

  }

for (i=1;i<=h;++i,pl){

  for (int j=1;j<=w;++j,p32) write(ans[i][j]);

  }

}

// Faster C++ solution for the same problem (measured speedup: 5.153215826616274x):
#include <cstdio>

#include <queue>;

using namespace std;



int cols[10010];

int res[101][101];

int main()

{

	int row, col, n;

	scanf("%d %d %d", &row, &col, &n);

	for (int i = 1; i <= n; i++)

		scanf("%d", &cols[i]);

	int c = 1;

	for (int i = 0; i < row; i++)

	{

		if (i % 2 == 0)

		{

			for(int j = 0; j < col; j++)

			{ 

				if (cols[c] <= 0)

					c++;

				res[i][j] = c;

				cols[c]--;

			}



		}

		else

		{

			for (int j = col - 1; j >= 0; j--)

			{

				if (cols[c] <= 0)

					c++;

				res[i][j] = c;

				cols[c]--;

			}

		}

	}

	for (int i = 0; i < row; i++)

	{

		for (int j = 0; j < col; j++)

		{

			printf("%d", res[i][j]);

			if (j != col - 1)

				printf(" ");

		}

		printf("\n");

	}

	return 0;

}
// Slower C++ solution:
#include<iostream>

using namespace std;

int main()

{

    int h,w,n,b[10000+50],a[105][105],i,j,k;

    while(cin>>h>>w>>n)

    {

        k=0;

        for(i=0;i<n;i++)

        {

            cin>>b[i];

        }

        for(i=0;i<h;i++)

        {

            if(i%2==0)

            {

                for(j=0;j<w;j++)

                {

                    a[i][j]=k+1;

                    b[k]--;

                    if(b[k]==0)k++;

                }

            }

            else

            {

                for(j=w-1;j>=0;j--)

                {

                    a[i][j]=k+1;

                    b[k]--;

                    if(b[k]==0)k++;

                }

            }

        }

        for(i=0;i<h;i++)

            for(j=0;j<w;j++)

        {

            cout<<a[i][j];

            if(j==w-1)cout<<endl;

            else cout<<" ";

        }

    }

}


// Faster C++ solution for the same problem (measured speedup: 5.253591439004067x):
#include <cstdio>

#include <queue>;

using namespace std;



int cols[10010];

int res[101][101];

int main()

{

	int row, col, n;

	scanf("%d %d %d", &row, &col, &n);

	for (int i = 1; i <= n; i++)

		scanf("%d", &cols[i]);

	int c = 1;

	for (int i = 0; i < row; i++)

	{

		if (i % 2 == 0)

		{

			for(int j = 0; j < col; j++)

			{ 

				if (cols[c] <= 0)

					c++;

				res[i][j] = c;

				cols[c]--;

			}



		}

		else

		{

			for (int j = col - 1; j >= 0; j--)

			{

				if (cols[c] <= 0)

					c++;

				res[i][j] = c;

				cols[c]--;

			}

		}

	}

	for (int i = 0; i < row; i++)

	{

		for (int j = 0; j < col; j++)

		{

			printf("%d", res[i][j]);

			if (j != col - 1)

				printf(" ");

		}

		printf("\n");

	}

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<cstdio>

#include<cstring>

#include<cmath>

#include<algorithm>

#include<set>

using namespace std;

typedef long long LL;

const int INF=0x3f3f3f3f;

const int MAXN=1e5+5;

int a[MAXN];

int G[105][105];



int main()

{

    int h,w;

    while(scanf("%d%d",&h,&w)!=EOF)

    {

        int n;

       cin>>n;

        for(int i=1;i<=n;++i)

            scanf("%d",&a[i]);

        int cnt=1;

        for(int i=1;i<=h;++i)

        {

            if(i&1)

            {

                for(int j=1;j<=w;++j)

                {

                   if(a[cnt]>0) {G[i][j]=cnt;--a[cnt];}

                   else if(a[cnt]==0) {++cnt;G[i][j]=cnt;--a[cnt];}

                }

            }else

            {

                for(int j=w;j>=1;--j)

                {

                    if(a[cnt]>0) {G[i][j]=cnt;--a[cnt];}

                    else if(a[cnt]==0) {++cnt;G[i][j]=cnt;--a[cnt];}

                }

            }

        }

        for(int i=1;i<=h;++i)

        {

            for(int j=1;j<=w;++j)

            {

                if(j!=w) printf("%d ",G[i][j]);

                else printf("%d\n",G[i][j]);

            }

        }

    }

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.174084635664709x):
#include <cstdio>

#include <queue>;

using namespace std;



int cols[10010];

int res[101][101];

int main()

{

	int row, col, n;

	scanf("%d %d %d", &row, &col, &n);

	for (int i = 1; i <= n; i++)

		scanf("%d", &cols[i]);

	int c = 1;

	for (int i = 0; i < row; i++)

	{

		if (i % 2 == 0)

		{

			for(int j = 0; j < col; j++)

			{ 

				if (cols[c] <= 0)

					c++;

				res[i][j] = c;

				cols[c]--;

			}



		}

		else

		{

			for (int j = col - 1; j >= 0; j--)

			{

				if (cols[c] <= 0)

					c++;

				res[i][j] = c;

				cols[c]--;

			}

		}

	}

	for (int i = 0; i < row; i++)

	{

		for (int j = 0; j < col; j++)

		{

			printf("%d", res[i][j]);

			if (j != col - 1)

				printf(" ");

		}

		printf("\n");

	}

	return 0;

}
// Slower C++ solution:
//20-27行描述了填色标准，算法核心

//为什么这么移动？

//走S形

//在奇数行时，向右移动；在偶数行时，向左移动

//奇数行末尾，列数达到最大，向下移动；偶数行末尾，列数为1，向下移动

//用代码描述一下就是这样

//理论上还可以选择另一种S形状，即“竖过来”

#include <bits/stdc++.h>

using namespace std;

int r,c;//行数、列数

int n;//颜色总数

int x,y;//当前待着色点坐标

int ans[200][200];//答案记录表



int main()

{

    cin>>r>>c>>n;//分别输入行数、列数、颜色总数

    x=1,y=1;//初始坐标设置为（1，1）

    for(int i=1; i<=n; i++)

    {

        int cnt;//“当前颜色剩余着色块数”计数器

        cin>>cnt;

        while(cnt--)//对当前颜色一块一块着色

        {

            ans[x][y]=i;//着色

            if(y==c&&x%2==1)//如果该点在右边缘 且 在奇数行上

                y=c,x++;//下移一行，列数不变

            else if(y==1&&x%2==0)//如果该点在第一列上，且在偶数行上

                y=1,x++;//列数不变，下移一行

            else if(x&1)//如果在奇数行上

                y++;//右移一列

            else//否则左移一列

                y--;

        }

    }

    for(int i=1; i<=r; i++)

        for(int j=1; j<=c; j++)

            printf("%d%c",ans[i][j],j==c?'\n':' ');//在到达当前行最后一列前，每次空一格；到达后，换行；

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.190105238360451x):
#include <cstdio>

#include <queue>;

using namespace std;



int cols[10010];

int res[101][101];

int main()

{

	int row, col, n;

	scanf("%d %d %d", &row, &col, &n);

	for (int i = 1; i <= n; i++)

		scanf("%d", &cols[i]);

	int c = 1;

	for (int i = 0; i < row; i++)

	{

		if (i % 2 == 0)

		{

			for(int j = 0; j < col; j++)

			{ 

				if (cols[c] <= 0)

					c++;

				res[i][j] = c;

				cols[c]--;

			}



		}

		else

		{

			for (int j = col - 1; j >= 0; j--)

			{

				if (cols[c] <= 0)

					c++;

				res[i][j] = c;

				cols[c]--;

			}

		}

	}

	for (int i = 0; i < row; i++)

	{

		for (int j = 0; j < col; j++)

		{

			printf("%d", res[i][j]);

			if (j != col - 1)

				printf(" ");

		}

		printf("\n");

	}

	return 0;

}
// Slower C++ solution:
#include<cstdio>

#include<iostream>

#include<cstring>



using namespace std;



int a[10010];

int pic[110][110];



int main()

{

    int H,W,N;

    int i,j,k=0;

    memset(a,0,sizeof(a));

    scanf("%d%d%d",&H,&W,&N);

    for(i=0;i<N;++i)

    {

        scanf("%d",&a[i]);

    }

    for(i=0;i<H;++i)

    {

        if(i%2==0)

        {

            for(j=0;j<W;++j)

            {

                pic[i][j]=k+1;

                --a[k];

                if(a[k]==0)++k;

            }

        }

        if(i%2==1)

        {

            for(j=W-1;j>=0;--j)

            {

                pic[i][j]=k+1;

                --a[k];

                if(a[k]==0)++k;

            }

        }

    }

    for(i=0;i<H;++i)

    {

        for(j=0;j<W;++j)

        {

            printf("%d",pic[i][j]);

            if(j==W-1)printf("\n");

            else printf(" ");

        }

    }

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.386032977691562x):
#include <cstdio>

#include <queue>;

using namespace std;



int cols[10010];

int res[101][101];

int main()

{

	int row, col, n;

	scanf("%d %d %d", &row, &col, &n);

	for (int i = 1; i <= n; i++)

		scanf("%d", &cols[i]);

	int c = 1;

	for (int i = 0; i < row; i++)

	{

		if (i % 2 == 0)

		{

			for(int j = 0; j < col; j++)

			{ 

				if (cols[c] <= 0)

					c++;

				res[i][j] = c;

				cols[c]--;

			}



		}

		else

		{

			for (int j = col - 1; j >= 0; j--)

			{

				if (cols[c] <= 0)

					c++;

				res[i][j] = c;

				cols[c]--;

			}

		}

	}

	for (int i = 0; i < row; i++)

	{

		for (int j = 0; j < col; j++)

		{

			printf("%d", res[i][j]);

			if (j != col - 1)

				printf(" ");

		}

		printf("\n");

	}

	return 0;

}
// Slower C++ solution:
#include <cstdio>

#include <iostream>

using namespace std;

int xx[110][110];

int main(){

    int h,w,n,x=0;

    cin>>h>>w>>n;

    int a[n];

    for(int i=0;i<n;i++){

        cin>>a[i];

        for(int j=0;j<a[i];j++){

            if((x/w)%2==0) xx[x/w][x%w]=i+1;

            else xx[x/w][w-(x%w)-1]=i+1;

            x++;

        }

    }

    for(int i=0;i<h;i++){

        for(int j=0;j<w;j++){

            if(j==w-1) printf("%d\n",xx[i][j]);

            else printf("%d ",xx[i][j]);

        }

    }

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.188097028110581x):
#include <cstdio>

#include <queue>;

using namespace std;



int cols[10010];

int res[101][101];

int main()

{

	int row, col, n;

	scanf("%d %d %d", &row, &col, &n);

	for (int i = 1; i <= n; i++)

		scanf("%d", &cols[i]);

	int c = 1;

	for (int i = 0; i < row; i++)

	{

		if (i % 2 == 0)

		{

			for(int j = 0; j < col; j++)

			{ 

				if (cols[c] <= 0)

					c++;

				res[i][j] = c;

				cols[c]--;

			}



		}

		else

		{

			for (int j = col - 1; j >= 0; j--)

			{

				if (cols[c] <= 0)

					c++;

				res[i][j] = c;

				cols[c]--;

			}

		}

	}

	for (int i = 0; i < row; i++)

	{

		for (int j = 0; j < col; j++)

		{

			printf("%d", res[i][j]);

			if (j != col - 1)

				printf(" ");

		}

		printf("\n");

	}

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<cstdio>

#include<cstring>

#include<cmath>

#include<algorithm>

#include<set>



using namespace std;

typedef long long LL;

const int INF=0x3f3f3f3f;

int a[100005];

int G[105][105];



int main()

{

    int h,w;

    while(scanf("%d%d",&h,&w)!=EOF)

    {

        int n;

        scanf("%d",&n);

        for(int i=1;i<=n;++i)

            scanf("%d",&a[i]);

        int cnt=1;

        for(int i=1;i<=h;++i)

        {

            if(i&1)

            {

                for(int j=1;j<=w;++j)

                {

                   if(a[cnt]>0)

                        {G[i][j]=cnt;--a[cnt];}

                   else if(a[cnt]==0)

                   {++cnt;G[i][j]=cnt;--a[cnt];}

                }

            }

            else

            {

                for(int j=w;j>=1;--j)

                {

                    if(a[cnt]>0)

                        {G[i][j]=cnt;--a[cnt];}

                    else if(a[cnt]==0)

                     {++cnt;G[i][j]=cnt;--a[cnt];}

                }

            }

        }

        for(int i=1;i<=h;++i)

        {

            for(int j=1;j<=w;++j)

            {

                if(j!=w)

                    printf("%d ",G[i][j]);

                else printf("%d\n",G[i][j]);

            }

        }

    }

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.145588699345768x):
#include <cstdio>

#include <queue>;

using namespace std;



int cols[10010];

int res[101][101];

int main()

{

	int row, col, n;

	scanf("%d %d %d", &row, &col, &n);

	for (int i = 1; i <= n; i++)

		scanf("%d", &cols[i]);

	int c = 1;

	for (int i = 0; i < row; i++)

	{

		if (i % 2 == 0)

		{

			for(int j = 0; j < col; j++)

			{ 

				if (cols[c] <= 0)

					c++;

				res[i][j] = c;

				cols[c]--;

			}



		}

		else

		{

			for (int j = col - 1; j >= 0; j--)

			{

				if (cols[c] <= 0)

					c++;

				res[i][j] = c;

				cols[c]--;

			}

		}

	}

	for (int i = 0; i < row; i++)

	{

		for (int j = 0; j < col; j++)

		{

			printf("%d", res[i][j]);

			if (j != col - 1)

				printf(" ");

		}

		printf("\n");

	}

	return 0;

}
// Slower C++ solution:
#include<iostream>

using namespace std;

int ans[200][200];

int main(){

	int x,y;

	int dir=1;

	cin>>y>>x;

	int n;

	cin>>n;

	int posx=1,posy=1;

	for(int a=1;a<=n;++a){

	int xc;

	cin>>xc;

	for(int x1=1;x1<=xc;++x1){

	ans[posy][posx]=a;

	posx+=dir; 

	if(posx>x||posx==0){posy++;dir=-dir;if(posx==0)posx=1;else posx=x;}

	}

	

	}

	for(int a1=1;a1<=y;++a1){

	for(int a2=1;a2<=x;++a2){

	cout<<ans[a1][a2];

	if(a2==x)cout<<endl;else cout<<" ";

	}}

	

	

	

	

	return 0;} 

// Faster C++ solution for the same problem (measured speedup: 5.205824827644374x):
#include <cstdio>

#include <queue>;

using namespace std;



int cols[10010];

int res[101][101];

int main()

{

	int row, col, n;

	scanf("%d %d %d", &row, &col, &n);

	for (int i = 1; i <= n; i++)

		scanf("%d", &cols[i]);

	int c = 1;

	for (int i = 0; i < row; i++)

	{

		if (i % 2 == 0)

		{

			for(int j = 0; j < col; j++)

			{ 

				if (cols[c] <= 0)

					c++;

				res[i][j] = c;

				cols[c]--;

			}



		}

		else

		{

			for (int j = col - 1; j >= 0; j--)

			{

				if (cols[c] <= 0)

					c++;

				res[i][j] = c;

				cols[c]--;

			}

		}

	}

	for (int i = 0; i < row; i++)

	{

		for (int j = 0; j < col; j++)

		{

			printf("%d", res[i][j]);

			if (j != col - 1)

				printf(" ");

		}

		printf("\n");

	}

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<cstdio>

#include<cstring>

#include<cmath>

#include<algorithm>

#include<set>

using namespace std;

typedef long long LL;

const int INF=0x3f3f3f3f;

const int MAXN=1e5+5;

int a[MAXN];

int G[105][105];



int main()

{

    int h,w;

    while(scanf("%d%d",&h,&w)!=EOF)

    {

        int n;

        scanf("%d",&n);

        for(int i=1;i<=n;++i)

            scanf("%d",&a[i]);

        int cnt=1;

        for(int i=1;i<=h;++i)

        {

            if(i&1)

            {

                for(int j=1;j<=w;++j)

                {

                   if(a[cnt]>0) {G[i][j]=cnt;--a[cnt];}

                   else if(a[cnt]==0) {++cnt;G[i][j]=cnt;--a[cnt];}

                }

            }else

            {

                for(int j=w;j>=1;--j)

                {

                    if(a[cnt]>0) {G[i][j]=cnt;--a[cnt];}

                    else if(a[cnt]==0) {++cnt;G[i][j]=cnt;--a[cnt];}

                }

            }

        }

        for(int i=1;i<=h;++i)

        {

            for(int j=1;j<=w;++j)

            {

                if(j!=w) printf("%d ",G[i][j]);

                else printf("%d\n",G[i][j]);

            }

        }

    }

///for(int i = 0;)

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.145588699345768x):
#include <cstdio>

#include <queue>;

using namespace std;



int cols[10010];

int res[101][101];

int main()

{

	int row, col, n;

	scanf("%d %d %d", &row, &col, &n);

	for (int i = 1; i <= n; i++)

		scanf("%d", &cols[i]);

	int c = 1;

	for (int i = 0; i < row; i++)

	{

		if (i % 2 == 0)

		{

			for(int j = 0; j < col; j++)

			{ 

				if (cols[c] <= 0)

					c++;

				res[i][j] = c;

				cols[c]--;

			}



		}

		else

		{

			for (int j = col - 1; j >= 0; j--)

			{

				if (cols[c] <= 0)

					c++;

				res[i][j] = c;

				cols[c]--;

			}

		}

	}

	for (int i = 0; i < row; i++)

	{

		for (int j = 0; j < col; j++)

		{

			printf("%d", res[i][j]);

			if (j != col - 1)

				printf(" ");

		}

		printf("\n");

	}

	return 0;

}
// Slower C++ solution:
# include <bits/stdc++.h>



using namespace std;



int a[10010];

int g[110][110];



int main()

{

	int h , w;

	cin >> h >> w;

	int n;

	cin >> n;

	for(int i = 1; i <= n; i++)

	{

		cin >> a[i];

	}

	int x = 1;

	for(int i = 1; i <= h; i++)

	{

		if(i % 2 == 1)

		{

			for(int j = 1; j <= w; j++)

			{

				if(a[x] > 0)

				{

					g[i][j] = x;

					a[x]--;

				}

				else

				{

					x++;

					g[i][j] = x;

					a[x]--;

				}

			}

		}

		else

		{

			for(int j = w; j > 0; j--)

			{

				if(a[x] > 0)

				{

					g[i][j] = x;

					a[x]--;

				}

				else

				{

					x++;

					g[i][j] = x;

					a[x]--;

				}

			}

		}

	}

	for(int i = 1; i <= h; i++)

	{

		for(int j = 1; j <= w; j++)

		{

			cout << g[i][j] << " ";

		}

		cout << endl;

	}

	

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.206335241690503x):
#include <cstdio>

#include <queue>;

using namespace std;



int cols[10010];

int res[101][101];

int main()

{

	int row, col, n;

	scanf("%d %d %d", &row, &col, &n);

	for (int i = 1; i <= n; i++)

		scanf("%d", &cols[i]);

	int c = 1;

	for (int i = 0; i < row; i++)

	{

		if (i % 2 == 0)

		{

			for(int j = 0; j < col; j++)

			{ 

				if (cols[c] <= 0)

					c++;

				res[i][j] = c;

				cols[c]--;

			}



		}

		else

		{

			for (int j = col - 1; j >= 0; j--)

			{

				if (cols[c] <= 0)

					c++;

				res[i][j] = c;

				cols[c]--;

			}

		}

	}

	for (int i = 0; i < row; i++)

	{

		for (int j = 0; j < col; j++)

		{

			printf("%d", res[i][j]);

			if (j != col - 1)

				printf(" ");

		}

		printf("\n");

	}

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

typedef  long long ll ;

const int maxn=1e2+3,maxxn=1e4+2;

vector<pair<int,int> >v[maxn][maxn];

bool mark[maxn][maxn];

int ans[maxn][maxn];

pair<int,int>p[maxxn];

int c;

void dfs(int u,int k){

    mark[u][k]=1;

    if(p[c].first<=0)c++;

    ans[u][k]=p[c].second;

    p[c].first--;

    for(int i=0;i<v[u][k].size();i++){

        int x1=v[u][k][i].first,y1=v[u][k][i].second;

        if(!mark[x1][y1])dfs(x1,y1);

    }

}

int main() {

    int h,w,n;

    cin>>h>>w>>n;

    for(int i=0;i<n;i++){

        int x;

        cin>>x;

        p[i]=make_pair(x,i+1);

    }

    for(int i=1;i<=h;i++){

        for(int j=1;j<=w;j++){

            if(j+1<=w)v[i][j].push_back(make_pair(i,j+1));

            if(j-1>0)v[i][j].push_back(make_pair(i,j-1));

            if(i+1<=h)v[i][j].push_back(make_pair(i+1,j));

            if(i-1>0)v[i][j].push_back(make_pair(i-1,j));

        }

    }

    dfs(1,1);

    for(int i=1;i<=h;i++){

        for(int j=1;j<=w;j++)cout<<ans[i][j]<<" ";

        cout<<endl;

    }

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.2785056301088258x):
#include<iostream>

#include<cstdio>

#include<iomanip>

#include<algorithm>

#include<vector>

#include<set>

#include<list>

#include<queue>

#include<deque>

#include<unordered_map>

#include<map>

#include<string>

#include<cstring>

#include<stack>

#include<cmath>



#define vint vector<int>

#define vstr vector<string>

#define vll vector<long long>

#define ll long long

#define pf printf

#define sf scanf

#define sfd(n) scanf("%d", &n)

#define sflf(n) scanf("%lf", &n)

#define sfll(n) scanf("%lld", &n)

#define pfd(n) printf("%d", n)

#define pflf(n) printf("%lf", n)

#define pfll(n) printf("%lld", n)

#define pft	printf("\t")

#define pfn printf("\n")

#define pfk printf(" ")

#define PI 3.1415926

#define MAX 100000

#define M 1e18



using namespace std;



int main() {

	int h, w;

	int n;

	sfd(h);

	sfd(w);

	sfd(n);

	int num;

	int** ans = new int*[h];

	for( int i=0; i<h; i++ ) {

		ans[i] = new int[w];

	}

	bool f = false;

	int l = 0, k = 0;

	for( int i=1; i<=n; i++ ) {

		sfd(num);

		for( int j=0; j<num; j++ ) {

			ans[l][k] = i;

//			cout << "l = " << l << "    k = " << k << endl;

			if( l%2==0 ) {

				k++;

			}else {

				k--;

			}

			if( k>=w ) {

				k--;

				l++;

			}

			if( k<0 ) {

				k++;

				l++;

			}

			if( l>=h ) {

				f = true;

				break;

			}

		}

		if( f ) {

			break;

		}

	}

	for( int i=0; i<h; i++ ) {

		for( int j=0; j<w; j++ ) {

			pfd(ans[i][j]);

			if( j<w-1 ) {

				pfk;

			}

		}

		pfn;

	}



	return 0;

}