#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;


int main() {
	int n, p; // テ、ツクツ甘ゥツ卍?50 50
	int kouho[50];

	//10^6
	while(cin >> n >> p && n && p)
	{
		//cout << n << " " << p << endl;
		rep(i,50){kouho[i]=0;}
		int box = p;
		int index=0;
		while(true)
		{
			if(index >= n){ index=0; }	
			if(box>0){ 
				box--; kouho[index]++;
			}else{
				box=kouho[index]; kouho[index]=0;
				bool flag=false;
				/*
				rep(i,n){if(kouho[i]!=0){flag=false;}}
				if(flag){cout << index << endl; break;}
				*/
				rep(i,n){
					if(kouho[i]==p){flag=true;}	
				}
				if(flag){
					if(index==0){index=n;}
					cout << (index-1)%n << endl; break;
				}
			}
			index++;
		}
	}
	return 0;
}
#include <bits/stdc++.h>
using namespace std;

int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	if(n&1)for(int i=1;i<=m;i++){
		printf("%d %d\n",i,n-i);
	}
	else{
		int cnt = 0;
		for(int i=1;cnt<m&&i<=n/4;cnt++,i++){
			printf("%d %d\n",i,n/2-i+1);
		}
		int cur = 1;
		for(int i=n/2+1;cnt<m;i++,cnt++){
			printf("%d %d\n",i,n-cur);
			cur++;
		}
	}
}
