unittest
{
	assert( [ "2 2", "3", "2 1 1" ].parse.expand.solve == "1 1\n3 2" );
	assert( [ "3 5", "5", "1 2 3 4 5" ].parse.expand.solve == "1 2 2 3 3\n4 4 4 4 3\n5 5 5 5 5" );
	assert( [ "1 1", "1", "1" ].parse.expand.solve == "1" );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto hw = input.front.split.to!( long[] );
	input.popFront;
	input.popFront;
	auto as = input.front.split.to!( long[] );
	return tuple( hw[ 0 ], hw[ 1 ], as );
}

auto solve( long h, long w, long[] as )
{
	auto ansss = new long[][]( h, w );
	auto c = 1L;
	auto hi = 0L;
	auto wi = 0L;
	auto wd = 1L;
	while( !as.empty )
	{
		// 色を塗る
		ansss[ hi ][ wi ] = c;
		as.front--;
		if( as.front == 0 )
		{
			as.popFront;
			c++;
		}
		
		// 移動して、端まで来たら一つ下に降りて向きを変える
		wi += wd;
		if( w <= wi )
		{
			hi++;
			wi = w - 1;
			wd = -1;
		}
		else if( wi < 0 )
		{
			hi++;
			wi = 0;
			wd = 1;
		}
	}
	return ansss.map!( ( x ) => x.to!( string[] ).join( " " ) ).join( "\n" );
}
