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

bool matrix[18][18];

int main(int argc, char **argv) {
	int n = atoi(argv[1]);
	int m = atoi(argv[2]);
	srand(atoi(argv[3]));
	printf("%d %d\n", n, m);
	for (int i = 0; i < m; i++) {
		int s, e;
		do {
			s = rand() % n;
			e = rand() % n;
		} while (matrix[s][e]);
		matrix[s][e] = matrix[e][s] = true;
		printf("%d %d\n", s + 1, e + 1);
	}
	return 0;
}