#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
//#include<atcoder/all>
//using namespace atcoder;
#include<iostream>
#include<cstring>
#include<vector>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


ll dp[1 << 18];
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);


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

	vector<pair<int, int>> XYZ[20];
	rep(i, M) {
		int x, y, z;
		cin >> x >> y >> z;
		XYZ[y].pb({ x, z });
	}

	dp[0] = 1;
	rep(i, 1 << N) {
		int c = __builtin_popcount(i);
		int OK = 1;
		for (auto p : XYZ[c]) {
			if (__builtin_popcount(i << 32 - p.first) > p.second) {
				OK = 0;
				break;
			}
		}
		if (!OK) {
			dp[i] = 0;
		}
		else {
			int tmp = i;
			for(int j = i + 1; j < (1 << N); j = tmp + 1) {
				dp[i | j] += dp[i];
				tmp |= j;
			}
		}
	}
	co(dp[(1 << N) - 1]);


	Would you please return 0;
}
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int>pii;
#define sf(x) scanf("%d",&x)
#define sfl(x) scanf("%lld",&x)
#define lli long long int
#define ll64 int64_t
#define pb push_back
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define frr(i,a) for(int i=0;i<a;i++)
#define frl(i,a) for(lli i=0;i<a;i++)
#define iter(x)  x.begin(),x.end()

int main()
{
    int n,m;
    cin>>n>>m;
    if(m==0)
    {
        int c=1;
        for(int i=1;i<=n;i++)
        {
            cout<<c<<" "<<c+1<<endl;
            c+=2;
        }
    }
    else if(m+2>n || m<0)
    {
        cout<<-1<<endl;
    }
    else
    {
        lli x=1000000000;
        int c=1;
        for(int i=m+2;i<=n;i++)
        {
            cout<<c++<<" "<<x--<<endl;
        }
        for(int i=1;i<=m+1;i++)
        {
            cout<<c<<" "<<c+1<<endl;
            c+=2;
        }

    }
}
