#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;

#ifndef ONLINE_JUDGE
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }
typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
	template<class S,class T>
	ostream &operator <<(ostream& out,const pair<S,T>& a){
		out<<'('<<a.fr<<','<<a.sc<<')';
		return out;
	}
}
const int INF=5e8;
int n,m;
int dp1[2][2005],dp2[2][2005];

int pud[100005],ispud[200005],pudsum[200005];
int mark[200005],marksum[200005];
int con[200005];
int MX=200003;
int main(){

	MX=10;
	cin>>n>>m;

	int st=MX;
	REP(i,n){
		int a;scanf("%d",&a);
		ispud[a]=1;
		pud[i]=a;
		chmin(st,a);
	}

	REP(i,MX){
		pudsum[i+1]=pudsum[i]+ispud[i];
		marksum[i+1]=mark[i]+marksum[i];
	}

	sort(pud,pud+n);
	REP(i,m){
		int a;scanf("%d",&a);
		mark[a]=1;
	}
	REP(i,MX) if(ispud[i] && ispud[i+1]) con[i]=1;
	REP(k,2) REP(j,2005) dp1[k][j]=dp2[k][j]=INF;
	int cur=0,nxt=1;
	dp1[cur][0]=0;

	int ans=0;
	for(int i=st;i<MX;++i){
		dump(m);
		REP(j,m+1) if(dp2[cur][j]<=n){
			if(!con[i]) chmin(dp1[cur][j],dp2[cur][j]);
		}
		REP(j,m+1) if(dp1[cur][j]<=n){
			dump(i);dump(j);dump(dp1[cur][j]);
			chmax(ans,j);
			chmin(dp1[nxt][j],dp1[cur][j]);

			if(ispud[i]){
				int sum=pudsum[i+1]-dp1[cur][j];
				int nmark=marksum[i+1]-marksum[i+1-sum];
				dump(sum);dump(nmark);
				chmax(nmark,0);
				chmin(dp2[cur][j+nmark],pudsum[i+1]);
			}
		}
		REP(j,m+1) if(dp2[cur][j]<=n){
			dump(i);dump(j);dump(dp2[cur][j]);
			chmax(ans,j);
			chmin(dp2[nxt][j+mark[i+1]],dp2[cur][j]+1);
			if(!con[i]) chmin(dp1[cur][j],dp2[cur][j]);
		}
		swap(cur,nxt);
		REP(j,m+1) dp1[nxt][j]=dp2[nxt][j]=INF;
	}

	cout<<ans<<endl;

	return 0;
}


#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;

#ifndef ONLINE_JUDGE
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }
typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
	template<class S,class T>
	ostream &operator <<(ostream& out,const pair<S,T>& a){
		out<<'('<<a.fr<<','<<a.sc<<')';
		return out;
	}
}
const int INF=5e8;
int n,m;
int dp1[2][2005],dp2[2][2005];

int pud[100005],ispud[200005],pudsum[200005];
int mark[200005],marksum[200005];
int con[200005];
int MX=200003;
int main(){
	MX=11;
	cin>>n>>m;

	int st=MX;
	REP(i,n){
		int a;scanf("%d",&a);
		ispud[a]=1;
		pud[i]=a;
		chmin(st,a);
	}

	sort(pud,pud+n);
	REP(i,m){
		int a;scanf("%d",&a);
		mark[a]=1;
	}

	REP(i,MX){
		pudsum[i+1]=pudsum[i]+ispud[i];
		marksum[i+1]=mark[i]+marksum[i];
	}
	REP(i,MX) if(ispud[i] && ispud[i+1]) con[i]=1;
	REP(k,2) REP(j,2005) dp1[k][j]=dp2[k][j]=INF;
	int cur=0,nxt=1;
	dp1[cur][0]=0;

	int ans=0;
	for(int i=st;i<MX;++i){
		dump(m);
		REP(j,m+1) if(dp1[cur][j]<=n){
			dump(i);dump(j);dump(dp1[cur][j]);
			chmax(ans,j);
			chmin(dp1[nxt][j],dp1[cur][j]);

			if(ispud[i]){
				int sum=pudsum[i+1]-dp1[cur][j];
				dump(marksum[i+1]);dump(marksum[i+1-sum]);
				int nmark=marksum[i+1]-marksum[i+1-sum];
				dump(sum);dump(nmark);
				chmax(nmark,0);
				chmin(dp2[cur][j+nmark],pudsum[i+1]);
			}
		}
		REP(j,m+1) if(dp2[cur][j]<=n){
			dump(i);dump(j);dump(dp2[cur][j]);
			chmax(ans,j);
			chmin(dp2[nxt][j+mark[i+1]],dp2[cur][j]+1);
			if(!con[pud[dp2[cur][j]-1]]) chmin(dp1[nxt][j],dp2[cur][j]);
		}
		swap(cur,nxt);
		REP(j,m+1) dp1[nxt][j]=dp2[nxt][j]=INF;
	}

	cout<<ans<<endl;

	return 0;
}


#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;

#ifndef ONLINE_JUDGE
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }
typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
	template<class S,class T>
	ostream &operator <<(ostream& out,const pair<S,T>& a){
		out<<'('<<a.fr<<','<<a.sc<<')';
		return out;
	}
}
const int INF=5e8;
int n,m;
int dp1[2][2005],dp2[2][2005];

int pud[100005],ispud[200005],pudsum[200005];
int mark[200005],marksum[200005];
int con[200005];
int MX=200003;
int main(){
	cin>>n>>m;

	int st=MX;
	REP(i,n){
		int a;scanf("%d",&a);
		ispud[a]=1;
		pud[i]=a;
		chmin(st,a);
	}

	sort(pud,pud+n);
	REP(i,m){
		int a;scanf("%d",&a);
		mark[a]=1;
	}

	REP(i,MX){
		pudsum[i+1]=pudsum[i]+ispud[i];
		marksum[i+1]=mark[i]+marksum[i];
	}
	REP(i,MX) if(ispud[i] && ispud[i+1]) con[i]=1;
	REP(k,2) REP(j,2005) dp1[k][j]=dp2[k][j]=INF;
	int cur=0,nxt=1;
	dp1[cur][0]=0;

	int ans=0;
	for(int i=st;i<MX;++i){
		dump(m);
		REP(j,m+1) if(dp1[cur][j]<=n){
			dump(i);dump(j);dump(dp1[cur][j]);
			chmax(ans,j);
			chmin(dp1[nxt][j],dp1[cur][j]);

			if(ispud[i]){
				int sum=pudsum[i+1]-dp1[cur][j];
				dump(marksum[i+1]);dump(marksum[i+1-sum]);
				int nmark=marksum[i+1]-marksum[i+1-sum];
				dump(sum);dump(nmark);
				chmax(nmark,0);
				chmin(dp2[cur][j+nmark],pudsum[i+1]);
			}
		}
		REP(j,m+1) if(dp2[cur][j]<=n){
			dump(i);dump(j);dump(dp2[cur][j]);
			chmax(ans,j);
			chmin(dp2[nxt][j+mark[i+1]],dp2[cur][j]+1);
			if(!con[pud[dp2[cur][j]-1]]) chmin(dp1[nxt][j],dp2[cur][j]+1);
		}
		swap(cur,nxt);
		REP(j,m+1) dp1[nxt][j]=dp2[nxt][j]=INF;
	}

	cout<<ans<<endl;

	return 0;
}


#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;

#ifndef ONLINE_JUDGE
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }
typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
	template<class S,class T>
	ostream &operator <<(ostream& out,const pair<S,T>& a){
		out<<'('<<a.fr<<','<<a.sc<<')';
		return out;
	}
}
const int INF=5e8;
int n,m;
int dp1[2][2005],dp2[2][2005];

int pud[100005],ispud[200005],pudsum[200005];
int mark[200005],marksum[200005];
int con[200005];
int MX=200003;
int main(){
	cin>>n>>m;

	int st=MX;
	REP(i,n){
		int a;scanf("%d",&a);
		ispud[a]=1;
		pud[i]=a;
		chmin(st,a);
	}

	sort(pud,pud+n);
	REP(i,m){
		int a;scanf("%d",&a);
		mark[a]=1;
	}

	REP(i,MX){
		pudsum[i+1]=pudsum[i]+ispud[i];
		marksum[i+1]=mark[i]+marksum[i];
	}
	REP(i,MX) if(ispud[i] && ispud[i+1]) con[i]=1;
	REP(k,2) REP(j,2005) dp1[k][j]=dp2[k][j]=INF;
	int cur=0,nxt=1;
	dp1[cur][0]=0;

	int ans=0;
	for(int i=st;i<MX;++i){
		dump(m);
		REP(j,m+1) if(dp1[cur][j]<=n){
			dump(i);dump(j);dump(dp1[cur][j]);
			chmax(ans,j);
			chmin(dp1[nxt][j],dp1[cur][j]);

			if(ispud[i]){
				int sum=pudsum[i+1]-dp1[cur][j];
				dump(marksum[i+1]);dump(marksum[i+1-sum]);
				int nmark=marksum[i+1]-marksum[i+1-sum];
				dump(sum);dump(nmark);
				chmax(nmark,0);
				chmin(dp2[cur][j+nmark],pudsum[i+1]);
			}
		}
		REP(j,m+1) if(dp2[cur][j]<=n){
			dump(i);dump(j);dump(dp2[cur][j]);
			chmax(ans,j);
			chmin(dp2[nxt][j+mark[i+1]],dp2[cur][j]+1);
			if(!con[pud[dp2[cur][j]-1]]) chmin(dp1[nxt][j],dp2[cur][j]);
		}

		swap(cur,nxt);
		REP(j,m+1) dp1[nxt][j]=dp2[nxt][j]=INF;
	}

	cout<<ans<<endl;

	return 0;
}


#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;

#ifndef ONLINE_JUDGE
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }
typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
	template<class S,class T>
	ostream &operator <<(ostream& out,const pair<S,T>& a){
		out<<'('<<a.fr<<','<<a.sc<<')';
		return out;
	}
}
const int INF=5e8;
int n,m;
int dp1[2][2005],dp2[2][2005];

int pud[100005],ispud[200005],pudsum[200005];
int mark[200005],marksum[200005];
int con[200005];
int MX=200003;
int main(){

	cin>>n>>m;

	int st=MX;
	REP(i,n){
		int a;scanf("%d",&a);
		ispud[a]=1;
		pud[i]=a;
		chmin(st,a);
	}

	sort(pud,pud+n);
	REP(i,m){
		int a;scanf("%d",&a);
		mark[a]=1;
	}

	REP(i,MX){
		pudsum[i+1]=pudsum[i]+ispud[i];
		marksum[i+1]=mark[i]+marksum[i];
	}
	REP(i,MX) if(ispud[i] && ispud[i+1]) con[i]=1;
	REP(k,2) REP(j,2005) dp1[k][j]=dp2[k][j]=INF;
	int cur=0,nxt=1;
	dp1[cur][0]=0;

	int ans=0;
	for(int i=st;i<MX;++i){
		dump(m);
		REP(j,m+1) if(dp2[cur][j]<=n){
			if(!con[pud[dp2[cur][j]-1]]) chmin(dp1[cur][j],dp2[cur][j]);
		}
		REP(j,m+1) if(dp1[cur][j]<=n){
			dump(i);dump(j);dump(dp1[cur][j]);
			chmax(ans,j);
			chmin(dp1[nxt][j],dp1[cur][j]);

			if(ispud[i]){
				int sum=pudsum[i+1]-dp1[cur][j];
				dump(marksum[i+1]);dump(marksum[i+1-sum]);
				int nmark=marksum[i+1]-marksum[i+1-sum];
				dump(sum);dump(nmark);
				chmax(nmark,0);
				chmin(dp2[cur][j+nmark],pudsum[i+1]);
			}
		}
		REP(j,m+1) if(dp2[cur][j]<=n){
			dump(i);dump(j);dump(dp2[cur][j]);
			chmax(ans,j);
			chmin(dp2[nxt][j+mark[i+1]],dp2[cur][j]+1);
		}
		swap(cur,nxt);
		REP(j,m+1) dp1[nxt][j]=dp2[nxt][j]=INF;
	}

	cout<<ans<<endl;

	return 0;
}


#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;

#ifndef ONLINE_JUDGE
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }
typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
	template<class S,class T>
	ostream &operator <<(ostream& out,const pair<S,T>& a){
		out<<'('<<a.fr<<','<<a.sc<<')';
		return out;
	}
}
const int INF=5e8;
int n,m;
int dp1[2][2005],dp2[2][2005];

int pud[100005],ispud[200005],pudsum[200005];
int mark[200005],marksum[200005];
int con[200005];
int MX=200003;
int main(){
	cin>>n>>m;

	int st=MX;
	REP(i,n){
		int a;scanf("%d",&a);
		ispud[a]=1;
		pud[i]=a;
		chmin(st,a);
	}

	sort(pud,pud+n);
	REP(i,m){
		int a;scanf("%d",&a);
		mark[a]=1;
	}

	REP(i,MX){
		pudsum[i+1]=pudsum[i]+ispud[i];
		marksum[i+1]=mark[i]+marksum[i];
	}
	REP(i,MX) if(ispud[i] && ispud[i+1]) con[i]=1;
	REP(k,2) REP(j,2005) dp1[k][j]=dp2[k][j]=INF;
	int cur=0,nxt=1;
	dp1[cur][0]=0;

	int ans=0;
	for(int i=st;i<MX;++i){
		dump(m);
		REP(j,m+1) if(dp1[cur][j]<=n){
			dump(i);dump(j);dump(dp1[cur][j]);
			chmax(ans,j);
			chmin(dp1[nxt][j],dp1[cur][j]);

			if(ispud[i]){
				int sum=pudsum[i+1]-dp1[cur][j];
				dump(marksum[i+1]);dump(marksum[i+1-sum]);
				int nmark=marksum[i+1]-marksum[i+1-sum];
				dump(sum);dump(nmark);
				chmax(nmark,0);
				chmin(dp2[cur][j+nmark],pudsum[i+1]);
			}
		}
		REP(j,m+1) if(dp2[cur][j]<=n){
			dump(i);dump(j);dump(dp2[cur][j]);
			chmax(ans,j);
			chmin(dp2[nxt][j+mark[i+1]],dp2[cur][j]+1);
			if(!con[pud[dp2[cur][j]]]) chmin(dp1[nxt][j],dp2[cur][j]+1);
		}
		swap(cur,nxt);
		REP(j,m+1) dp1[nxt][j]=dp2[nxt][j]=INF;
	}

	cout<<ans<<endl;

	return 0;
}


#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;

#ifndef ONLINE_JUDGE
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }
typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
	template<class S,class T>
	ostream &operator <<(ostream& out,const pair<S,T>& a){
		out<<'('<<a.fr<<','<<a.sc<<')';
		return out;
	}
}
const int INF=5e8;
int n,m;
int dp1[2][2005],dp2[2][2005];

int pud[100005],ispud[200005],pudsum[200005];
int mark[200005],marksum[200005];
int con[200005];
int MX=200003;
int main(){

	MX=10;
	cin>>n>>m;

	int st=MX;
	REP(i,n){
		int a;scanf("%d",&a);
		ispud[a]=1;
		pud[i]=a;
		chmin(st,a);
	}

	sort(pud,pud+n);
	REP(i,m){
		int a;scanf("%d",&a);
		mark[a]=1;
	}

	REP(i,MX){
		pudsum[i+1]=pudsum[i]+ispud[i];
		marksum[i+1]=mark[i]+marksum[i];
	}
	REP(i,MX) if(ispud[i] && ispud[i+1]) con[i]=1;
	REP(k,2) REP(j,2005) dp1[k][j]=dp2[k][j]=INF;
	int cur=0,nxt=1;
	dp1[cur][0]=0;

	int ans=0;
	for(int i=st;i<MX;++i){
		dump(m);
		REP(j,m+1) if(dp2[cur][j]<=n){
			if(!con[pud[dp2[cur][j]-1]]) chmin(dp1[cur][j],dp2[cur][j]);
		}
		REP(j,m+1) if(dp1[cur][j]<=n){
			dump(i);dump(j);dump(dp1[cur][j]);
			chmax(ans,j);
			chmin(dp1[nxt][j],dp1[cur][j]);

			if(ispud[i]){
				int sum=pudsum[i+1]-dp1[cur][j];
				dump(marksum[i+1]);dump(marksum[i+1-sum]);
				int nmark=marksum[i+1]-marksum[i+1-sum];
				dump(sum);dump(nmark);
				chmax(nmark,0);
				chmin(dp2[cur][j+nmark],pudsum[i+1]);
			}
		}
		REP(j,m+1) if(dp2[cur][j]<=n){
			dump(i);dump(j);dump(dp2[cur][j]);
			chmax(ans,j);
			chmin(dp2[nxt][j+mark[i+1]],dp2[cur][j]+1);
		}
		swap(cur,nxt);
		REP(j,m+1) dp1[nxt][j]=dp2[nxt][j]=INF;
	}

	cout<<ans<<endl;

	return 0;
}


#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;

#ifndef ONLINE_JUDGE
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }
typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
	template<class S,class T>
	ostream &operator <<(ostream& out,const pair<S,T>& a){
		out<<'('<<a.fr<<','<<a.sc<<')';
		return out;
	}
}
const int INF=5e8;
int n,m;
int dp1[2][2005],dp2[2][2005];

int pud[100005],ispud[200005],pudsum[200005];
int mark[200005],marksum[200005];
int con[200005];
int MX=200003;
int main(){

	MX=10;
	cin>>n>>m;

	int st=MX;
	REP(i,n){
		int a;scanf("%d",&a);
		ispud[a]=1;
		pud[i]=a;
		chmin(st,a);
	}

	sort(pud,pud+n);
	REP(i,m){
		int a;scanf("%d",&a);
		mark[a]=1;
	}

	REP(i,MX){
		pudsum[i+1]=pudsum[i]+ispud[i];
		marksum[i+1]=mark[i]+marksum[i];
	}
	REP(i,MX) if(ispud[i] && ispud[i+1]) con[i]=1;
	REP(k,2) REP(j,2005) dp1[k][j]=dp2[k][j]=INF;
	int cur=0,nxt=1;
	dp1[cur][0]=0;

	int ans=0;
	for(int i=st;i<MX;++i){
		dump(m);
		REP(j,m+1) if(dp2[cur][j]<=n){
			if(!con[pud[dp2[cur][j]-1]]) chmin(dp1[cur][j],dp2[cur][j]);
		}
		REP(j,m+1) if(dp1[cur][j]<=n){
			dump(i);dump(j);dump(dp1[cur][j]);
			chmax(ans,j);
			chmin(dp1[nxt][j],dp1[cur][j]);

			if(ispud[i]){
				int sum=pudsum[i+1]-dp1[cur][j];
				dump(marksum[i+1]);dump(marksum[i+1-sum]);
				int nmark=marksum[i+1]-marksum[i+1-sum];
				dump(sum);dump(nmark);
				chmax(nmark,0);
				chmin(dp2[cur][j+nmark],pudsum[i+1]);
			}
		}
		REP(j,m+1) if(dp2[cur][j]<=n){
			dump(i);dump(j);dump(dp2[cur][j]);
			chmax(ans,j);
			chmin(dp2[nxt][j+mark[i+1]],dp2[cur][j]+1);
			if(!con[i]) chmin(dp1[cur][j],dp2[cur][j]);
		}
		swap(cur,nxt);
		REP(j,m+1) dp1[nxt][j]=dp2[nxt][j]=INF;
	}

	cout<<ans<<endl;

	return 0;
}


#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;

#ifndef ONLINE_JUDGE
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }
typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
	template<class S,class T>
	ostream &operator <<(ostream& out,const pair<S,T>& a){
		out<<'('<<a.fr<<','<<a.sc<<')';
		return out;
	}
}
const int INF=5e8;
int n,m;
int dp1[2][2005],dp2[2][2005];

int pud[100005],ispud[200005],pudsum[200005];
int mark[200005],marksum[200005];
int con[200005];
int MX=200003;
int main(){
	cin>>n>>m;

	int st=MX;
	REP(i,n){
		int a;scanf("%d",&a);
		ispud[a]=1;
		pud[i]=a;
		chmin(st,a);
	}

	sort(pud,pud+n);
	REP(i,m){
		int a;scanf("%d",&a);
		mark[a]=1;
	}

	REP(i,MX){
		pudsum[i+1]=pudsum[i]+ispud[i];
		marksum[i+1]=mark[i]+marksum[i];
	}
	REP(i,MX) if(ispud[i] && ispud[i+1]) con[i]=1;
	REP(k,2) REP(j,2005) dp1[k][j]=dp2[k][j]=INF;
	int cur=0,nxt=1;
	dp1[cur][0]=0;

	int ans=0;
	for(int i=st;i<MX;++i){
		REP(j,m+1) if(dp1[cur][j]<=n){
			chmax(ans,j);
			chmin(dp1[nxt][j],dp1[cur][j]);

			if(ispud[i]){
				int sum=pudsum[i+1]-dp1[cur][j];
				if(sum<=0) continue;
				int nmark=marksum[i+1]-marksum[i+1-sum];
				chmin(dp2[cur][j+nmark],pudsum[i+1]);
			}
		}
		REP(j,m+1) if(dp2[cur][j]<=n){
			chmax(ans,j);
			chmin(dp2[nxt][j+mark[i+1]],dp2[cur][j]+1);
			if(!con[pud[dp2[cur][j]-1]]) chmin(dp1[nxt][j],dp2[cur][j]);
		}

		swap(cur,nxt);
		REP(j,m+1) dp1[nxt][j]=dp2[nxt][j]=INF;
	}

	cout<<ans<<endl;

	return 0;
}


#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;

#ifndef ONLINE_JUDGE
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }
typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
	template<class S,class T>
	ostream &operator <<(ostream& out,const pair<S,T>& a){
		out<<'('<<a.fr<<','<<a.sc<<')';
		return out;
	}
}
const int INF=5e8;
int n,m;
int dp1[2][2005],dp2[2][2005];

int pud[100005],ispud[200005],pudsum[200005];
int mark[200005],marksum[200005];
int con[200005];
int MX=200003;
int main(){
	cin>>n>>m;

	int st=MX;
	REP(i,n){
		int a;scanf("%d",&a);
		ispud[a]=1;
		pud[i]=a;
		chmin(st,a);
	}

	sort(pud,pud+n);
	REP(i,m){
		int a;scanf("%d",&a);
		mark[a]=1;
	}

	REP(i,MX){
		pudsum[i+1]=pudsum[i]+ispud[i];
		marksum[i+1]=mark[i]+marksum[i];
	}
	REP(i,MX) if(ispud[i] && ispud[i+1]) con[i]=1;
	REP(k,2) REP(j,2005) dp1[k][j]=dp2[k][j]=INF;
	int cur=0,nxt=1;
	dp1[cur][0]=0;

	int ans=0;
	for(int i=st;i<MX;++i){
		dump(m);
		REP(j,m+1) if(dp1[cur][j]<=n){
			dump(i);dump(j);dump(dp1[cur][j]);
			chmax(ans,j);
			chmin(dp1[nxt][j],dp1[cur][j]);

			if(ispud[i]){
				int sum=pudsum[i+1]-dp1[cur][j];
				if(sum<=0) continue;
				dump(marksum[i+1]);dump(marksum[i+1-sum]);
				int nmark=marksum[i+1]-marksum[i+1-sum];
				dump(sum);dump(nmark);
				chmin(dp2[cur][j+nmark],pudsum[i+1]);
			}
		}
		REP(j,m+1) if(dp2[cur][j]<=n){
			dump(i);dump(j);dump(dp2[cur][j]);
			chmax(ans,j);
			chmin(dp2[nxt][j+mark[i+1]],dp2[cur][j]+1);
			if(!con[pud[dp2[cur][j]-1]]) chmin(dp1[nxt][j],dp2[cur][j]);
		}

		swap(cur,nxt);
		REP(j,m+1) dp1[nxt][j]=dp2[nxt][j]=INF;
	}

	cout<<ans<<endl;

	return 0;
}


#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;

#ifndef ONLINE_JUDGE
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }
typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
	template<class S,class T>
	ostream &operator <<(ostream& out,const pair<S,T>& a){
		out<<'('<<a.fr<<','<<a.sc<<')';
		return out;
	}
}
const int INF=5e8;
int n,m;
int dp1[2][2005],dp2[2][2005];

int pud[100005],ispud[200005],pudsum[200005];
int mark[200005],marksum[200005];
int con[200005];
int MX=200003;
int main(){
	cin>>n>>m;

	int st=MX;
	REP(i,n){
		int a;scanf("%d",&a);
		ispud[a]=1;
		pud[i]=a;
		chmin(st,a);
	}

	sort(pud,pud+n);
	REP(i,m){
		int a;scanf("%d",&a);
		mark[a]=1;
	}

	REP(i,MX){
		pudsum[i+1]=pudsum[i]+ispud[i];
		marksum[i+1]=mark[i]+marksum[i];
	}
	REP(i,MX) if(ispud[i] && ispud[i+1]) con[i]=1;
	REP(k,2) REP(j,2005) dp1[k][j]=dp2[k][j]=INF;
	int cur=0,nxt=1;
	dp1[cur][0]=0;

	int ans=0;
	for(int i=st;i<MX;++i){
		dump(m);
		REP(j,m+1) if(dp1[cur][j]<=n){
			dump(i);dump(j);dump(dp1[cur][j]);
			chmax(ans,j);
			chmin(dp1[nxt][j],dp1[cur][j]);

			if(ispud[i]){
				int sum=pudsum[i+1]-dp1[cur][j];
				dump(marksum[i+1]);dump(marksum[i+1-sum]);
				int nmark=marksum[i+1]-marksum[i+1-sum];
				dump(sum);dump(nmark);
				chmax(nmark,0);
				chmin(dp2[cur][j+nmark],pudsum[i+1]);
			}
		}
		REP(j,m+1) if(dp2[cur][j]<=n){
			dump(i);dump(j);dump(dp2[cur][j]);
			chmax(ans,j);
			chmin(dp2[nxt][j+mark[i+1]],dp2[cur][j]+1);
			if(!con[pud[dp2[cur][j]-1]]) chmin(dp1[nxt][j],dp2[cur][j]);
		}
		swap(cur,nxt);
		REP(j,m+1) dp1[nxt][j]=dp2[nxt][j]=INF;
	}

	cout<<ans<<endl;

	return 0;
}


#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;

#ifndef ONLINE_JUDGE
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }
typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
	template<class S,class T>
	ostream &operator <<(ostream& out,const pair<S,T>& a){
		out<<'('<<a.fr<<','<<a.sc<<')';
		return out;
	}
}
const int INF=5e8;
int n,m;
int dp1[2][2005],dp2[2][2005];

int pud[100005],ispud[200005],pudsum[200005];
int mark[200005],marksum[200005];
int con[200005];
int MX=200003;
int main(){
	cin>>n>>m;

	int st=MX;
	REP(i,n){
		int a;scanf("%d",&a);
		ispud[a]=1;
		pud[i]=a;
		chmin(st,a);
	}

	sort(pud,pud+n);
	REP(i,m){
		int a;scanf("%d",&a);
		mark[a]=1;
	}

	REP(i,MX){
		pudsum[i+1]=pudsum[i]+ispud[i];
		marksum[i+1]=mark[i]+marksum[i];
	}
	REP(i,MX) if(ispud[i] && ispud[i+1]) con[i]=1;
	REP(k,2) REP(j,2005) dp1[k][j]=dp2[k][j]=INF;
	int cur=0,nxt=1;
	dp1[cur][0]=0;

	int ans=0;
	for(int i=st;i<MX;++i){
		dump(m);
		REP(j,m+1) if(dp1[cur][j]<=n){
			dump(i);dump(j);dump(dp1[cur][j]);
			chmax(ans,j);
			chmin(dp1[nxt][j],dp1[cur][j]);

			if(ispud[i]){
				int sum=pudsum[i+1]-dp1[cur][j];
				dump(marksum[i+1]);dump(marksum[i+1-sum]);
				int nmark=marksum[i+1]-marksum[i+1-sum];
				dump(sum);dump(nmark);
				if(nmark>0) chmin(dp2[cur][j+nmark],pudsum[i+1]);
			}
		}
		REP(j,m+1) if(dp2[cur][j]<=n){
			dump(i);dump(j);dump(dp2[cur][j]);
			chmax(ans,j);
			chmin(dp2[nxt][j+mark[i+1]],dp2[cur][j]+1);
			if(!con[pud[dp2[cur][j]-1]]) chmin(dp1[nxt][j],dp2[cur][j]);
		}

		swap(cur,nxt);
		REP(j,m+1) dp1[nxt][j]=dp2[nxt][j]=INF;
	}

	cout<<ans<<endl;

	return 0;
}


import java.io.BufferedReader;
import java.io.InputStreamReader;

/**
 *
 */

/**
 * @author Administrator
 *
 */
public class A {

	public static void main(String[] args) throws Exception {
		A main = new A();
		main.run();
		System.exit(0);
	}

	private void run() throws Exception {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String[] strs = in.readLine().split("\\s");
		int n = Integer.parseInt(strs[0]);
		int m = Integer.parseInt(strs[1]);
		if (m <= n / 2) {
			System.out.println(-1);
			return;
		}

		for (int i = 0; i < m; i++) {
			System.out.println(String.format("%d %d", i, i * i));
		}
		for (int i = m; i < n; i++) {
			System.out.println(String.format("%d %d", n - i, -i * i * i));
		}
	}
}


import java.io.BufferedReader;
import java.io.InputStreamReader;

public class A {

	public static void main(String[] args) throws Exception {
		A main = new A();
		main.run();
		System.exit(0);
	}

	private void run() throws Exception {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String[] strs = in.readLine().split("\\s");
		int n = Integer.parseInt(strs[0]);
		int m = Integer.parseInt(strs[1]);
		if (m * 2 <= n) {
			System.out.println(-1);
			return;
		}

		for (int i = 1; i <= m; i++) {
			System.out.println(String.format("%d %d", i, i * i));
		}
		for (int i = 1; i <= n - m; i++) {
			System.out.println(String.format("%d %d", 100000 + i * i, i));
		}
	}
}


import java.io.BufferedReader;
import java.io.InputStreamReader;

/**
 *
 */

/**
 * @author Administrator
 *
 */
public class A {

	public static void main(String[] args) throws Exception {
		A main = new A();
		main.run();
		System.exit(0);
	}

	private void run() throws Exception {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String[] strs = in.readLine().split("\\s");
		int n = Integer.parseInt(strs[0]);
		int m = Integer.parseInt(strs[1]);
		if (m <= n / 2) {
			System.out.println(-1);
			return;
		}

		for (int i = 0; i < m; i++) {
			System.out.println(String.format("%d %d", i, i * i));
		}
		for (int i = m; i < n; i++) {
			System.out.println(String.format("%d %d", n - i, (n - i) * (n - i)
					/ 2));
		}
	}
}


import java.io.BufferedReader;
import java.io.InputStreamReader;

/**
 *
 */

/**
 * @author Administrator
 *
 */
public class A {

	public static void main(String[] args) throws Exception {
		A main = new A();
		main.run();
		System.exit(0);
	}

	private void run() throws Exception {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String[] strs = in.readLine().split("\\s");
		int n = Integer.parseInt(strs[0]);
		int m = Integer.parseInt(strs[1]);
		if (m <= n / 2) {
			System.out.println(-1);
			return;
		}

		for (int i = 1; i <= m; i++) {
			System.out.println(String.format("%d %d", i, i * i));
		}
		for (int i = m + 1; i <= n; i++) {
			System.out.println(String.format("%d %d", i - m + 1, (i - m)
					* (i - m)));
		}
	}
}


import java.io.BufferedReader;
import java.io.InputStreamReader;

public class A {

	public static void main(String[] args) throws Exception {
		A main = new A();
		main.run();
		System.exit(0);
	}

	private void run() throws Exception {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String[] strs = in.readLine().split("\\s");
		int n = Integer.parseInt(strs[0]);
		int m = Integer.parseInt(strs[1]);
		if (n - m >= 2 && m < 4) {
			System.out.println(-1);
			return;
		}

		for (int i = 1; i <= m; i++) {
			System.out.println(String.format("%d %d", i, i * i));
		}
		for (int i = 1; i <= n - m; i++) {
			System.out.println(String.format("%d %d", 40001 + i * i, i));
		}
	}
}


import java.io.BufferedReader;
import java.io.InputStreamReader;

public class A {

	public static void main(String[] args) throws Exception {
		A main = new A();
		main.run();
		System.exit(0);
	}

	private void run() throws Exception {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String[] strs = in.readLine().split("\\s");
		int n = Integer.parseInt(strs[0]);
		int m = Integer.parseInt(strs[1]);
		if (n - m >= 2 && m < 4) {
			System.out.println(-1);
			return;
		}

		for (int i = 1; i <= m; i++) {
			System.out.println(String.format("%d %d", i, i * i / 2));
		}
		for (int i = 1; i <= n - m; i++) {
			System.out.println(String.format("%d %d", 100000 + i * i / 2, i));
		}
	}
}


import java.io.BufferedReader;
import java.io.InputStreamReader;

public class A {

	public static void main(String[] args) throws Exception {
		A main = new A();
		main.run();
		System.exit(0);
	}

	private void run() throws Exception {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String[] strs = in.readLine().split("\\s");
		int n = Integer.parseInt(strs[0]);
		int m = Integer.parseInt(strs[1]);
		if (m * 2 <= n) {
			System.out.println(-1);
			return;
		}

		for (int i = 1; i <= m; i++) {
			System.out.println(String.format("%d %d", i, i * (i + 1) / 2));
		}
		for (int i = 1; i <= n - m; i++) {
			System.out.println(String.format("%d %d", 100000 + i * (i + 1) / 2,
					i));
		}
	}
}


import java.io.BufferedReader;
import java.io.InputStreamReader;

/**
 *
 */

/**
 * @author Administrator
 *
 */
public class A {

	public static void main(String[] args) throws Exception {
		A main = new A();
		main.run();
		System.exit(0);
	}

	private void run() throws Exception {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String[] strs = in.readLine().split("\\s");
		int n = Integer.parseInt(strs[0]);
		int m = Integer.parseInt(strs[1]);
		if (m <= n / 2) {
			System.out.println(-1);
			return;
		}

		for (int i = 1; i <= m; i++) {
			System.out.println(String.format("%d %d", i, i * i));
		}
		for (int i = m + 1; i <= n; i++) {
			System.out.println(String.format("%d %d", i,
					(int) Math.pow(i - m - 1, 1.0 / 3.0) + (m + 1)));
		}
	}
}


import java.io.BufferedReader;
import java.io.InputStreamReader;

/**
 *
 */

/**
 * @author Administrator
 *
 */
public class A {

	public static void main(String[] args) throws Exception {
		A main = new A();
		main.run();
		System.exit(0);
	}

	private void run() throws Exception {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String[] strs = in.readLine().split("\\s");
		int n = Integer.parseInt(strs[0]);
		int m = Integer.parseInt(strs[1]);
		if (m <= n / 2) {
			System.out.println(-1);
			return;
		}

		for (int i = 0; i < m; i++) {
			System.out.println(String.format("%d %d", i, i * i));
		}
		for (int i = m; i < n; i++) {
			System.out.println(String.format("%d %d", i, i * i - 1));
		}
	}
}


import java.io.BufferedReader;
import java.io.InputStreamReader;

/**
 *
 */

/**
 * @author Administrator
 *
 */
public class A {

	public static void main(String[] args) throws Exception {
		A main = new A();
		main.run();
		System.exit(0);
	}

	private void run() throws Exception {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String[] strs = in.readLine().split("\\s");
		int n = Integer.parseInt(strs[0]);
		int m = Integer.parseInt(strs[1]);
		if (m <= n / 2) {
			System.out.println(-1);
			return;
		}

		for (int i = 1; i <= m; i++) {
			System.out.println(String.format("%d %d", i, i * i));
		}
		for (int i = m + 1; i <= n; i++) {
			System.out.println(String.format("%d %d", i,
					(int) Math.pow(i * i, 1.0 / 3.0) + (m + 1)));
		}
	}
}


import java.io.BufferedReader;
import java.io.InputStreamReader;

/**
 *
 */

/**
 * @author Administrator
 *
 */
public class A {

	public static void main(String[] args) throws Exception {
		A main = new A();
		main.run();
		System.exit(0);
	}

	private void run() throws Exception {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String[] strs = in.readLine().split("\\s");
		int n = Integer.parseInt(strs[0]);
		int m = Integer.parseInt(strs[1]);
		if (m <= n / 2) {
			System.out.println(-1);
			return;
		}

		for (int i = 1; i <= m; i++) {
			System.out.println(String.format("%d %d", i, i * i));
		}
		for (int i = m + 1; i <= n; i++) {
			System.out.println(String.format("%d %d", i - m + 1, (i - m + 1)
					* (i - m + 1)));
		}
	}
}


import java.io.BufferedReader;
import java.io.InputStreamReader;

/**
 *
 */

/**
 * @author Administrator
 *
 */
public class A {

	public static void main(String[] args) throws Exception {
		A main = new A();
		main.run();
		System.exit(0);
	}

	private void run() throws Exception {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String[] strs = in.readLine().split("\\s");
		int n = Integer.parseInt(strs[0]);
		int m = Integer.parseInt(strs[1]);
		if (m <= n / 2) {
			System.out.println(-1);
			return;
		}

		for (int i = 0; i < m; i++) {
			System.out.println(String.format("%d %d", i, i * (i + 1)));
		}
		for (int i = 1; i <= n - m + 1; i++) {
			System.out.println(String.format("%d %d", 100000 + i * (i + 1), i));
		}
	}
}


import java.io.BufferedReader;
import java.io.InputStreamReader;

/**
 *
 */

/**
 * @author Administrator
 *
 */
public class A {

	public static void main(String[] args) throws Exception {
		A main = new A();
		main.run();
		System.exit(0);
	}

	private void run() throws Exception {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String[] strs = in.readLine().split("\\s");
		int n = Integer.parseInt(strs[0]);
		int m = Integer.parseInt(strs[1]);
		if (m <= n / 2) {
			System.out.println(-1);
			return;
		}

		for (int i = 1; i <= m; i++) {
			System.out.println(String.format("%d %d", i, i * i));
		}
		for (int i = m + 1; i <= n; i++) {
			System.out.println(String.format("%d %d", i,
					(int) Math.pow(i, 1.0 / 3.0)));
		}
	}
}


import java.io.BufferedReader;
import java.io.InputStreamReader;

public class A {

	public static void main(String[] args) throws Exception {
		A main = new A();
		main.run();
		System.exit(0);
	}

	private void run() throws Exception {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String[] strs = in.readLine().split("\\s");
		int n = Integer.parseInt(strs[0]);
		int m = Integer.parseInt(strs[1]);
		if (n - m >= 2 && m < 4) {
			System.out.println(-1);
			return;
		}

		for (int i = 1; i <= m; i++) {
			System.out.println(String.format("%d %d", i, i * i));
		}
		for (int i = 1; i <= n - m; i++) {
			System.out.println(String.format("%d %d", 100000 + i * i, i));
		}
	}
}


import java.io.BufferedReader;
import java.io.InputStreamReader;

/**
 *
 */

/**
 * @author Administrator
 *
 */
public class A {

	public static void main(String[] args) throws Exception {
		A main = new A();
		main.run();
		System.exit(0);
	}

	private void run() throws Exception {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String[] strs = in.readLine().split("\\s");
		int n = Integer.parseInt(strs[0]);
		int m = Integer.parseInt(strs[1]);
		if (m <= n / 2) {
			System.out.println(-1);
			return;
		}

		for (int i = 0; i < m; i++) {
			System.out
					.println(String.format("%d %d", i, (i + 100) * (i + 100)));
		}
		for (int i = m; i < n; i++) {
			System.out.println(String.format("%d %d", i,
					Math.round(Math.pow(i, 22.0 / 24.0))));
		}
	}
}


import java.io.BufferedReader;
import java.io.InputStreamReader;

/**
 *
 */

/**
 * @author Administrator
 *
 */
public class A {

	public static void main(String[] args) throws Exception {
		A main = new A();
		main.run();
		System.exit(0);
	}

	private void run() throws Exception {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String[] strs = in.readLine().split("\\s");
		int n = Integer.parseInt(strs[0]);
		int m = Integer.parseInt(strs[1]);
		if (m <= n / 2) {
			System.out.println(-1);
			return;
		}

		for (int i = 0; i < m; i++) {
			System.out.println(String.format("%d %d", i, i * (i + 1)));
		}
		for (int i = 1; i < n - m + 1; i++) {
			System.out.println(String.format("%d %d", 100000 + i * (i + 1), i));
		}
	}
}


import java.io.BufferedReader;
import java.io.InputStreamReader;

/**
 *
 */

/**
 * @author Administrator
 *
 */
public class A {

	public static void main(String[] args) throws Exception {
		A main = new A();
		main.run();
		System.exit(0);
	}

	private void run() throws Exception {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String[] strs = in.readLine().split("\\s");
		int n = Integer.parseInt(strs[0]);
		int m = Integer.parseInt(strs[1]);
		if (m <= n / 2) {
			System.out.println(-1);
			return;
		}

		for (int i = 0; i < m; i++) {
			System.out.println(String.format("%d %d", i, i * i));
		}
		for (int i = m; i < n; i++) {
			System.out.println(String.format("%d %d", i, -i * i * i));
		}
	}
}


import java.io.BufferedReader;
import java.io.InputStreamReader;

/**
 *
 */

/**
 * @author Administrator
 *
 */
public class A {

	public static void main(String[] args) throws Exception {
		A main = new A();
		main.run();
		System.exit(0);
	}

	private void run() throws Exception {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String[] strs = in.readLine().split("\\s");
		int n = Integer.parseInt(strs[0]);
		int m = Integer.parseInt(strs[1]);
		if (m <= n / 2) {
			System.out.println(-1);
			return;
		}

		for (int i = 1; i <= m; i++) {
			System.out.println(String.format("%d %d", i, i * i));
		}
		for (int i = m + 1; i <= n; i++) {
			System.out.println(String.format("%d %d", n - i, (n - i) * (n - i)
					/ 2));
		}
	}
}


import java.io.BufferedReader;
import java.io.InputStreamReader;

/**
 *
 */

/**
 * @author Administrator
 *
 */
public class A {

	public static void main(String[] args) throws Exception {
		A main = new A();
		main.run();
		System.exit(0);
	}

	private void run() throws Exception {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String[] strs = in.readLine().split("\\s");
		int n = Integer.parseInt(strs[0]);
		int m = Integer.parseInt(strs[1]);
		if (m <= n / 2) {
			System.out.println(-1);
			return;
		}

		for (int i = 1; i <= m; i++) {
			System.out.println(String.format("%d %d", i, i * i));
		}
		for (int i = m + 1; i <= n; i++) {
			System.out.println(String.format("%d %d", n - i + 1, (n - i + 1)
					* (n - i + 1) / 2));
		}
	}
}


import java.io.BufferedReader;
import java.io.InputStreamReader;

public class A {

	public static void main(String[] args) throws Exception {
		A main = new A();
		main.run();
		System.exit(0);
	}

	private void run() throws Exception {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String[] strs = in.readLine().split("\\s");
		int n = Integer.parseInt(strs[0]);
		int m = Integer.parseInt(strs[1]);
		if (n - m >= 2 && m < 4) {
			System.out.println(-1);
			return;
		}

		for (int i = 1; i <= m; i++) {
			System.out.println(String.format("%d %d", i, i * (i + 1) / 2));
		}
		for (int i = 1; i <= n - m; i++) {
			System.out.println(String.format("%d %d", 100000 + i * (i + 1) / 2,
					i));
		}
	}
}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Scanner;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author pttrung
 */
public class D {

    public static void main(String[] args) {
        Scanner in = new Scanner(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        int n = in.nextInt();
        int m = in.nextInt();
        if (m == 3) {
            if (n >= 5) {
                out.println(-1);
            } else {
                out.println(0 + " " + 0);
                out.println(3 + " " + 0);
                out.println(0 + " " + 3);
                if (n == 4) {
                    out.println(1 + " " + 1);
                }
            }
        } else {
            int X = 10000000;
            for (int i = 0; i < m; i++) {
                out.println(i + " " + (i * i + X));
            }
            for (int i = 0; i < n - m; i++) {
                out.println(i + " " + (-i * i - X));
            }
        }
        out.close();
    }
}


#include <cstdio>
#include <iostream>
using namespace std;

int main(){
    int m,n; cin>>n>>m;
    if(m == 3 && n >= 5)  {
        cout<<-1<<endl;
        return 0;
    }
    int ans = 10000000;
    for(int i=0; i<m; i++)
        printf("%I64d %I64d\n", i, ans+i*i);
    for(__int64 i=0;i<n-m;i++)
        printf("%I64d %I64d\n", i, -ans-i*i);
    return 0;
}


#include <cstdio>
#include <iostream>
using namespace std;

int main(){
    int m,n; cin>>n>>m;
    if(m == 3 && n >= 5)  {
        cout<<-1<<endl;
        return 0;
    }
    int ans = 10000000;
    for(int i=0; i<m; i++)
        printf("%d %d\n", i, ans+i*i);
    for(int i=0; i<n-m; i++)
        printf("%d %d\n", i, -ans-i*i);
    return 0;
}


#include <stdio.h>
#include <math.h>
#include <cstring>
#include <algorithm>
using namespace std;

const double PI=acos(-1.0);

int n,m;
double p[210][2];

int main()
{
	while(scanf("%d%d",&n,&m)!=EOF)
	{
		if (m==3)
		{
			if (n==3)
			{
				printf("0 0\n0 1\n1 0\n");
				continue;
			}
			if (n==4)
			{
				printf("0 0\n3 0\n0 3\n1 1\n");
				continue;
			}
			printf("-1\n");
			continue;
		}
		for (int i=1; i<=m; i++)
		{
			printf("%d %d\n", i, -(n-i)*(n-i));
		}
		for (int i=1; i<=n-m; i++)
		{
			printf("%d %d\n", -i, (n-i)*(n-i));
		}
	}
	return 0;
}


#pragma comment(linker, "/STACK:36777216")
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <ctime>

#define pb push_back
#define mp make_pair
#define sz size()
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define vint vector<int>
#define rep(i,n) for (int i=0; i<n; i++)
#define ll long long

using namespace std;

const int INF=~(1<<31);
const double EPS=1;
const double PI=3.141592653589793;

int main() {
#ifdef _DEBUG
   freopen("in.txt","r",stdin);
   //freopen("out.txt","w",stdout);
#endif
   int n,m;
   cin>>n>>m;
   if (m==3 && n>=5) {
	   cout<<"-1\n";
	   return 0;
   }
   rep(i,m) cout<<i<<' '<<i*i+1000<<'\n';
   rep(i,n-m) cout<<i<<' '<<-i*i-1000<<'\n';
   return 0;
}


#pragma comment(linker, "/STACK:36777216")
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <ctime>

#define pb push_back
#define mp make_pair
#define sz size()
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define vint vector<int>
#define rep(i,n) for (int i=0; i<n; i++)
#define ll long long

using namespace std;

const int INF=~(1<<31);
const double EPS=1;
const double PI=3.141592653589793;

int main() {
#ifdef _DEBUG
   freopen("in.txt","r",stdin);
   //freopen("out.txt","w",stdout);
#endif
   int n,m;
   cin>>n>>m;
   if (m==3 && n>=5) {
	   cout<<"-1\n";
	   return 0;
   }
   rep(i,m) cout<<i<<' '<<i*i+10000000<<'\n';
   rep(i,n-m) cout<<i<<' '<<-i*i-10000000<<'\n';
   return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <memory.h>
#include <map>
#include <set>
#include <memory.h>
#include <cstdlib>
#include <cstring>
#include <string>
#define y1 jvhsdoublek
#define x first
#define y second
#define mod 1000000007
#define ll long long
#define MAX  105
#define INF 1000000000
using namespace std;
int main() {
  int n , m;
  scanf("%d %d",&n, &m);
  if(m == 3 && n > 4){
        printf("-1\n");
        return 0;
  }
    for(int i = 1; i <= m; i++)
        printf("%d %d\n", i, i * i + INF);
    for(int i = 1; i <= n - m; ++i)
        printf("%d %d\n", - i, - i * i - INF);
  return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <memory.h>
#include <map>
#include <set>
#include <memory.h>
#include <cstdlib>
#include <cstring>
#include <string>
#define y1 jvhsdoublek
#define x first
#define y second
#define mod 1000000007
#define ll long long
#define MAX  105
#define INF 1000000
using namespace std;
int main() {
  int n , m;
  scanf("%d %d",&n, &m);
  if(m == 3 && n > 4){
        printf("-1\n");
        return 0;
  }
    for(int i = 1; i <= m; i++)
        printf("%d %d\n", i, i * i + INF);
    for(int i = 1; i <= n - m; ++i)
        printf("%d %d\n", - i, - i * i - INF);
  return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <memory.h>
#include <map>
#include <set>
#include <memory.h>
#include <cstdlib>
#include <cstring>
#include <string>
#define y1 jvhsdoublek
#define x first
#define y second
#define mod 1000000007
#define ll long long
#define MAX  105
#define INF 1000000000
using namespace std;
int main() {
  int n , m;
  scanf("%d %d",&n, &m);
  if(m == 3 && n > 4) printf("-1\n");
    for(int i = 1; i <= m; i++)
        printf("%d %d\n", i, i * i + INF);
    for(int i = 1; i <= n - m; ++i)
        printf("%d %d\n", - i, - i * i - INF);
  return 0;
}


/*
Bismillahir-rahmanir-rahim
*/

# include <iostream>
# include <fstream>
# include <sstream>
# include <algorithm>
# include <functional> // greater<int>()
# include <vector>
# include <string>
# include <queue>
# include <stack>
# include <list>
# include <map>
# include <set>
# include <cstdio>
# include <cstdlib>
# include <cmath>
# include <ctime>
# include <cstring>
# include <cctype>
# include <climits> // LLONG_MAX , LLONG_MIN , INT_MAX , INT_MIN

/* MACROS */

# define  all(A)		(A).begin() , (A).end()
# define  rall(A)		(A).rbegin() , (A).rend()
# define  sz(A)			(int)(A).size()
# define  pb			push_back
# define  ppb			pop_back
# define  mp			make_pair
# define  bir			first
# define  iki			second
# define  rsz(A,X)		(A).resize(X)
# define  ln(A)			(int)(A).length()
# define  FILL(X, A)	memset((X), (A), sizeof(X))
# define  minof(X)		min_element(all(X))-X.begin()
# define  maxof(X)		max_element(all(X))-X.begin()
# define  square(X)		(X)*(X)
# define  cube(X)		(X)*(X)*(X)

# define  FOR(i, a, b)	for (int i=a; i<b; i++)
# define  FORD(i, a, b)	for (int i=a-1; i>=b; i--)
# define  REP(i,n)		for( int i=0 ; i<n ; i++ )
# define  REPD(i,n)		for( int i=n-1 ; i>=0 ; i-- )
# define  REK(IDFR,EXPRESSION,CHANGE)  \
		for( int IDFR ; EXPRESSION ; CHANGE )
# define  TR(it,container)  \
		for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
# define  setmap_found(container, element) (container.find(element) != container.end())
# define  vector_found(container, element) (find(all(container),element) != container.end())
# define  DBG(vari) cerr<<endl<<#vari<<" = "<<(vari)<<endl;

time_t st=clock();
using namespace std;

/* {START} */

template <class stl>  // $stl = 'deque', 'vector' , 'set'
void DBGSTL (stl a) {
	cerr<<"\tDEBUG:\n\t";
	TR(i,a) { cerr<<*i<<" "; }
	cerr<<"\n";
	return;
}

/* TYPE DEFINITIONS */
typedef long long i64;

typedef		vector<int>		vi;
typedef		vector<vi>		vvi;
typedef		pair<int,int>	pi;
typedef		vector<pi>		vpi;
typedef		vector<vpi>		vvpi;
typedef		vector<i64>		v64;
typedef		vector<v64>		vv64;
typedef		pair<i64,i64>	p64;
typedef		vector<p64> 	vp64;
typedef		vector<vp64>	vvp64;
typedef		vector<string>	vs;
typedef		vector<vs>		vvs;
typedef		vector<bool>	vb;
typedef		vector<vb>		vvb;
typedef		vector<char>	vc;
typedef		vector<vc>		vvc;

/* TOOLS */
template <class T>
inline T max(T a, T b, T c)
{   return max(a, max(b, c));   }

template <class T>
inline T min(T a, T b, T c)
{   return min(a, min(b, c));   }

/* ALGEBRA */
template <class T>
T gcd (T a, T b)
{    return ( b==(T)0 ?a :gcd(b,a%b) );    }

template <class T>
T lcm (T a , T b)
{    return a/gcd(a,b)*b;    }

template <class T>
T mathround (T x)
{    i64 i64x=(i64)x; if( x<i64x+0.5 ) return (T)i64x; return (T)i64x+1;    }

template <class T>
bool isprime(T x)
{
	int till = (T)sqrt(x+.0);
	if (x == 1) return 0;
	if (x == 2) return 1;
	if (x%2 == 0) return 0;
	for (int i=3; i<=till; i+=2) if (x%i == 0) return 0;
	return 1;
}

/* GEOMETRY */
template <class T>
double geodist(T x1, T y1, T x2, T y2)
{   return sqrt( square(x1-x2) + square(y1-y2) + .0 );   }

/* CONSTANTS */
const double Pi = 4.0 * atan(1.0); // 4*atan(1)

//int di[]={1, -1, 0, 0, 1, 1, -1, -1};
//int dj[]={0, 0, 1, -1, 1, -1, 1, -1};
//int mon[] = {31,28,31,30,31,30,31,31,30,31,30,31};

/* {END} */

i64 n,m;

int main()
{
	cin >> n >> m;

	if(m == 3)
	{
		if(n == 3)
		cout << "0 0\n0 1\n1 0\n";

		else
		if(n == 4)
		cout << "0 0\n1 0\n-1 1\n-1 -1";

		else
		cout << -1;

		return 0;
	}

	i64 x = 0;
	i64 y = 1;
	for (int i=m; i>0; i--)
	{
		cout << i+10 << " " << x << "\n";
		x += y;
		y++;
	}

	x = 0;
	y = 1;
	for (int i=n-m; i>0; i--)
	{
		cout << -i << " " << x << "\n";
		x += y;
		y++;
	}

//	ios_base::sync_with_stdio(false);
//	freopen("input.txt", "r", stdin);		// needs disabled ios_base::sync_with_stdio(false);
//	freopen("output.txt", "w", stdout);		// needs disabled ios_base::sync_with_stdio(false);
//	cin >> noskipws;
//	cin >> skipws;

//	cout<<clock()-st;
	/*
	getchar();
	getchar();
	*/
	return EXIT_SUCCESS;
}


/*
Bismillahir-rahmanir-rahim
*/

# include <iostream>
# include <fstream>
# include <sstream>
# include <algorithm>
# include <functional> // greater<int>()
# include <vector>
# include <string>
# include <queue>
# include <stack>
# include <list>
# include <map>
# include <set>
# include <cstdio>
# include <cstdlib>
# include <cmath>
# include <ctime>
# include <cstring>
# include <cctype>
# include <climits> // LLONG_MAX , LLONG_MIN , INT_MAX , INT_MIN

/* MACROS */

# define  all(A)		(A).begin() , (A).end()
# define  rall(A)		(A).rbegin() , (A).rend()
# define  sz(A)			(int)(A).size()
# define  pb			push_back
# define  ppb			pop_back
# define  mp			make_pair
# define  bir			first
# define  iki			second
# define  rsz(A,X)		(A).resize(X)
# define  ln(A)			(int)(A).length()
# define  FILL(X, A)	memset((X), (A), sizeof(X))
# define  minof(X)		min_element(all(X))-X.begin()
# define  maxof(X)		max_element(all(X))-X.begin()
# define  square(X)		(X)*(X)
# define  cube(X)		(X)*(X)*(X)

# define  FOR(i, a, b)	for (int i=a; i<b; i++)
# define  FORD(i, a, b)	for (int i=a-1; i>=b; i--)
# define  REP(i,n)		for( int i=0 ; i<n ; i++ )
# define  REPD(i,n)		for( int i=n-1 ; i>=0 ; i-- )
# define  REK(IDFR,EXPRESSION,CHANGE)  \
		for( int IDFR ; EXPRESSION ; CHANGE )
# define  TR(it,container)  \
		for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
# define  setmap_found(container, element) (container.find(element) != container.end())
# define  vector_found(container, element) (find(all(container),element) != container.end())
# define  DBG(vari) cerr<<endl<<#vari<<" = "<<(vari)<<endl;

time_t st=clock();
using namespace std;

/* {START} */

template <class stl>  // $stl = 'deque', 'vector' , 'set'
void DBGSTL (stl a) {
	cerr<<"\tDEBUG:\n\t";
	TR(i,a) { cerr<<*i<<" "; }
	cerr<<"\n";
	return;
}

/* TYPE DEFINITIONS */
typedef long long i64;

typedef		vector<int>		vi;
typedef		vector<vi>		vvi;
typedef		pair<int,int>	pi;
typedef		vector<pi>		vpi;
typedef		vector<vpi>		vvpi;
typedef		vector<i64>		v64;
typedef		vector<v64>		vv64;
typedef		pair<i64,i64>	p64;
typedef		vector<p64> 	vp64;
typedef		vector<vp64>	vvp64;
typedef		vector<string>	vs;
typedef		vector<vs>		vvs;
typedef		vector<bool>	vb;
typedef		vector<vb>		vvb;
typedef		vector<char>	vc;
typedef		vector<vc>		vvc;

/* TOOLS */
template <class T>
inline T max(T a, T b, T c)
{   return max(a, max(b, c));   }

template <class T>
inline T min(T a, T b, T c)
{   return min(a, min(b, c));   }

/* ALGEBRA */
template <class T>
T gcd (T a, T b)
{    return ( b==(T)0 ?a :gcd(b,a%b) );    }

template <class T>
T lcm (T a , T b)
{    return a/gcd(a,b)*b;    }

template <class T>
T mathround (T x)
{    i64 i64x=(i64)x; if( x<i64x+0.5 ) return (T)i64x; return (T)i64x+1;    }

template <class T>
bool isprime(T x)
{
	int till = (T)sqrt(x+.0);
	if (x == 1) return 0;
	if (x == 2) return 1;
	if (x%2 == 0) return 0;
	for (int i=3; i<=till; i+=2) if (x%i == 0) return 0;
	return 1;
}

/* GEOMETRY */
template <class T>
double geodist(T x1, T y1, T x2, T y2)
{   return sqrt( square(x1-x2) + square(y1-y2) + .0 );   }

/* CONSTANTS */
const double Pi = 4.0 * atan(1.0); // 4*atan(1)

//int di[]={1, -1, 0, 0, 1, 1, -1, -1};
//int dj[]={0, 0, 1, -1, 1, -1, 1, -1};
//int mon[] = {31,28,31,30,31,30,31,31,30,31,30,31};

/* {END} */

i64 n,m;

int main()
{
	cin >> n >> m;

	if(m == 3 && n-m > 1)
	{
		cout << -1;
		return 0;
	}

	i64 x = 0;
	i64 y = 1;
	for (int i=m; i>0; i--)
	{
		cout << i+10 << " " << x << "\n";
		x += y;
		y++;
	}

	x = 0;
	y = 1;
	for (int i=1; i<=n-m; i++)
	{
		cout << -i << " " << x << "\n";
		x += y;
		y++;
	}

//	ios_base::sync_with_stdio(false);
//	freopen("input.txt", "r", stdin);		// needs disabled ios_base::sync_with_stdio(false);
//	freopen("output.txt", "w", stdout);		// needs disabled ios_base::sync_with_stdio(false);
//	cin >> noskipws;
//	cin >> skipws;

//	cout<<clock()-st;
	/*
	getchar();
	getchar();
	*/
	return EXIT_SUCCESS;
}


/*
Bismillahir-rahmanir-rahim
*/

# include <iostream>
# include <fstream>
# include <sstream>
# include <algorithm>
# include <functional> // greater<int>()
# include <vector>
# include <string>
# include <queue>
# include <stack>
# include <list>
# include <map>
# include <set>
# include <cstdio>
# include <cstdlib>
# include <cmath>
# include <ctime>
# include <cstring>
# include <cctype>
# include <climits> // LLONG_MAX , LLONG_MIN , INT_MAX , INT_MIN

/* MACROS */

# define  all(A)		(A).begin() , (A).end()
# define  rall(A)		(A).rbegin() , (A).rend()
# define  sz(A)			(int)(A).size()
# define  pb			push_back
# define  ppb			pop_back
# define  mp			make_pair
# define  bir			first
# define  iki			second
# define  rsz(A,X)		(A).resize(X)
# define  ln(A)			(int)(A).length()
# define  FILL(X, A)	memset((X), (A), sizeof(X))
# define  minof(X)		min_element(all(X))-X.begin()
# define  maxof(X)		max_element(all(X))-X.begin()
# define  square(X)		(X)*(X)
# define  cube(X)		(X)*(X)*(X)

# define  FOR(i, a, b)	for (int i=a; i<b; i++)
# define  FORD(i, a, b)	for (int i=a-1; i>=b; i--)
# define  REP(i,n)		for( int i=0 ; i<n ; i++ )
# define  REPD(i,n)		for( int i=n-1 ; i>=0 ; i-- )
# define  REK(IDFR,EXPRESSION,CHANGE)  \
		for( int IDFR ; EXPRESSION ; CHANGE )
# define  TR(it,container)  \
		for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
# define  setmap_found(container, element) (container.find(element) != container.end())
# define  vector_found(container, element) (find(all(container),element) != container.end())
# define  DBG(vari) cerr<<endl<<#vari<<" = "<<(vari)<<endl;

time_t st=clock();
using namespace std;

/* {START} */

template <class stl>  // $stl = 'deque', 'vector' , 'set'
void DBGSTL (stl a) {
	cerr<<"\tDEBUG:\n\t";
	TR(i,a) { cerr<<*i<<" "; }
	cerr<<"\n";
	return;
}

/* TYPE DEFINITIONS */
typedef long long i64;

typedef		vector<int>		vi;
typedef		vector<vi>		vvi;
typedef		pair<int,int>	pi;
typedef		vector<pi>		vpi;
typedef		vector<vpi>		vvpi;
typedef		vector<i64>		v64;
typedef		vector<v64>		vv64;
typedef		pair<i64,i64>	p64;
typedef		vector<p64> 	vp64;
typedef		vector<vp64>	vvp64;
typedef		vector<string>	vs;
typedef		vector<vs>		vvs;
typedef		vector<bool>	vb;
typedef		vector<vb>		vvb;
typedef		vector<char>	vc;
typedef		vector<vc>		vvc;

/* TOOLS */
template <class T>
inline T max(T a, T b, T c)
{   return max(a, max(b, c));   }

template <class T>
inline T min(T a, T b, T c)
{   return min(a, min(b, c));   }

/* ALGEBRA */
template <class T>
T gcd (T a, T b)
{    return ( b==(T)0 ?a :gcd(b,a%b) );    }

template <class T>
T lcm (T a , T b)
{    return a/gcd(a,b)*b;    }

template <class T>
T mathround (T x)
{    i64 i64x=(i64)x; if( x<i64x+0.5 ) return (T)i64x; return (T)i64x+1;    }

template <class T>
bool isprime(T x)
{
	int till = (T)sqrt(x+.0);
	if (x == 1) return 0;
	if (x == 2) return 1;
	if (x%2 == 0) return 0;
	for (int i=3; i<=till; i+=2) if (x%i == 0) return 0;
	return 1;
}

/* GEOMETRY */
template <class T>
double geodist(T x1, T y1, T x2, T y2)
{   return sqrt( square(x1-x2) + square(y1-y2) + .0 );   }

/* CONSTANTS */
const double Pi = 4.0 * atan(1.0); // 4*atan(1)

//int di[]={1, -1, 0, 0, 1, 1, -1, -1};
//int dj[]={0, 0, 1, -1, 1, -1, 1, -1};
//int mon[] = {31,28,31,30,31,30,31,31,30,31,30,31};

/* {END} */

i64 n,m;

int main()
{
	cin >> n >> m;

	if(m == 3 && n-m > 1)
	{
		cout << -1;
		return 0;
	}

	i64 x = 0;
	i64 y = 1;
	for (int i=m; i>0; i--)
	{
		cout << i+10 << " " << x << "\n";
		x += y;
		y++;
	}

	x = 0;
	y = 1;
	for (int i=n-m; i>0; i--)
	{
		cout << -i << " " << x << "\n";
		x += y;
		y++;
	}

//	ios_base::sync_with_stdio(false);
//	freopen("input.txt", "r", stdin);		// needs disabled ios_base::sync_with_stdio(false);
//	freopen("output.txt", "w", stdout);		// needs disabled ios_base::sync_with_stdio(false);
//	cin >> noskipws;
//	cin >> skipws;

//	cout<<clock()-st;
	/*
	getchar();
	getchar();
	*/
	return EXIT_SUCCESS;
}


/*
Bismillahir-rahmanir-rahim
*/

# include <iostream>
# include <fstream>
# include <sstream>
# include <algorithm>
# include <functional> // greater<int>()
# include <vector>
# include <string>
# include <queue>
# include <stack>
# include <list>
# include <map>
# include <set>
# include <cstdio>
# include <cstdlib>
# include <cmath>
# include <ctime>
# include <cstring>
# include <cctype>
# include <climits> // LLONG_MAX , LLONG_MIN , INT_MAX , INT_MIN

/* MACROS */

# define  all(A)		(A).begin() , (A).end()
# define  rall(A)		(A).rbegin() , (A).rend()
# define  sz(A)			(int)(A).size()
# define  pb			push_back
# define  ppb			pop_back
# define  mp			make_pair
# define  bir			first
# define  iki			second
# define  rsz(A,X)		(A).resize(X)
# define  ln(A)			(int)(A).length()
# define  FILL(X, A)	memset((X), (A), sizeof(X))
# define  minof(X)		min_element(all(X))-X.begin()
# define  maxof(X)		max_element(all(X))-X.begin()
# define  square(X)		(X)*(X)
# define  cube(X)		(X)*(X)*(X)

# define  FOR(i, a, b)	for (int i=a; i<b; i++)
# define  FORD(i, a, b)	for (int i=a-1; i>=b; i--)
# define  REP(i,n)		for( int i=0 ; i<n ; i++ )
# define  REPD(i,n)		for( int i=n-1 ; i>=0 ; i-- )
# define  REK(IDFR,EXPRESSION,CHANGE)  \
		for( int IDFR ; EXPRESSION ; CHANGE )
# define  TR(it,container)  \
		for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
# define  setmap_found(container, element) (container.find(element) != container.end())
# define  vector_found(container, element) (find(all(container),element) != container.end())
# define  DBG(vari) cerr<<endl<<#vari<<" = "<<(vari)<<endl;

time_t st=clock();
using namespace std;

/* {START} */

template <class stl>  // $stl = 'deque', 'vector' , 'set'
void DBGSTL (stl a) {
	cerr<<"\tDEBUG:\n\t";
	TR(i,a) { cerr<<*i<<" "; }
	cerr<<"\n";
	return;
}

/* TYPE DEFINITIONS */
typedef long long i64;

typedef		vector<int>		vi;
typedef		vector<vi>		vvi;
typedef		pair<int,int>	pi;
typedef		vector<pi>		vpi;
typedef		vector<vpi>		vvpi;
typedef		vector<i64>		v64;
typedef		vector<v64>		vv64;
typedef		pair<i64,i64>	p64;
typedef		vector<p64> 	vp64;
typedef		vector<vp64>	vvp64;
typedef		vector<string>	vs;
typedef		vector<vs>		vvs;
typedef		vector<bool>	vb;
typedef		vector<vb>		vvb;
typedef		vector<char>	vc;
typedef		vector<vc>		vvc;

/* TOOLS */
template <class T>
inline T max(T a, T b, T c)
{   return max(a, max(b, c));   }

template <class T>
inline T min(T a, T b, T c)
{   return min(a, min(b, c));   }

/* ALGEBRA */
template <class T>
T gcd (T a, T b)
{    return ( b==(T)0 ?a :gcd(b,a%b) );    }

template <class T>
T lcm (T a , T b)
{    return a/gcd(a,b)*b;    }

template <class T>
T mathround (T x)
{    i64 i64x=(i64)x; if( x<i64x+0.5 ) return (T)i64x; return (T)i64x+1;    }

template <class T>
bool isprime(T x)
{
	int till = (T)sqrt(x+.0);
	if (x == 1) return 0;
	if (x == 2) return 1;
	if (x%2 == 0) return 0;
	for (int i=3; i<=till; i+=2) if (x%i == 0) return 0;
	return 1;
}

/* GEOMETRY */
template <class T>
double geodist(T x1, T y1, T x2, T y2)
{   return sqrt( square(x1-x2) + square(y1-y2) + .0 );   }

/* CONSTANTS */
const double Pi = 4.0 * atan(1.0); // 4*atan(1)

//int di[]={1, -1, 0, 0, 1, 1, -1, -1};
//int dj[]={0, 0, 1, -1, 1, -1, 1, -1};
//int mon[] = {31,28,31,30,31,30,31,31,30,31,30,31};

/* {END} */

i64 n,m;

int main()
{
	cin >> n >> m;

	if(m == 3 && n-m > 1)
	{
		cout << -1;
		return 0;
	}

	i64 x = 0;
	i64 y = 1;
	for (int i=m; i>0; i--)
	{
		cout << i+1000000 << " " << x << "\n";
		x += y;
		y++;
	}

	x = 0;
	y = 1;
	for (int i=n-m; i>0; i--)
	{
		cout << -i << " " << x << "\n";
		x += y;
		y++;
	}

//	ios_base::sync_with_stdio(false);
//	freopen("input.txt", "r", stdin);		// needs disabled ios_base::sync_with_stdio(false);
//	freopen("output.txt", "w", stdout);		// needs disabled ios_base::sync_with_stdio(false);
//	cin >> noskipws;
//	cin >> skipws;

//	cout<<clock()-st;
	/*
	getchar();
	getchar();
	*/
	return EXIT_SUCCESS;
}


/*
Bismillahir-rahmanir-rahim
*/

# include <iostream>
# include <fstream>
# include <sstream>
# include <algorithm>
# include <functional> // greater<int>()
# include <vector>
# include <string>
# include <queue>
# include <stack>
# include <list>
# include <map>
# include <set>
# include <cstdio>
# include <cstdlib>
# include <cmath>
# include <ctime>
# include <cstring>
# include <cctype>
# include <climits> // LLONG_MAX , LLONG_MIN , INT_MAX , INT_MIN

/* MACROS */

# define  all(A)		(A).begin() , (A).end()
# define  rall(A)		(A).rbegin() , (A).rend()
# define  sz(A)			(int)(A).size()
# define  pb			push_back
# define  ppb			pop_back
# define  mp			make_pair
# define  bir			first
# define  iki			second
# define  rsz(A,X)		(A).resize(X)
# define  ln(A)			(int)(A).length()
# define  FILL(X, A)	memset((X), (A), sizeof(X))
# define  minof(X)		min_element(all(X))-X.begin()
# define  maxof(X)		max_element(all(X))-X.begin()
# define  square(X)		(X)*(X)
# define  cube(X)		(X)*(X)*(X)

# define  FOR(i, a, b)	for (int i=a; i<b; i++)
# define  FORD(i, a, b)	for (int i=a-1; i>=b; i--)
# define  REP(i,n)		for( int i=0 ; i<n ; i++ )
# define  REPD(i,n)		for( int i=n-1 ; i>=0 ; i-- )
# define  REK(IDFR,EXPRESSION,CHANGE)  \
		for( int IDFR ; EXPRESSION ; CHANGE )
# define  TR(it,container)  \
		for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
# define  setmap_found(container, element) (container.find(element) != container.end())
# define  vector_found(container, element) (find(all(container),element) != container.end())
# define  DBG(vari) cerr<<endl<<#vari<<" = "<<(vari)<<endl;

time_t st=clock();
using namespace std;

/* {START} */

template <class stl>  // $stl = 'deque', 'vector' , 'set'
void DBGSTL (stl a) {
	cerr<<"\tDEBUG:\n\t";
	TR(i,a) { cerr<<*i<<" "; }
	cerr<<"\n";
	return;
}

/* TYPE DEFINITIONS */
typedef long long i64;

typedef		vector<int>		vi;
typedef		vector<vi>		vvi;
typedef		pair<int,int>	pi;
typedef		vector<pi>		vpi;
typedef		vector<vpi>		vvpi;
typedef		vector<i64>		v64;
typedef		vector<v64>		vv64;
typedef		pair<i64,i64>	p64;
typedef		vector<p64> 	vp64;
typedef		vector<vp64>	vvp64;
typedef		vector<string>	vs;
typedef		vector<vs>		vvs;
typedef		vector<bool>	vb;
typedef		vector<vb>		vvb;
typedef		vector<char>	vc;
typedef		vector<vc>		vvc;

/* TOOLS */
template <class T>
inline T max(T a, T b, T c)
{   return max(a, max(b, c));   }

template <class T>
inline T min(T a, T b, T c)
{   return min(a, min(b, c));   }

/* ALGEBRA */
template <class T>
T gcd (T a, T b)
{    return ( b==(T)0 ?a :gcd(b,a%b) );    }

template <class T>
T lcm (T a , T b)
{    return a/gcd(a,b)*b;    }

template <class T>
T mathround (T x)
{    i64 i64x=(i64)x; if( x<i64x+0.5 ) return (T)i64x; return (T)i64x+1;    }

template <class T>
bool isprime(T x)
{
	int till = (T)sqrt(x+.0);
	if (x == 1) return 0;
	if (x == 2) return 1;
	if (x%2 == 0) return 0;
	for (int i=3; i<=till; i+=2) if (x%i == 0) return 0;
	return 1;
}

/* GEOMETRY */
template <class T>
double geodist(T x1, T y1, T x2, T y2)
{   return sqrt( square(x1-x2) + square(y1-y2) + .0 );   }

/* CONSTANTS */
const double Pi = 4.0 * atan(1.0); // 4*atan(1)

//int di[]={1, -1, 0, 0, 1, 1, -1, -1};
//int dj[]={0, 0, 1, -1, 1, -1, 1, -1};
//int mon[] = {31,28,31,30,31,30,31,31,30,31,30,31};

/* {END} */

i64 n,m;

int main()
{
	cin >> n >> m;

	if(m == 3 && n-m > 1)
	{
		cout << -1;
		return 0;
	}

	i64 x = 0;
	i64 y = 1;
	for (int i=m; i>0; i--)
	{
		cout << i+10 << " " << x << "\n";
		x += y;
		y++;
	}

	x = 0;
	y = 1;
	for (int i=1; i<=n-m; i--)
	{
		cout << -i << " " << x << "\n";
		x += y;
		y++;
	}

//	ios_base::sync_with_stdio(false);
//	freopen("input.txt", "r", stdin);		// needs disabled ios_base::sync_with_stdio(false);
//	freopen("output.txt", "w", stdout);		// needs disabled ios_base::sync_with_stdio(false);
//	cin >> noskipws;
//	cin >> skipws;

//	cout<<clock()-st;
	/*
	getchar();
	getchar();
	*/
	return EXIT_SUCCESS;
}


#include <stdio.h>

using namespace std;

int main()
{
  int n, m;
  scanf("%d %d", &n, &m);
  int x = 0, y = 0;
  if((m == 3 && n == 6) || (m == 3 && n == 5))
  {
    printf("-1");
    return 0;
  }
  for(int i = 0; i < m; i++)
  {
    x++;
    y = (x * x) + 1;
    printf("%d %d\n", x, y);
  }
  int delta = n - m;
  x = 1;
  for(int i = 0; i < delta; i++)
  {
    x++;
    y = -(x * x) - 1;
    printf("%d %d\n", x, y);
  }
  return 0;
}


#include <stdio.h>

using namespace std;

int main()
{
  int n, m;
  scanf("%d %d", &n, &m);
  int x = 0, y = 0;
  if(m < 3 || (n % m == 0 && n != m))
  {
    printf("-1");
    return 0;
  }
  for(int i = 0; i < m; i++)
  {
    printf("%d %d\n", x, y);
    x++;
    y += i + 1;
  }
  int delta = n - m;
  x += 10;
  for(int i = 0; i < delta; i++)
  {
    printf("%d %d\n", x, y);
    y -= i + 1;
    x++;
  }
  return 0;
}


#include <stdio.h>

using namespace std;

int main()
{
  int n, m;
  scanf("%d %d", &n, &m);
  int x = 0, y = 0;
  if(m < 3)
  {
    printf("-1");
    return 0;
  }
  for(int i = 0; i < m; i++)
  {
    printf("%d %d\n", x, y);
    x++;
    y += i + 1;
  }
  int delta = n - m;
  x += 10;
  for(int i = 0; i < delta; i++)
  {
    printf("%d %d\n", x, y);
    y -= i + 1;
  }
  return 0;
}


#include <stdio.h>

using namespace std;

int main()
{
  int n, m;
  scanf("%d %d", &n, &m);
  int x = 0, y = 0;
  if((m == 3 && n == 6) || (m == 3 && n == 5))
  {
    printf("-1");
    return 0;
  }
  for(int i = 0; i < m; i++)
  {
    printf("%d %d\n", x, y);
    x++;
    y = x * x + 1;
  }
  int delta = n - m;
  x = 0;
  for(int i = 0; i < delta; i++)
  {
    printf("%d %d\n", x, y);
    x++;
    y = -x * x - 1;
  }
  return 0;
}


#include <stdio.h>

using namespace std;

int main()
{
  int n, m;
  scanf("%d %d", &n, &m);
  int x = 0, y = 0;
  if(m < 3 || n % m == 0)
  {
    printf("-1");
    return 0;
  }
  for(int i = 0; i < m; i++)
  {
    printf("%d %d\n", x, y);
    x++;
    y += i + 1;
  }
  int delta = n - m;
  x += 10;
  for(int i = 0; i < delta; i++)
  {
    printf("%d %d\n", x, y);
    y -= i + 1;
  }
  return 0;
}


#include <stdio.h>

using namespace std;

int main()
{
  int n, m;
  scanf("%d %d", &n, &m);
  int x = 0, y = 0;
  if((m == 3 && n == 6) || (m == 3 && n == 5))
  {
    printf("-1");
    return 0;
  }
  for(int i = 0; i < m; i++)
  {
    printf("%d %d\n", x, y);
    x++;
    y = x * x + 1;
  }
  int delta = n - m;
  x = 0;
  for(int i = 0; i < delta; i++)
  {
    printf("%d %d\n", x, y);
    x++;
    y = -(x * x) - 1;
  }
  return 0;
}


#include <stdio.h>

using namespace std;

int main()
{
  int n, m;
  scanf("%d %d", &n, &m);
  int x = 0, y = 0;
  if(m < 3 || (n % m == 0 && n != m))
  {
    printf("-1");
    return 0;
  }
  for(int i = 0; i < m; i++)
  {
    printf("%d %d\n", x, y);
    x++;
    y += i + 1;
  }
  int delta = n - m;
  x += 10;
  for(int i = 0; i < delta; i++)
  {
    printf("%d %d\n", x, y);
    y -= i + 1;
  }
  return 0;
}


#include <sstream>
#include <fstream>
#include <string>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

int main() {

	int N, M;
	cin >> N >> M;

	if( M == 3 ){
		if( N == 5 || N == 6 ){
			cout << -1 << endl;
			return 0;
		}
	}

	for( int i = 0; i < M; i++ ){
		printf( "%d %d\n", i, static_cast<int>(1e6)+i*i );
	}
	int r = N - M;
	for( int i = 0; i < r; i++ ){
		printf( "%d %d\n", i,static_cast<int>(-1e6)-i*i );
	}
}


#include <cstdio> //PROG: CF278D
#include <cstring>
#include <algorithm>
int main(){
	#ifdef JACK1_NOTEBOOK
	freopen("CF278D_in.txt","r",stdin);
	freopen("CF278D_out.h","w",stdout);
	#endif
	int i,n,m,ary[5][2]={{0,100},{0,0},{100,0},{1,1},{1,2}};
	scanf("%d%d",&n,&m);
	if (m==3){
		if (n>=5){
			puts("-1");
		}else{
			for (m=0;m<n;m++)
				printf("%d %d\n",ary[m][0],ary[m][1]);
		}
		return 0;
	}
	int X=10000;
	for (i=0;i<m;i++)printf("%d %d\n",i,i*i+X);
	for (i=0;i<n-m;i++)printf("%d %d\n",i,-X-i*i);
}


#include <cstdio> //PROG: CF278D
#include <cstring>
#include <algorithm>
int main(){
	#ifdef JACK1_NOTEBOOK
	freopen("CF278D_in.txt","r",stdin);
	freopen("CF278D_out.h","w",stdout);
	#endif
	int i,n,m,ary[5][2]={{0,100},{0,0},{100,0},{1,1},{1,2}};
	scanf("%d%d",&n,&m);
	if (m==3){
		if (n==6){
			puts("-1");
		}else{
			for (m=0;m<n;m++)
				printf("%d %d\n",ary[m][0],ary[m][1]);
		}
		return 0;
	}
	int X=10000;
	for (i=0;i<m;i++)printf("%d %d\n",i,i*i+X);
	for (i=0;i<n-m;i++)printf("%d %d\n",i,-X-i*i);
}


#include <vector>
#include <string>
#include <algorithm>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <sstream>
#include <numeric>
#include <functional>
#include <utility>
#include <bitset>
#include <iostream>
#include <cmath>
#include <map>
#include <cstring>
#include <cstdio>
#include <stdint.h>
#include <cstdarg>
#include <cstdio>
#include <cassert>
using namespace std;

int n, m;

int main()
{
    scanf("%d %d", & n, & m);
    if (m == 3)
    {
        if (n == 3)
        {
            printf("0 0\n0 1\n1 0\n");
            return 0;
        }
        if (n == 4)
        {
            printf("0 0\n0 10\n10 0\n1 1\n");
            return 0;
        }
        printf("-1\n");
        return 0;
    }
    for (int i = 1; i <= m; ++ i)
        printf("%d %d\n", i, - (n - i) * (n - i));
    for (int i = 1; i <= n - m; ++ i)
        printf("%d %d\n", - i, (n - i) * (n - i));
}


#include<iostream>
#include<cstdio>
#include<algorithm>

using namespace std;

int main()
{
    int n,m;
    cin>>n>>m;
    if(m==3&&n>4)
    {
        cout<<-1<<endl;
        return 0;
    }
    for(int i=0;i<m;i++)
    {
        cout<<-i<<" "<<(n-i)*(n-i)<<endl;
    }
    for(int i=0;i<n-m;i++)
    {
        cout<<i<<" "<<-(n-i)*(n-i)<<endl;
    }
    return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <cstdlib>
#include <set>
#define hs(x) x*x
using namespace std;
inline int maxx(const int &a,const int &b){if (a>b)return a;return b;}
inline int minn(const int &a,const int &b){if (a<b)return a;return b;}
int a,b,c,d,e,f,g,h,i,j,k,l,m,n;
int main(){
    scanf("%d%d",&n,&m);
    if (m==3){
        if (n>4){printf("-1");return 0;}
        printf("0 0\n");
        printf("3 0\n");
        printf("0 3\n");
        if (n==4)printf("1 1\n");
        }
    if (m&1)printf("0 0\n");
    for (i=1;i<=m/2;i++){printf("%d %d\n",i,hs(i));printf("%d %d\n",-i,hs(i));}
    n-=m;
    for(i=1;i<=n/2;i++){printf("%d %d\n",i,-hs(i)-1);printf("%d %d\n",-i,-hs(i)-1);}
    if (n&1)printf("%d %d\n",m/2,-hs(m/2)-1);
    return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <cstdlib>
#include <set>
#define hs(x) x*x*x*x
using namespace std;
inline int maxx(const int &a,const int &b){if (a>b)return a;return b;}
inline int minn(const int &a,const int &b){if (a<b)return a;return b;}
int a,b,c,d,e,f,g,h,i,j,k,l,m,n;
int main(){
    scanf("%d%d",&n,&m);
    if (m==3){
        if (n>4){printf("-1");return 0;}
        printf("0 0\n");
        printf("3 0\n");
        printf("0 3\n");
        if (n==4)printf("1 1\n");
        return 0;
        }
    if (m&1)printf("0 0\n");
    for (i=1;i<=m/2;i++){printf("%d %d\n",i,hs(i));printf("%d %d\n",-i,hs(i));}
    n-=m;
    for(i=1;i<=n/2;i++){printf("%d %d\n",i,-hs(i)-1);printf("%d %d\n",-i,-hs(i)-1);}
    if (n&1)printf("%d %d\n",m/2,-hs(m/2)-1);
    return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <cstdlib>
#include <set>
#define hs(x) x*x
using namespace std;
inline int maxx(const int &a,const int &b){if (a>b)return a;return b;}
inline int minn(const int &a,const int &b){if (a<b)return a;return b;}
int a,b,c,d,e,f,g,h,i,j,k,l,m,n;
int main(){
    scanf("%d%d",&n,&m);
    if (m==3){
        if (n>4){printf("-1");return 0;}
        printf("0 0\n");
        printf("3 0\n");
        printf("0 3\n");
        if (n==4)printf("1 1\n");
        return 0;
        }
    if (m&1)printf("0 0\n");
    for (i=1;i<=m/2;i++){printf("%d %d\n",i,hs(i));printf("%d %d\n",-i,hs(i));}
    n-=m;
    for(i=1;i<=n/2;i++){printf("%d %d\n",i,-hs(i)-1);printf("%d %d\n",-i,-hs(i)-1);}
    if (n&1)printf("-10000 0\n");
    return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <cstdlib>
#include <set>
#define hs(x) x*x
using namespace std;
inline int maxx(const int &a,const int &b){if (a>b)return a;return b;}
inline int minn(const int &a,const int &b){if (a<b)return a;return b;}
int a,b,c,d,e,f,g,h,i,j,k,l,m,n;
int main(){
    scanf("%d%d",&n,&m);
    if (m==3){
        if (n>4){printf("-1");return 0;}
        printf("0 0\n");
        printf("3 0\n");
        printf("0 3\n");
        if (n==4)printf("1 1\n");
        return 0;
        }
    if (m&1)printf("0 0\n");
    for (i=1;i<=m/2;i++){printf("%d %d\n",i,hs(i));printf("%d %d\n",-i,hs(i));}
    n-=m;
    for(i=1;i<=n/2;i++){printf("%d %d\n",i,-hs(i)-1);printf("%d %d\n",-i,-hs(i)-1);}
    if (n&1)printf("-100000000 0\n");
    return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <cstdlib>
#include <set>
#define hs(x) x*x
using namespace std;
inline int maxx(const int &a,const int &b){if (a>b)return a;return b;}
inline int minn(const int &a,const int &b){if (a<b)return a;return b;}
int a,b,c,d,e,f,g,h,i,j,k,l,m,n;
int main(){
    scanf("%d%d",&n,&m);
    if (m==3){
        if (n>4){printf("-1");return 0;}
        printf("0 0\n");
        printf("3 0\n");
        printf("0 3\n");
        if (n==4)printf("1 1\n");
        return 0;
        }
    if (m&1)printf("0 0\n");
    for (i=1;i<=m/2;i++){printf("%d %d\n",i,hs(i));printf("%d %d\n",-i,hs(i));}
    n-=m;
    for(i=1;i<=n/2;i++){printf("%d %d\n",i,-hs(i)-1);printf("%d %d\n",-i,-hs(i)-1);}
    if (n&1)printf("%d %d\n",m/2,-hs(m/2)-1);
    return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <cstdlib>
#include <set>
#define hs(x) x*x
using namespace std;
inline int maxx(const int &a,const int &b){if (a>b)return a;return b;}
inline int minn(const int &a,const int &b){if (a<b)return a;return b;}
int a,b,c,d,e,f,g,h,i,j,k,l,m,n;
int main(){
    scanf("%d%d",&n,&m);
    if (m==3){
        if (n>4){printf("-1");return 0;}
        printf("0 0\n");
        printf("3 0\n");
        printf("0 3\n");
        if (n==4)printf("1 1\n");
        return 0;
        }
    if (m&1){printf("0 0\n");
    for (i=1;i<=m/2;i++){printf("%d %d\n",i,hs(i));printf("%d %d\n",-i,hs(i));}}
    else for (i=1;i<=m/2;i++){printf("%d %d\n",i,17*hs(i));printf("%d %d\n",-i,17*hs(i));}
    n-=m;
    for(i=1;i<=n/2;i++){printf("%d %d\n",i,-13*hs(i)-10086);printf("%d %d\n",-i,-13*hs(i)-10086);}
    if (n&1){i=(n/2)+1;
        printf("%d %d\n",i,-13*hs(i)-10086);
    }
    return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <cstdlib>
#include <set>
#define hs(x) x*x
using namespace std;
inline int maxx(const int &a,const int &b){if (a>b)return a;return b;}
inline int minn(const int &a,const int &b){if (a<b)return a;return b;}
int a,b,c,d,e,f,g,h,i,j,k,l,m,n;
int main(){
    scanf("%d%d",&n,&m);
    if (m==3){
        if (n>4){printf("-1");return 0;}
        printf("0 0\n");
        printf("3 0\n");
        printf("0 3\n");
        if (n==4)printf("1 1\n");
        return 0;
        }
    if (m&1)printf("0 0\n");
    for (i=1;i<=m/2;i++){printf("%d %d\n",i,hs(i));printf("%d %d\n",-i,hs(i));}
    n-=m;
    for(i=1;i<=n/2;i++){printf("%d %d\n",i,-hs(i)-1);printf("%d %d\n",-i,-hs(i)-1);}
    if (n&1)printf("0 -1");
    return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <cstdlib>
#include <set>
#define hs(x) x*x+x+1
using namespace std;
inline int maxx(const int &a,const int &b){if (a>b)return a;return b;}
inline int minn(const int &a,const int &b){if (a<b)return a;return b;}
int a,b,c,d,e,f,g,h,i,j,k,l,m,n;
int main(){
    scanf("%d%d",&n,&m);
    if (m==3){
        if (n>4){printf("-1");return 0;}
        printf("0 0\n");
        printf("3 0\n");
        printf("0 3\n");
        if (n==4)printf("1 1\n");
        return 0;
        }
    if (m&1){printf("0 0\n");
    for (i=1;i<=m/2;i++){printf("%d %d\n",i,hs(i));printf("%d %d\n",-i,hs(i));}}
    else for (i=1;i<=m/2;i++){printf("%d %d\n",i,123*hs(i));printf("%d %d\n",-i,123*hs(i));}
    n-=m;
    for(i=1;i<=n/2;i++){printf("%d %d\n",i,-13*hs(i)-10086);printf("%d %d\n",-i,-13*hs(i)-10086);}
    if (n&1){i=(n/i);
        printf("%d %d\n",i+1,-13*hs(int(i+1))-10086);
    }
    return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <cstdlib>
#include <set>
#define hs(x) x*x
using namespace std;
inline int maxx(const int &a,const int &b){if (a>b)return a;return b;}
inline int minn(const int &a,const int &b){if (a<b)return a;return b;}
int a,b,c,d,e,f,g,h,i,j,k,l,m,n;
int main(){
    scanf("%d%d",&n,&m);
    if (m==3){
        if (n>4){printf("-1");return 0;}
        printf("0 0\n");
        printf("3 0\n");
        printf("0 3\n");
        if (n==4)printf("1 1\n");
        return 0;
        }
    if (m&1){printf("0 0\n");
    for (i=1;i<=m/2;i++){printf("%d %d\n",i,hs(i));printf("%d %d\n",-i,hs(i));}}
    else for (i=1;i<=m/2;i++){printf("%d %d\n",i,123*hs(i));printf("%d %d\n",-i,123*hs(i));}
    n-=m;
    for(i=1;i<=n/2;i++){printf("%d %d\n",i,-13*hs(i)-10086);printf("%d %d\n",-i,-13*hs(i)-10086);}
    if (n&1){i=(n/i);
        printf("%d %d\n",i+1,-13*hs(int(i+1))-10086);
    }
    return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <cstdlib>
#include <set>
#define hs(x) x*x
using namespace std;
inline int maxx(const int &a,const int &b){if (a>b)return a;return b;}
inline int minn(const int &a,const int &b){if (a<b)return a;return b;}
int a,b,c,d,e,f,g,h,i,j,k,l,m,n;
int main(){
    scanf("%d%d",&n,&m);
    if (m==3){
        if (n>4){printf("-1");return 0;}
        printf("0 0");
        printf("3 0");
        printf("0 3");
        if (n==4)printf("1 1");
        }
    if (m&1)printf("0 0\n");
    for (i=1;i<=m/2;i++){printf("%d %d\n",i,hs(i));printf("%d %d\n",-i,hs(i));}
    n-=m;
    for(i=1;i<=n/2;i++){printf("%d %d\n",i,-hs(i)-1);printf("%d %d\n",-i,-hs(i)-1);}
    if (n&1)printf("%d %d\n",m/2,-hs(m/2)-1);
    return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <cstdlib>
#include <set>
#define hs(x) x*x
using namespace std;
inline int maxx(const int &a,const int &b){if (a>b)return a;return b;}
inline int minn(const int &a,const int &b){if (a<b)return a;return b;}
int a,b,c,d,e,f,g,h,i,j,k,l,m,n;
int main(){
    scanf("%d%d",&n,&m);
    if (m==3){
        if (n>4){printf("-1");return 0;}
        printf("0 0\n");
        printf("3 0\n");
        printf("0 3\n");
        if (n==4)printf("1 1\n");
        return 0;
        }
    if (m&1){printf("0 0\n");
    for (i=1;i<=m/2;i++){printf("%d %d\n",i,hs(i));printf("%d %d\n",-i,hs(i));}}
    else for (i=1;i<=m/2;i++){printf("%d %d\n",i,123*hs(i));printf("%d %d\n",-i,123*hs(i));}
    n-=m;
    for(i=1;i<=n/2;i++){printf("%d %d\n",i,-13*hs(i)-10086);printf("%d %d\n",-i,-13*hs(i)-10086);}
    if (n&1){i=(n/2);
        printf("%d %d\n",i+1,-13*hs(i+1)-10086);
    }
    return 0;
}


#include <iostream>
#include <cstdio>
using namespace std;

int main()
{
  //  freopen("test.txt","r",stdin);
    int n,m;
    while(scanf("%d %d",&n,&m)!=EOF){
        if(m==3){
            if(n==3) printf("0 0\n1 0\n0 1\n");
            else if(n==4) printf("0 0\n3 0\n0 3\n1 1\n");
            else printf("-1\n");
            continue;
        }
        for(int i=1;i<=m;i++){
            printf("%d %d\n",i,10000+i*i);
        }
        for(int i=1;i<=n-m;i++){
            printf("%d %d\n",i+m,-10000-i*i);
        }
    }
    return 0;
}
/*int main()
{
    int n,m,i;
    scanf("%d%d",&n,&m);
    if(m==3){
        if(n==3){
            printf("0 0\n3 0\n0 3\n");
            return 0;
        }
        if(n==4){
            printf("0 0\n3 0\n0 3\n1 1\n");
            return 0;
        }
        printf("-1\n");
        return 0;
    }
    for(i=1;i<=m;i++){
        printf("%d %d\n",i,-(n-i)*(n-i));
    }
    for(i=1;i<=n-m;i++){
        printf("%d %d\n",-i,(n-i)*(n-i));
    }
    return 0;
}
    return 0;
}*/


#include <iostream>
#include <cstdio>
using namespace std;

int main()
{
  //  freopen("test.txt","r",stdin);
    int n,m;
    while(scanf("%d %d",&n,&m)!=EOF){
        if(m==3){
            if(n==3) printf("0 0\n1 0\n0 1\n");
            else if(n==4) printf("0 0\n3 0\n0 3\n1 1\n");
            else printf("-1\n");
            continue;
        }
        for(int i=1;i<=m;i++){
            printf("%d %d\n",i,1000000+i*i);
        }
        for(int i=1;i<=n-m;i++){
            printf("%d %d\n",i+m,-1000000-i*i);
        }
    }
    return 0;
}
/*int main()
{
    int n,m,i;
    scanf("%d%d",&n,&m);
    if(m==3){
        if(n==3){
            printf("0 0\n3 0\n0 3\n");
            return 0;
        }
        if(n==4){
            printf("0 0\n3 0\n0 3\n1 1\n");
            return 0;
        }
        printf("-1\n");
        return 0;
    }
    for(i=1;i<=m;i++){
        printf("%d %d\n",i,-(n-i)*(n-i));
    }
    for(i=1;i<=n-m;i++){
        printf("%d %d\n",-i,(n-i)*(n-i));
    }
    return 0;
}
    return 0;
}*/


#include <iostream>
#include <cstdio>
using namespace std;

int main()
{
//    freopen("test.txt","r",stdin);
    int n,m;
    while(scanf("%d %d",&n,&m)!=EOF){
        if(m==3){
            if(n==3) printf("0 0\n1 0\n0 1\n");
            else if(n==4) printf("0 0\n3 0\n0 3\n1 1\n");
            else printf("-1\n");
            continue;
        }
        for(int i=1;i<=m;i++){
            printf("%d %d\n",i,10000+i*i);
        }
        for(int i=1;i<=n-m;i++){
            printf("%d %d\n",i+m,-10000+i*i);
        }
    }
    return 0;
}


#include <iostream>
#include <cstdio>
using namespace std;

int main()
{
 //   freopen("test.txt","r",stdin);
    int n,m;
    while(scanf("%d %d",&n,&m)!=EOF){
        if(m==3){
            if(n==3) printf("0 0\n1 0\n0 1\n");
            else if(n==4) printf("0 0\n3 0\n0 3\n1 1\n");
            else printf("-1\n");
        }
        for(int i=1;i<=m;i++){
            printf("%d %d\n",i,10000+i*i);
        }
        for(int i=1;i<=n-m;i++){
            printf("%d %d\n",i+m,-10000+i*i);
        }
    }
    return 0;
}


#include <cstdio>
int main(){
    int n, m;
    scanf("%d%d", &n, &m);
    if(m==3 && n > 4){
        puts("-1");
        return 0;
    }
    for(int i = 1; i <= m; ++i)
        printf("%d %d\n", i, i*i);
    for(int i = 1; i <= n-m; ++i)
        printf("%d %d\n", i, -1000000-i*i);
    return 0;
}


#include <cstdio>
#include <iostream>
using namespace std;

int main()
{
    int n,m;
    cin>>n>>m;
    if (m==3&&m>4)
    {
        puts("-1");return 0;
    }
    for (int i=1;i<=m;++i)
     printf("%d %d\n",i*i+100000,i);
    for (int i=1;i<=n-m;++i)
     printf("%d %d\n",-i*i,i);
    return 0;
}


#include <cstdio>
#include <iostream>
using namespace std;

int main()
{
    int n,m;
    cin>>n>>m;
    if (m==3&&n>4)
    {
        puts("-1");return 0;
    }
    for (int i=1;i<=m;++i)
     printf("%d %d\n",i*i+100000,i);
    for (int i=1;i<=n-m;++i)
     printf("%d %d\n",-i*i,i);
    return 0;
}


#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
  int n,m;
  cin>>n>>m;
  if (m==3&&n>4)
  {
    printf("-1");
    return 0;
  }
  for (int i=1;i<=m/2;i++)
    cout<<-100000+500*i<<' '<<-200000+1000*i<<endl;
  for (int i=1;i<=m-m/2;i++)
    cout<<-100000+500*i<<' '<<200000-1000*i<<endl;
  for (int i=1;i<=n-m;i++)
    cout<<50*i-100000+500*i<<' '<<60*i<<endl;
  return 0;
}

/*fpctsnhmqgfdicedahobinpmstbjsaodhqofjbrripbirrljqr*/


#include<iostream>
#include<cstdio>
#include<cmath>
#define pi 3.14159265
using namespace std;
int main()
{
    int m,n,a,b;
    scanf("%d%d",&n,&m);
    if(m==3&&n>4)
    {
        cout<<-1<<endl;
    }
    else
    {
        int l=n-m;
        for(int i=0;i<l;i++)
        {
            a=10*sin((double)i*pi*2/(double)l);
            b=10*cos((double)i*pi*2/(double)l);
            cout<<a<<" "<<b<<endl;
        }
        for(int i=0;i<m;i++)
        {
            a=10000*sin((double)i*pi*2/(double)m)+1;
            b=10000*cos((double)i*pi*2/(double)m)+1;
            cout<<a<<" "<<b<<endl;
        }
    }
    return 0;
}

/*nlqhtbihjhobqhhjqfjfoidsnsaqrtnkkjjkcjjlqdmnltctqd*/


#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
  int n,m;
  cin>>n>>m;
  if (m==3&&n>4)
  {
    printf("-1");
    return 0;
  }
  for (int i=1;i<=m/2;i++)
    cout<<-100000+500*i<<' '<<-1000000+(500+5*i)*i<<endl;
  for (int i=1;i<=m-m/2;i++)
    cout<<-100000+500*i<<' '<<1000000-(500+5*i)*i<<endl;
  for (int i=1;i<=n-m;i++)
    cout<<50*i-100000+500*1<<' '<<60*i<<endl;
  return 0;
}

/*ftkqicaqondkllqdncfcljcqjqksqnbbedjegcampqcghljafp*/


#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#define MAXN 1111
#define INF 10111111
#define PI acos(-1.0)
using namespace std;
int main()
{
    int n, m;
    while(scanf("%d%d", &n, &m) != EOF)
    {
        if((n == 6 && m == 3) || (n == 5 && m == 3))
        {
            printf("-1\n");
            continue;
        }
        for(int i = 0; i < m; i++) printf("%d %d\n", i, i * i + INF);
        for(int i = 0; i < n - m; i++) printf("%d %d\n", i, -i * i);
    }
    return 0;
}

/*qelacgimdqhmsqmldcbdcitfkcbhnrebchcqokijshbrefathb*/


#include<cstdio>
#include<cmath>
#define pi 3.1415
int x[200],y[200];
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    if(m==3&&n>4)
    {
        printf("-1\n");
        return 0;
    }
    for(int i=0;i<m;i++)
    {
        printf("%d %d\n",i,i*i+1000000);
    }
    for(int i=0;i<n-m;i++)
    {
        printf("%d %d\n",-i,-i*i-1000000);
    }
    return 0;
}

/*tkgkcjljgdiipkrefchlltdjimkjskajmglphdqfsfnnhdkmfj*/


#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
  int n,m;
  cin>>n>>m;
  if (m==3&&n>4)
  {
    printf("-1");
    return 0;
  }
  for (int i=1;i<=m/2;i++)
    cout<<-100000+500*i<<' '<<-1000000+(500+5*i)*i<<endl;
  for (int i=1;i<=m-m/2;i++)
    cout<<-100000+500*i<<' '<<1000000-(500+5*i)*i<<endl;
  for (int i=1;i<=n-m;i++)
    cout<<1000*i-100000+1000<<' '<<i*i<<endl;
  return 0;
}

/*aheknebbbsbdnbomgpkasparoreqfpjfpniirbkstdcfeirdph*/


#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
  int n,m;
  cin>>n>>m;
  if (m==3&&n>4)
  {
    printf("-1");
    return 0;
  }
  for (int i=1;i<=m/2;i++)
    cout<<-100000+500*i<<' '<<-1000000+(500+5*i)*i<<endl;
  for (int i=1;i<=m-m/2;i++)
    cout<<-100000+500*i<<' '<<1000000-(500+5*i)*i<<endl;
  for (int i=1;i<=n-m;i++)
    cout<<50*i-100000+500*i<<' '<<60*i<<endl;
  return 0;
}

/*lpnhaomjefciaislipjddajqnbrgofnrasrnejcigqjgftkfpt*/


#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    if(m == 3 && n > 4)
    {
        printf("-1\n");
    }
    else
    {
        for(int i = 0; i < m; ++ i)
        {
            printf("%d %d\n", i, 100000 + i * i);
        }
        n -= m;
        for(int i = 0; i < n; ++ i)
        {
            printf("%d %d\n", i, - 100000 - i * i);
        }
    }
    return 0;
}

/*nlshoakraobfhogldpqmrcbfasmfnpnhslgmlrkdddakrhnbcj*/


#include<iostream>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<iomanip>
#include<cstdio>
using namespace std;
int main()
{
    int n,m,i;
    scanf("%d%d",&n,&m);
    if(n>4&&m==3)
    {
        printf("-1\n");
    }
    else
    {
        for(i=0; i<m; ++i)
        {
            printf("%d %d\n",i,i*i+11111);
        }
        n=n-m;
        for(i=0;i<n;++i)
        {
            printf("%d %d\n",i,i*i);
        }
    }
    return 0;
}

/*ctnnkotgothhfjsrnqpqdtbshgqegobbnoopbgnpfbcckmmdah*/


#include<cstdio>
#include<cmath>
#define pi 3.1415
int x[200],y[200];
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    if(m==3&&n>4)
    {
        printf("-1\n");
        return 0;
    }
    for(int i=0;i<m;i++)
    {
        printf("%d %d\n",i,i*i+100);
    }
    for(int i=0;i<n-m;i++)
    {
        printf("%d %d\n",-i,-i*i-100);
    }
    return 0;
}

/*ipekdhkfdiogplblenicdbfiepkqnphnkddncflgfremardell*/


#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
  int n,m;
  cin>>n>>m;
  if (m==3&&n>4)
  {
    printf("-1");
    return 0;
  }
  for (int i=1;i<=m/2;i++)
    cout<<-100000+500*i<<' '<<-200000+(500+50*i)*i<<endl;
  for (int i=1;i<=m-m/2;i++)
    cout<<-100000+500*i<<' '<<200000-(500+50*i)*i<<endl;
  for (int i=1;i<=n-m;i++)
    cout<<50*i-100000+500*i<<' '<<60*i<<endl;
  return 0;
}

/*deqinshffhihaahtmissslpsacdiqcalgjtlhgjnormgjarcap*/


#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
  int n,m;
  cin>>n>>m;
  if (m==3&&n>4)
  {
    printf("-1");
    return 0;
  }
  cout<<0<<' '<<0<<endl;
  for (int i=1;i<=m/2;i++)
    cout<<50*i+500<<' '<<10*i*i*i<<endl;
  for (int i=1;i<=m-m/2-1;i++)
    cout<<-50*i-500<<' '<<10*i*i*i<<endl;
  for (int i=1;i<=(n-m)/2;i++)
    cout<<20*i<<' '<<i*i<<endl;
  for (int i=1;i<=n-m-(n-m)/2;i++)
    cout<<-20*i<<' '<<i*i<<endl;
  return 0;
}

/*ednhnlpnbcemdaihrmkssbqrhgohsgdobjnomjindergefgnjq*/


#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
  int n,m;
  cin>>n>>m;
  if (m==3&&n>4)
  {
    printf("-1");
    return 0;
  }
  for (int i=1;i<=m/2;i++)
    cout<<-100000+500000*i<<' '<<-100000+70*i<<endl;
  for (int i=1;i<=m-m/2;i++)
    cout<<-100000+500500*i<<' '<<100000-80*i<<endl;
  for (int i=1;i<=n-m;i++)
    cout<<50*i-100000+500000*i<<' '<<60*i<<endl;
  return 0;
}

/*lcclqlfimotcshjjnjircqkoqjjctmhcgjfcnlcrrctpbjeose*/


#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
  int n,m;
  cin>>n>>m;
  if (m==3&&n>4)
  {
    printf("-1");
    return 0;
  }
  for (int i=1;i<=m/2;i++)
    cout<<-100000+500*i<<' '<<-1000000+(500+5*i)*i<<endl;
  for (int i=1;i<=m-m/2;i++)
    cout<<-100000+500*i<<' '<<1000000-(500+5*i)*i<<endl;
  for (int i=1;i<=n-m;i++)
    cout<<50*i-100000+500*1<<' '<<i*i<<endl;
  return 0;
}

/*sffnlphqjdgqoqqnrggsjrrkikjatbijtnocictsrrglnoqkao*/


#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#define MAXN 1111
#define INF 1011111111
#define PI acos(-1.0)
using namespace std;
int x[111], y[111];

int main()
{
    int n, m;
    while(scanf("%d%d", &n, &m) != EOF)
    {
        int r = 80000000;
        for(int i = 0; i < m; i++)
        {
            double rad = 2.0 * PI / m * i;
            x[i] = (int)(r * 1.0 * cos(rad));
            y[i] = (int)(r * 1.0 * sin(rad));
        }
        for(int i = m; i < n; i++)
        {
            double rad = 2.0 * PI / m * (i - m);
            x[i] = (int)(r * 1.0 * cos(rad) / 2.0);
            y[i] = (int)(r * 1.0 * sin(rad) / 2.0);
        }
        for(int i = 0; i < n; i++) printf("%d %d\n", x[i], y[i]);
    }
    return 0;
}

/*bjcmgpfqebkkinrqnpihqrnrdicgtdjaemfktkspdifmcpihci*/


#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
  int n,m;
  cin>>n>>m;
  if (m==3&&n>4)
  {
    printf("-1");
    return 0;
  }
  for (int i=1;i<=m/2;i++)
    cout<<50*i<<' '<<500*i*i<<endl;
  for (int i=1;i<=m-m/2;i++)
    cout<<-50*i<<' '<<500*i*i<<endl;
  for (int i=1;i<=n-m;i++)
    cout<<20*i<<' '<<i*i+10<<endl;
  return 0;
}

/*tsonfkpipjtsktpajiikgqmaiqeikimksgppjlpemgpcskohsc*/


#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
  int n,m;
  cin>>n>>m;
  if (m==3&&n>4)
  {
    printf("-1");
    return 0;
  }
  for (int i=1;i<=m/2;i++)
    cout<<-100000+500000*i<<' '<<-200000+1000*i<<endl;
  for (int i=1;i<=m-m/2;i++)
    cout<<-100000+500500*i<<' '<<200000-700*i<<endl;
  for (int i=1;i<=n-m;i++)
    cout<<50*i-100000+500500*i<<' '<<60*i<<endl;
  return 0;
}

/*rlhijpbmkkjgoaakheolprbrtamkgdkdosdqneiqgkcakodrsr*/


#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
  int n,m;
  cin>>n>>m;
  if (m==3&&n>4)
  {
    printf("-1");
    return 0;
  }
  for (int i=1;i<=m/2;i++)
    cout<<-100000+500*i<<' '<<-200000+1000*i+50<<endl;
  for (int i=1;i<=m-m/2;i++)
    cout<<-100000+500*i<<' '<<200000-1000*i-50<<endl;
  for (int i=1;i<=n-m;i++)
    cout<<50*i-100000+500*i<<' '<<60*i<<endl;
  return 0;
}

/*kbipbitrglhcifgtqrhdptrbdodjmtroafjogilmlkotqmkmks*/


#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main()
{
    int m,n,a,b;
    scanf("%d%d",&n,&m);
    if(m==3&&n>4)
    {
        cout<<-1<<endl;
    }
    else
    {
        for(int i=1;i<=m;i++)
        {
            cout<<i<<" "<<1000000+i*i<<endl;
        }
        n-=m;
        for(int i=1;i<=n;i++)
        {
            cout<<i<<" "<<-1000000-i*i<<endl;
        }
    }
    return 0;
}

/*aicokondtljarcogitldjrhnetqistpstjecdsfpbhhsjbejnh*/


#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
  int n,m;
  cin>>n>>m;
  if (m==3&&n>4)
  {
    printf("-1");
    return 0;
  }
  cout<<0<<' '<<0<<endl;
  for (int i=1;i<=m/2;i++)
    cout<<50*i<<' '<<500*i*i<<endl;
  for (int i=1;i<=m-m/2-1;i++)
    cout<<-50*i<<' '<<500*i*i<<endl;
  for (int i=1;i<=n-m;i++)
    cout<<20*i+10<<' '<<450*i*i<<endl;
  for (int i=1;i<=n-m-(n-m)/2;i++)
    cout<<-20*i-10<<' '<<450*i*i<<endl;
  return 0;
}

/*pptdddbiitjjhredknfbilcgpkftakiistlbcejkqkldaqskbe*/


#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
  int n,m;
  cin>>n>>m;
  if (m==3&&n>4)
  {
    printf("-1");
    return 0;
  }
  for (int i=1;i<=m/2;i++)
    cout<<-100000+500*i<<' '<<-1000000+(500+5*i)*i<<endl;
  for (int i=1;i<=m-m/2;i++)
    cout<<-100000+500*i<<' '<<1000000-(500+5*i)*i<<endl;
  for (int i=1;i<=n-m;i++)
    cout<<47*i-100000+500<<' '<<i*i<<endl;
  return 0;
}

/*hngckgrcfmsairjbroqtifpncfngokobdadohnimfsmopnpehl*/


#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
  int n,m;
  cin>>n>>m;
  if (m==3&&n>4)
  {
    printf("-1");
    return 0;
  }
  int num=1;
  for (int i=-m/2;num<=m;num++,i++)
    cout<<i<<' '<<i*i+10000000<<endl;
  num=1;
  for (int i=-(n-m)/2;num<=n-m;num++,i++)
    cout<<i<<' '<<-i*i-10000000<<endl;
  return 0;
}

/*ookpsshisqcarejronjfcsgcjbqtgjbaelqocddaarmrnngthp*/