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

int main(int argc, char **argv) {
	int n = atoi(argv[1]) / 2;
	srand(atoi(argv[2]));
	int m = n + rand() % 1000;
	if (m > n * n) m = n * n;
	
	bool matrix[9][9];
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			matrix[i][j] = false;
		}
	}

	int mix[18];
	for (int i = 0; i < 2 * n; i++) {
		mix[i] = i + 1;
	}
	std::random_shuffle(mix, mix + 2 * n);

	printf("%d %d\n", 2 * n, m);

	for (int i = 0; i < n; i++) {
		int j = rand() % n;
		matrix[i][j] = true;
		printf("%d %d\n", mix[i], mix[n + j]);
		m--;
	}
	while (m > 0) {
		m--;
		int i, j;
		do {
			i = rand() % n;
			j = rand() % n;
		} while (matrix[i][j]);
		matrix[i][j] = true;
		printf("%d %d\n", mix[i], mix[n + j]);
	}
	return 0;
}