#include <cstdio>
#include <cassert>
#include <cstdlib>
#include <algorithm>

using namespace std;

#define forn(i, n) for (int i = 0; i < (int)(n); i++)

unsigned R()
{
  return (rand() << 15) + rand();
}

int main( int argc, char *argv[] )
{
  assert(argc >= 3);
  int n = atoi(argv[1]);
  int m = atoi(argv[2]); // 2 * m
  int *a = new int[2 * m];

  forn(i, m)
    a[i + m] = a[i] = R() % n;

  int bad, cnt = 0;
  do
  {
    bad = 0;
    random_shuffle(a, a + 2 * m);
    forn(i, m - 1)
      if (a[2 * i] == a[2 * i + 1])
        bad = 1, i = m;
    cnt++;
  } while (bad);

  fprintf(stderr, "cnt = %d\n", cnt);

  printf("%d %d\n", n, m);
  forn(i, m)
    printf("%d %d\n", a[2 * i] + 1, a[2 * i + 1] + 1);
  return 0;
}