public class Test08 {
	public static void main(String[] args) {
		int k, i, j, n;
		int a[][] = new int[5][5];
		k = 0;
		i = j = -1;
		n = -1;
		while(true)
		{
			i++;
			n *= -1;
			if (i > 4)
				break;
			while(true)
			{
				j += n;
				k++;
				a[i][j] = k;
				if (i % 2 == 0)
				{
					if (j < 4)
						continue;
					else
					{
						j++;
						break;
					}
				}
				else
				{
					if (j > 0)
						continue;
					else
					{
						j = -1;
						break;
					}
				}
			}
		}
		for (int x = 0; x <= 4; x++)
		{
			for (int y = 0; y <= 4; y++)
				System.out.printf("%3d", a[x][y]);
			System.out.printf("\n");
		}
	}
}
