#include<stdio.h>
#include<stdlib.h>

int main(int argc, char * argv[]) {
	int table1[2][5] = {};
	int table2[3][5] = {};
	int table3[5][5] = {};

	for (int i = 0; i < 5; i++) {
		table1[0][i] = i+1;
		table1[1][i] = i+1;
	}

	for (int i = 0; i < 15; i++) {
		table2[i/5][i%5] = i+1;
	}

	for (int y = 0; y < 5; y++) {
		for (int x = 0; x < 5; x++) {
			if (y < x) table3[x][y] = y+1;
			else table3[x][y] = 0;
		}
	}

	for (int l = 0; l < 5; l++) {
		for (int c = 0; c < 17; c++) {
			if (l < 1) {
				if (c < 5) printf("%2d ", table1[l][c]);
				else if (c > 5 && c < 11) printf("%2d ", table2[l][c-6]);
				else if (c > 11) printf("%2d ", table3[l][c-12]);
				else printf("   ");
			} else if (l < 2) {
				if (c > 5 && c < 11) printf("%2d ", table2[l][c-6]);
				else if (c > 11) printf("%2d ", table3[l][c-12]);
				else printf("   ");
			} else {
				if (c > 11) printf("%2d ", table3[l][c-12]);
				else printf("   ");
			}
		}
		printf("\n");
	}
	
	return EXIT_SUCCESS;
}

