#include <cstdio>
#include <algorithm>
#include <set>
using namespace std;
#include "random.h"
#define forn(i, n) for (int i = 0; i < (int)(n); i++)
int main( int argc, char *argv[] )
{
if (argc < 4)
{
puts("Usage: <seed for random> <n> <m>");
puts(" [seed == 0] => Time()");
return 1;
}
int seed = atoi(argv[1]);
int n = atoi(argv[2]);
int m = atoi(argv[3]);
if (seed == 0)
seed = Time(), fprintf(stderr, "seed = %d\n", seed);
initrand(seed);
printf("%d %d\n", n, m);
typedef pair <int, int> pii;
set <pii> s;
forn(i, m)
{
int a, b;
do
{
a = R(1, n);
b = R(1, n);
} while (a == b || s.count(pii(min(a, b), max(a, b))));
s.insert(pii(min(a, b), max(a, b)));
printf("%d %d\n", a, b);
}
return 0;
}