import java.util.ArrayList;
import java.util.Random;


public class IrrigationTCGen {
	
	private static class Source
	{
		public int row;
		public int col;
		public int capacity;
		
		public Source(int row, int col)
		{
			this.row = row;
			this.col = col;
			this.capacity = 0;
		}
	}
	
	private static class Point
	{
		public int x,y;
		
		public Point(int x, int y)
		{
			this.x = x;
			this.y = y;
		}
	}
	
	static int[][] field;
	
	static int dir[][] = { {1,0}, {0,1}, {-1,0}, {0,-1} };
	
	public static void main(String[] args)
	{
		int M = Integer.parseInt(args[0]);
		int N = Integer.parseInt(args[1]);
		
		Random rand = new Random(System.nanoTime());
		boolean found = false;
		
		while (!found)
		{
			field = new int[M][N]; //M == y, N == x
			
			int capacityAvail = N*M;
			int sourceCount = 0;
			
			ArrayList<Source> sourceList = new ArrayList<Source>(200);
			ArrayList<Point> avail = new ArrayList<Point>(N*M);
			
			for (int i = 0; i < M; i++)
			{
				for (int j = 0; j < N; j++)
				{
					avail.add(new Point(j,i));
				}
			}
			
			while (capacityAvail > 0)
			{
				int row = -1;
				int col = -1;
				
				do
				{
					int index = rand.nextInt(avail.size());
					Point p = avail.get(index);
					avail.remove(index);
					row = p.y;
					col = p.x;
				} while (field[row][col] != 0);
				
				sourceCount++;
				field[row][col] = sourceCount;
				capacityAvail--;
				
				Source source = new Source(row, col);
				
				for (int i = 0; i < 4; i++)
				{
					int tempRow = row + dir[i][0];
					int tempCol = col + dir[i][1];
					while (0 <= tempRow && tempRow < M && 0 <= tempCol && tempCol < N && field[tempRow][tempCol] == 0)
					{
						field[tempRow][tempCol] = sourceCount;
						source.capacity++;
						capacityAvail--;
						tempRow += dir[i][0];
						tempCol += dir[i][1];
					}
				}
				sourceList.add(source);
			}
			
			if (sourceList.size() <= 200) found = true;
			else continue;
			
			if (found)
			{
				System.out.printf("%d %d %d\n", N, M, sourceList.size());
				for (Source s : sourceList)
				{
					System.out.printf("%d %d %d\n", s.col+1, s.row+1, s.capacity);
				}
				System.out.printf("0\n");
			}
			
			/*for (int[] row : field)
			{
				for (int col : row)
				{
					System.out.printf("%02X ", col);
				}
				System.out.println();
			}*/
		}
	}
}
