#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<bool> vb;
typedef vector<string> vs;
const int di[] = { 0, 1 };
const int dj[] = { 1, 0 };
const ll MOD = 1e9 + 9;
const ll INF = 1e9;
const long double EPS = 1e-7;
#define all(n) n.begin(),n.end()

int n, m, k;
vb inA;
vi a, b;

bool test(vvi& adj) {
	vvi ans = adj;
	for (int i = 0; i < k; i++) {
		int v = a[i];
		for (int j = 0; j < n; j++)
			for (int r = 0; r < n; r++)
				ans[j][r] = min(ans[j][r], ans[j][v] + ans[v][r]);
	}

	vvi ans2 = adj;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++)
			for (int r = 0; r < n; r++)
				ans2[j][r] = min(ans2[j][r], ans2[j][i] + ans2[i][r]);
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (ans[i][j] != ans2[i][j])
				return true;
		}
	}
	return false;
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n >> m >> k;
	inA.resize(n);

	for (int i = 0; i < k; i++) {
		int x; cin >> x; x--;
		inA[x] = true;
		a.push_back(x);
	}
	for (int i = 0; i < n; i++) {
		if (!inA[i])
			b.push_back(i);
	}

	vvi adj(n, vi(n, INF));

	for (int i = 1; (i < a.size() || i < b.size()) && m; i++) {
		if (i >= a.size())
			adj[a.back()][b[i]] = adj[b[i]][a.back()] = 1;
		else if (i >= b.size())
			adj[a[i]][b.back()] = adj[b.back()][a[i]] = 1;
		else
			adj[a[i]][b[i]] = adj[b[i]][a[i]] = 1;
		m--;
	}

	for (int i = 0; i < b.size() && m; i++) {
		for (int j = 0; j < a.size() && m; j++) {
			if (adj[a[j]][b[i]] != INF) continue;
			adj[a[j]][b[i]] = adj[b[i]][a[j]] = 1;
			m--;
		}
	}
	for (int i = 0; i < b.size() && m; i++) {
		for (int j = i + 1; j < b.size() && m; j++) {
			if (adj[b[j]][b[i]] != INF) continue;
			adj[b[j]][b[i]] = adj[b[i]][b[j]] = 1;
			m--;
		}
	}
	for (int i = 0; i < n && m; i++) {
		for (int j = i + 1; j < n && m; j++) {
			if (adj[i][j] != INF) continue;
			adj[i][j] = adj[j][i] = 1;
			m--;
		}
	}

	if (test(adj) && !m) {
		set<pii> st;
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				if (adj[i][j] != INF) {
					cout << i + 1 << " " << j + 1 << endl;
				}
			}
		}
	}
	else cout << -1 << endl;

	cin.ignore(), cin.get();
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<bool> vb;
typedef vector<string> vs;
const int di[] = { 0, 1 };
const int dj[] = { 1, 0 };
const ll MOD = 1e9 + 9;
const ll INF = 1e9;
const long double EPS = 1e-7;
#define all(n) n.begin(),n.end()

int n, m, k;
vb inA;
vi a, b;

bool test(vvi& adj) {
	vvi ans = adj;
	for (int i = 0; i < k; i++) {
		int v = a[i];
		for (int j = 0; j < n; j++)
			for (int r = 0; r < n; r++)
				ans[j][r] = min(ans[j][r], ans[j][v] + ans[v][r]);
	}

	vvi ans2 = adj;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++)
			for (int r = 0; r < n; r++)
				ans2[j][r] = min(ans2[j][r], ans2[j][i] + ans2[i][r]);
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (ans[i][j] != ans2[i][j])
				return true;
		}
	}
	return false;
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n >> m >> k;
	inA.resize(n);

	for (int i = 0; i < k; i++) {
		int x; cin >> x; x--;
		inA[x] = true;
		a.push_back(x);
	}
	for (int i = 0; i < n; i++) {
		if (!inA[i])
			b.push_back(i);
	}

	vvi adj(n, vi(n, INF));

	if (!b.empty()) for (int i = 1; (i < a.size() || i < b.size()) && m; i++) {
		if (i >= a.size())
			adj[b[0]][b[i]] = adj[b[i]][b[0]] = 1;
		else if (i >= b.size())
			adj[a[i]][b.back()] = adj[b.back()][a[i]] = 1;
		else
			adj[a[i]][b[i]] = adj[b[i]][a[i]] = 1;
		m--;
	}

	for (int i = 0; i < b.size() && m; i++) {
		for (int j = 0; j < a.size() && m; j++) {
			if (adj[a[j]][b[i]] != INF) continue;
			adj[a[j]][b[i]] = adj[b[i]][a[j]] = 1;
			m--;
		}
	}
	for (int i = 0; i < b.size() && m; i++) {
		for (int j = i + 1; j < b.size() && m; j++) {
			if (adj[b[j]][b[i]] != INF) continue;
			adj[b[j]][b[i]] = adj[b[i]][b[j]] = 1;
			m--;
		}
	}
	for (int i = 0; i < n && m; i++) {
		for (int j = i + 1; j < n && m; j++) {
			if (adj[i][j] != INF) continue;
			adj[i][j] = adj[j][i] = 1;
			m--;
		}
	}

	if (test(adj) && !m) {
		set<pii> st;
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				if (adj[i][j] != INF) {
					cout << i + 1 << " " << j + 1 << endl;
				}
			}
		}
	}
	else cout << -1 << endl;

	cin.ignore(), cin.get();
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<bool> vb;
typedef vector<string> vs;
const int di[] = { 0, 1 };
const int dj[] = { 1, 0 };
const ll MOD = 1e9 + 9;
const ll INF = 1e9;
const long double EPS = 1e-7;
#define all(n) n.begin(),n.end()

int n, m, k;
vb inA;
vi a, b;

bool test(vvi& adj) {
	vvi ans = adj;
	for (int i = 0; i < k; i++) {
		int v = a[i];
		for (int j = 0; j < n; j++)
			for (int r = 0; r < n; r++)
				ans[j][r] = min(ans[j][r], ans[j][v] + ans[v][r]);
	}

	vvi ans2 = adj;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++)
			for (int r = 0; r < n; r++)
				ans2[j][r] = min(ans2[j][r], ans2[j][i] + ans2[i][r]);
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (ans[i][j] != ans2[i][j])
				return true;
		}
	}
	return false;
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n >> m >> k;
	inA.resize(n);

	for (int i = 0; i < k; i++) {
		int x; cin >> x; x--;
		inA[x] = true;
		a.push_back(x);
	}
	for (int i = 0; i < n; i++) {
		if (!inA[i])
			b.push_back(i);
	}

	vvi adj(n, vi(n, INF));

	if (!b.empty()) for (int i = 1; (i < a.size() || i < b.size()) && m; i++) {
		if (i >= a.size())
			adj[a.back()][b[i]] = adj[b[i]][a.back()] = 1;
		else if (i >= b.size())
			adj[a[i]][b.back()] = adj[b.back()][a[i]] = 1;
		else
			adj[a[i]][b[i]] = adj[b[i]][a[i]] = 1;
		m--;
	}

	for (int i = 0; i < b.size() && m; i++) {
		for (int j = 0; j < a.size() && m; j++) {
			if (adj[a[j]][b[i]] != INF) continue;
			adj[a[j]][b[i]] = adj[b[i]][a[j]] = 1;
			m--;
		}
	}
	for (int i = 0; i < b.size() && m; i++) {
		for (int j = i + 1; j < b.size() && m; j++) {
			if (adj[b[j]][b[i]] != INF) continue;
			adj[b[j]][b[i]] = adj[b[i]][b[j]] = 1;
			m--;
		}
	}
	for (int i = 0; i < n && m; i++) {
		for (int j = i + 1; j < n && m; j++) {
			if (adj[i][j] != INF) continue;
			adj[i][j] = adj[j][i] = 1;
			m--;
		}
	}

	if (test(adj) && !m) {
		set<pii> st;
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				if (adj[i][j] != INF) {
					cout << i + 1 << " " << j + 1 << endl;
				}
			}
		}
	}
	else cout << -1 << endl;

	cin.ignore(), cin.get();
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<bool> vb;
typedef vector<string> vs;
const int di[] = { 0, 1 };
const int dj[] = { 1, 0 };
const ll MOD = 1e9 + 9;
const ll INF = 1e9;
const long double EPS = 1e-7;
#define all(n) n.begin(),n.end()

int n, m, k;
vb inA;
vi a, b;

bool test(vvi& adj) {
	vvi ans = adj;
	for (int i = 0; i < k; i++) {
		int v = a[i];
		for (int j = 0; j < n; j++)
			for (int r = 0; r < n; r++)
				ans[j][r] = min(ans[j][r], ans[j][v] + ans[v][r]);
	}

	vvi ans2 = adj;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++)
			for (int r = 0; r < n; r++)
				ans2[j][r] = min(ans2[j][r], ans2[j][i] + ans2[i][r]);
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (ans[i][j] != ans2[i][j])
				return true;
		}
	}
	return false;
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n >> m >> k;
	inA.resize(n);

	for (int i = 0; i < k; i++) {
		int x; cin >> x; x--;
		inA[x] = true;
		a.push_back(x);
	}
	for (int i = 0; i < n; i++) {
		if (!inA[i])
			b.push_back(i);
	}

	vvi adj(n, vi(n, INF));

	for (int i = 1; i < a.size() && i < b.size() && m; i++) {
		adj[a[i]][b[i]] = adj[b[i]][a[i]] = 1;
		m--;
	}
	for (int i = b.size() - 1; i >= 0; i--) {
		if (adj[b[i]][a.back()] != INF) break;
		adj[a[i]][b[i]] = adj[b[i]][a[i]] = 1;
		m--;
	}

	for (int i = 0; i < b.size() && m; i++) {
		for (int j = 0; j < a.size() && m; j++) {
			if (adj[a[j]][b[i]] != INF) continue;
			adj[a[j]][b[i]] = adj[b[i]][a[j]] = 1;
			m--;
		}
	}

	if (test(adj) && !m) {
		set<pii> st;
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				if (adj[i][j] != INF) {
					cout << i + 1 << " " << j + 1 << endl;
				}
			}
		}
	}
	else cout << -1 << endl;

	cin.ignore(), cin.get();
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<bool> vb;
typedef vector<string> vs;
const int di[] = { 0, 1 };
const int dj[] = { 1, 0 };
const ll MOD = 1e9 + 9;
const ll INF = 1e9;
const long double EPS = 1e-7;
#define all(n) n.begin(),n.end()

int n, m, k;
vb inA;
vi a, b;

bool test(vvi& adj) {
	vvi ans = adj;
	for (int i = 0; i < k; i++) {
		int v = a[i];
		for (int j = 0; j < n; j++)
			for (int r = 0; r < n; r++)
				ans[j][r] = min(ans[j][r], ans[j][v] + ans[v][r]);
	}

	vvi ans2 = adj;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++)
			for (int r = 0; r < n; r++)
				ans2[j][r] = min(ans2[j][r], ans2[j][i] + ans2[i][r]);
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (ans[i][j] != ans2[i][j])
				return true;
		}
	}
	return false;
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n >> m >> k;
	inA.resize(n);

	for (int i = 0; i < k; i++) {
		int x; cin >> x; x--;
		inA[x] = true;
		a.push_back(x);
	}
	for (int i = 0; i < n; i++) {
		if (!inA[i])
			b.push_back(i);
	}

	vvi adj(n, vi(n, INF));

	for (int i = 1; (i < a.size() || i < b.size()) && m; i++) {
		if (i >= a.size())
			adj[a.back()][b[i]] = adj[b[i]][a.back()] = 1;
		else if (i >= b.size())
			adj[a[i]][b.back()] = adj[b.back()][a[i]] = 1;
		else
			adj[a[i]][b[i]] = adj[b[i]][a[i]] = 1;
		m--;
	}

	for (int i = 0; i < b.size() && m; i++) {
		for (int j = 0; j < a.size() && m; j++) {
			if (adj[a[j]][b[i]] != INF) continue;
			adj[a[j]][b[i]] = adj[b[i]][a[j]] = 1;
			m--;
		}
	}

	if (test(adj) && !m) {
		set<pii> st;
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				if (adj[i][j] != INF) {
					cout << i + 1 << " " << j + 1 << endl;
				}
			}
		}
	}
	else cout << -1 << endl;

	cin.ignore(), cin.get();
}


#include <iostream>
#include <vector>

using namespace std;

vector<int> Z;

void Stworz(int n)
{
    for (int i = 0; i < n; ++i)
        Z.push_back(i);
}

int Find(int a)
{
    if (Z[a] == a)
        return a;
    int fa = Find(Z[a]);
    Z[a] = fa;
    return fa;
}

void Union(int a, int b)
{
    int fa = Find(a);
    int fb = Find(b);
    Z[fa] = fb;
}

int main()
{
    ios_base::sync_with_stdio(0);
    int n, m, k;
    cin >> n >> m >> k;
    vector<bool> zb(n, false);
    int wyr;
    for (int i = 0; i < k; ++i)
    {
        int x;
        cin >> x;
        --x;
        wyr = x;
        zb[x] = true;
    }
    if (k == n || m > n * (n - 1) / 2 - (k - 1))
    {
        cout << "-1";
        return 0;
    }
    vector< vector<bool> > G(n, vector<bool>(n, false));
    Stworz(n);
    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < n; ++j)
        {
            if (i == j)
                continue;
            if (!((i == wyr && zb[j]) || (zb[i] && j == wyr)))
            {
                if (Find(i) != Find(j))
                {
                    G[i][j] = true;
                    G[j][i] = true;
                    Union(i, j);
                }
            }
        }
    }
    int mam = n - 1;
    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < n; ++j)
        {
            if (i == j)
                continue;
            if (!((i == wyr && zb[j]) || (zb[i] && j == wyr)))
            {
                if (!G[i][j] && mam < m)
                {
                    G[i][j] = true;
                    G[j][i] = true;
                    ++m;
                }
            }
        }
    }
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < n; ++j)
            if (i < j && G[i][j])
                cout << i + 1 << " " << j + 1 << endl;
    return 0;
}


#include <iostream>
#include <vector>

using namespace std;

vector<int> Z;

void Stworz(int n)
{
    for (int i = 0; i < n; ++i)
        Z.push_back(i);
}

int Find(int a)
{
    if (Z[a] == a)
        return a;
    int fa = Find(Z[a]);
    Z[a] = fa;
    return fa;
}

void Union(int a, int b)
{
    int fa = Find(a);
    int fb = Find(b);
    Z[fa] = fb;
}

int main()
{
    ios_base::sync_with_stdio(0);
    int n, m, k;
    cin >> n >> m >> k;
    vector<bool> zb(n, false);
    int wyr;
    for (int i = 0; i < k; ++i)
    {
        int x;
        cin >> x;
        --x;
        wyr = x;
        zb[x] = true;
    }
    if (k == n || m > n * (n - 1) / 2 - (k - 1))
    {
        cout << "-1";
        return 0;
    }
    vector< vector<bool> > G(n, vector<bool>(n, false));
    Stworz(n);
    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < n; ++j)
        {
            if (i == j)
                continue;
            if (!((i == wyr && zb[j]) || (zb[i] && j == wyr)))
            {
                if (Find(i) != Find(j))
                {
                    G[i][j] = true;
                    G[j][i] = true;
                    Union(i, j);
                }
            }
        }
    }
    int mam = n - 1;
    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < n; ++j)
        {
            if (i == j)
                continue;
            if (!((i == wyr && zb[j]) || (zb[i] && j == wyr)))
            {
                if (!G[i][j] && mam < m)
                {
                    G[i][j] = true;
                    G[j][i] = true;
                    ++mam;
                }
            }
        }
    }
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < n; ++j)
            if (i < j && G[i][j])
                cout << i + 1 << " " << j + 1 << endl;
    return 0;
}


                                    /* Survive. Live. Win. Conquer.*/

#include<bits/stdc++.h>
using namespace std;
typedef long long LL ;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

#define ook order_of_key
#define fbk find_by_order
#define bug printf("TRUST\n");
#define pf printf
#define sf scanf
#define lp(i, n) for(int i = 0; i < n; i++)
#define rlp(n, i) for(int i = n - 1; i >= 0; i--)
#define bye vector<LL>
#define pb push_back
#define r0 return 0
#define ff first
#define ss second
#define mp make_pair
#define pii pair <int, int>
#define sz(a) ((int)a.size())
#define set0(a) memset ((a), 0 , sizeof(a))
#define set1(a) memset((a),-1,sizeof (a))
#define si(a) scanf("%d" , &a)
#define sl(a) scanf("%lld" , &a)
#define sii(a,b) scanf("%d %d" , &a , &b)
#define siii(a,b,c) scanf("%d %d %d" , &a , &b, &c)
#define sll(a,b) scanf("%lld %lld" , &a , &b)
#define slll(a,b,c) scanf("%lld %lld %lld" , &a , &b, &c)
#define FOR(i,a,b) for(LL i = (a) ; i <= (b) ; i++)
#define mod 1000000007
#define nod 200003

//using namespace __gnu_pbds;
//typedef tree < int, null_type ,less<int>,rb_tree_tag,tree_order_statistics_node_update > ordered_set;

void func(void)
{
        freopen("input.c","r",stdin);
        freopen("output.c","w",stdout);
}
const int N = 1e3;
set <LL> s, s1;
LL edgeSet[N][N];
void kEqualsN(LL n, LL m){
    LL now = 1;
    //cout << m << endl;
    for(int i  = now + 1; i <= n and m; i++){

            edgeSet[i][now] = 1;
            edgeSet[now][i] = 1;
            now = i;
            m--;

    }
   // cout << m << endl;
    for(int i = 1; i <= n and m; i++){
        for(int j = 1; j <= n and m; j++){
            //cout << i << " " << j << " " endl;
            if(edgeSet[i][j] == 0 and i != j){
                edgeSet[i][j] = 1;
                edgeSet[j][i] = 1;
                m--;
            }
       //     cout << i << " " << j << " " << m << endl;
        }
    }
   // cout << m << endl;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            if(edgeSet[i][j] and i < j){
                cout << i << " " << j << endl;
            }
        }
    }
}
int main(){
//    ios_base::sync_with_stdio(0); cin.tie(0);
  //  system("COLOR F0");
    LL n, q, i,j = 0, temp, t, k, ans = 0, sum = 0, x, y, z, cnt = 0, m, fg = 0, mx = 0, mx1 = 0, mn = 8000000000000000000, mn1 = 8000000000000000000;
    cin >> n >> m >> k;
    for(int i = 1; i <= 1000; i++){
        s1.insert(i);
    }

    for(int i = 0; i < k; i++){
        cin >> x;
        s1.erase(x);
        s.insert(x);
    }
    if(k != n and (n - 1) * (n) / 2 - (n - 2) < m){
        cout << -1 << endl;
        r0;
    }
    if(k == n){
        kEqualsN(n, m);
        r0;
    }
    LL take = *s.begin();
    s.erase(s.begin());
    LL now = *s1.begin();
    s1.erase(s1.begin());
    LL permanent = now;
    temp = 1e17;
    if(s.size())
        temp = *s.begin();
    edgeSet[take][now] = 1;
    edgeSet[now][take] = 1;
    now = min(now, temp);

    m--;
    for(int i  = now + 1; i <= n and m; i++){
        if(i != take and i != now){
            edgeSet[i][now] = 1;
            edgeSet[now][i] = 1;
            now = i;
            cnt++;
            m--;
        }
    }
    for(int i = 1; i <= n and m; i++){
        for(int j = 1; j <= n and m; j++){
            if(i != j and i != take and j != take and edgeSet[i][j] == 0){
                edgeSet[i][j] = 1;
                edgeSet[j][i] = 1;
                m--;
            }
        }
    }
    for(auto it = s1.begin(); it != s1.end() and m; it++){
        edgeSet[take][*it] = 1;
        edgeSet[*it][take] = 1;
        m--;
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            if(edgeSet[i][j] and i < j){
                cout << i << " " << j << endl;
            }
        }
    }
}


                                    /* Survive. Live. Win. Conquer.*/

#include<bits/stdc++.h>
using namespace std;
typedef long long LL ;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

#define ook order_of_key
#define fbk find_by_order
#define bug printf("TRUST\n");
#define pf printf
#define sf scanf
#define lp(i, n) for(int i = 0; i < n; i++)
#define rlp(n, i) for(int i = n - 1; i >= 0; i--)
#define bye vector<LL>
#define pb push_back
#define r0 return 0
#define ff first
#define ss second
#define mp make_pair
#define pii pair <int, int>
#define sz(a) ((int)a.size())
#define set0(a) memset ((a), 0 , sizeof(a))
#define set1(a) memset((a),-1,sizeof (a))
#define si(a) scanf("%d" , &a)
#define sl(a) scanf("%lld" , &a)
#define sii(a,b) scanf("%d %d" , &a , &b)
#define siii(a,b,c) scanf("%d %d %d" , &a , &b, &c)
#define sll(a,b) scanf("%lld %lld" , &a , &b)
#define slll(a,b,c) scanf("%lld %lld %lld" , &a , &b, &c)
#define FOR(i,a,b) for(LL i = (a) ; i <= (b) ; i++)
#define mod 1000000007
#define nod 200003

//using namespace __gnu_pbds;
//typedef tree < int, null_type ,less<int>,rb_tree_tag,tree_order_statistics_node_update > ordered_set;

void func(void)
{
        freopen("input.c","r",stdin);
        freopen("output.c","w",stdout);
}
const int N = 1e3;
set <LL> s, s1;
LL edgeSet[N][N];
void kEqualsN(LL n, LL m){
    LL now = 1;
    //cout << m << endl;
    for(int i  = now + 1; i <= n and m; i++){

            edgeSet[i][now] = 1;
            edgeSet[now][i] = 1;
            now = i;
            m--;

    }
   // cout << m << endl;
    for(int i = 1; i <= n and m; i++){
        for(int j = 1; j <= n and m; j++){
            //cout << i << " " << j << " " endl;
            if(edgeSet[i][j] == 0 and i != j){
                edgeSet[i][j] = 1;
                edgeSet[j][i] = 1;
                m--;
            }
       //     cout << i << " " << j << " " << m << endl;
        }
    }
   // cout << m << endl;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            if(edgeSet[i][j] and i < j){
                cout << i << " " << j << endl;
            }
        }
    }
}
int main(){
//    ios_base::sync_with_stdio(0); cin.tie(0);
  //  system("COLOR F0");
    LL n, q, i,j = 0, temp, t, k, ans = 0, sum = 0, x, y, z, cnt = 0, m, fg = 0, mx = 0, mx1 = 0, mn = 8000000000000000000, mn1 = 8000000000000000000;
    cin >> n >> m >> k;
    for(int i = 1; i <= 1000; i++){
        s1.insert(i);
    }

    for(int i = 0; i < k; i++){
        cin >> x;
        s1.erase(x);
        s.insert(x);
    }
    if(k == n or (n - 1) * (n) / 2 - max(1LL, k - 1) < m){
        cout << -1 << endl;
        r0;
    }

    LL take = *s.begin();
    s.erase(s.begin());
    LL now = *s1.begin();
    s1.erase(s1.begin());
    LL permanent = now;
    temp = 1e17;
    if(s.size())
        temp = *s.begin();
    edgeSet[take][now] = 1;
    edgeSet[now][take] = 1;
    now = min(now, temp);

    m--;
    for(int i  = now + 1; i <= n and m; i++){
        if(i != take and i != now){
            edgeSet[i][now] = 1;
            edgeSet[now][i] = 1;
            now = i;
            cnt++;
            m--;
        }
    }
    for(int i = 1; i <= n and m; i++){
        for(int j = 1; j <= n and m; j++){
            if(i != j and i != take and j != take and edgeSet[i][j] == 0){
                edgeSet[i][j] = 1;
                edgeSet[j][i] = 1;
                m--;
            }
        }
    }
    //for(int i = 1; i <= n and m; i++){
        for(int j = 1; j <= n and m; j++){
            if(j != take and s.find(j) == s.end() and edgeSet[take][j] == 0){
                edgeSet[take][j] = 1;
                edgeSet[j][take] = 1;
                m--;
            }
        }
    //}
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            if(edgeSet[i][j] and i < j){
                cout << i << " " << j << endl;
            }
        }
    }
}


#include <bits/stdc++.h>
using namespace std;
#define MAX 305

bool ok[MAX][MAX];
bool marked[MAX];

int main(){
    int n,m,k,p;
    scanf("%d %d %d",&n,&m,&k);

    if(n==k || m>(n*(n-1))/2-k+1){printf("-1"); return 0;}
    for(int i=1;i<=k;i++) {scanf("%d",&p); marked[p]=1;}

    int now;
    for(int i=1;i<=n;i++) if(!marked[i]) now=i;
    for(int i=1;i<=n;i++) if(i!=now) {ok[now][i]=ok[i][now]=1; printf("%d %d\n",now,i);}
    int COUNT=n-1;

    for(int i=1;i<=n;i++) if(marked[i]) now=i;
    for(int i=1;i<=n;i++){
        if(COUNT==m) break;
        for(int j=i+1;j<=n;j++){
            if(COUNT==m) break;
            if(i==now && marked[j]) continue;
            if(j==now && marked[i]) continue;
            if(ok[i][j]) continue;
            ok[i][j]=ok[j][i]=1;
            printf("%d %d\n",i,j);
            COUNT++;
        }
    }
}


#include <bits/stdc++.h>
using namespace std;
#define m_p make_pair
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
mt19937 rnf(2106);
const int N = 404;

int n, k, m;
int a[N];

bool u[N][N];

set<pair<int, int> > s;

bool c[N];
void dfs(int x)
{
    c[x] = true;
    for (int h = 1; h <= n; ++h)
    {
        if (!u[x][h])
            continue;
        if (!c[h])
        {
            s.insert(m_p(min(x, h), max(x, h)));
            dfs(h);
        }
    }
}

void solv()
{
    scanf("%d%d%d", &n, &m, &k);
    for (int i = 1; i <= k; ++i)
        scanf("%d", &a[i]);
    sort(a + 1, a + k + 1);
    if (k == n)
    {
        printf("-1\n");
        return;
    }
    if (m > n * (n - 1) / 2 - k + 1)
    {
        printf("-1\n");
        return;
    }
    for (int i = 1; i <= n; ++i)
    {
        for (int j = 1; j <= n; ++j)
        {
            if (i == j)
                continue;
            if (i == a[1])
            {
                if (!binary_search(a + 1, a + k + 1, j))
                    u[i][j] = true;
            }
            else if (j == a[1])
            {
                if (!binary_search(a + 1, a + k + 1, i))
                    u[i][j] = true;
            }
            else
                u[i][j] = true;
        }
    }
    dfs(1);
    m -= (n - 1);
    for (int i = 1; i <= n; ++i)
    {
        for (int j = i + 1; j <= n; ++j)
        {
            if (!u[i][j])
                continue;
            if (s.find(m_p(i, j)) != s.end())
                continue;
            if (m)
            {
                --m;
                s.insert(m_p(i, j));
            }
        }
    }
    for (set<pair<int, int> >::iterator it = s.begin(); it != s.end(); ++it)
        printf("%d %d\n", it->first, it->second);
}

int main()
{
    #ifdef SOMETHING
    freopen("input.txt", "r", stdin);
    #endif // SOMETHING
    solv();
    return 0;
}

//while ((double)clock() / CLOCKS_PER_SEC <= 0.9){}


#include<bits/stdc++.h>
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

#define ll long long

#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define fill(ar,val) memset(ar, val, sizeof(ar))
#define fill0(ar) fill((ar), 0)
#define debug(x) cout<<#x<<": "<<x<<endl

#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;
typedef vector<int> vi;

#define INF 1000000000000000000
#define PI 3.14159265358979323846L

ll ans[301][301];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    ll n,m,k;
    cin >> n >> m >> k;

    ll mark[n+1];
    fill0(mark);

    rep(i,k)
    {
        ll a;
        cin >> a;
        mark[a] = 1;
    }

    ll one = 0;
    ll two = 0;
    ll thr = 0;

    if(k==n)
    {
        cout << "-1" << endl;
        return 0;
    }

    fr(i,1,n)
    {
        if(!mark[i] && thr==0)
            thr = i;
        if(mark[i])
        {
            if(one==0)
                one = i;
            else if(two==0)
                two = i;
        }
    }

    ans[one][thr] = 1;
    ans[thr][one] = 1;
    ans[two][thr] = 1;
    ans[thr][two] = 1;
    m--;
    m--;

    fr(i,1,n)
    {
        if(m==0)
            break;
        fr(j,1,n)
        {
            if(m==0)
                break;
            if(i==j)
                continue;
            if(ans[i][j])
                continue;
            if(i==one && j==two)
                continue;
            if(i==two && j==one)
                continue;
            if(i==one)
            {
                if(mark[j] && ans[two][j])
                    continue;
            }
            if(i==two)
            {
                if(mark[j] && ans[one][j])
                    continue;
            }

            ans[i][j] = 1;
            ans[j][i] = 1;
            m--;
        }
    }

    if(m!=0)
    {
        cout << "-1" << endl;
    }
    else
    {
        fr(i,1,n)
        {
            fr(j,i,n)
            {
                if(j==i)
                    continue;
                if(ans[i][j])
                    cout << i << " " << j << endl;
            }
        }
    }
}


#include<bits/stdc++.h>
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

#define ll long long

#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define fill(ar,val) memset(ar, val, sizeof(ar))
#define fill0(ar) fill((ar), 0)
#define debug(x) cout<<#x<<": "<<x<<endl

#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;
typedef vector<int> vi;

#define INF 1000000000000000000
#define PI 3.14159265358979323846L

ll ans[301][301];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    ll n,m,k;
    cin >> n >> m >> k;

    ll mark[n+1];
    fill0(mark);

    rep(i,k)
    {
        ll a;
        cin >> a;
        mark[a] = 1;
    }

    ll one = 0;
    ll two = 0;
    ll thr = 0;

    if(k==n)
    {
        cout << "-1" << endl;
        return 0;
    }

    fr(i,1,n)
    {
        if(!mark[i] && thr==0)
            thr = i;
        if(mark[i])
        {
            if(one==0)
                one = i;
            else if(two==0)
                two = i;
        }
    }

    ans[one][thr] = 1;
    ans[thr][one] = 1;
    ans[two][thr] = 1;
    ans[thr][two] = 1;
    m--;
    m--;

    // cout << one << " " << two << " " << thr << endl;
    fr(i,1,n)
    {
        if(m==0)
            break;
        fr(j,1,n)
        {
            if(m==0)
                break;
            if(i==j)
                continue;
            if(ans[i][j])
                continue;
            if(i==one && j==two)
                continue;
            if(i==two && j==one)
                continue;
            if(i==one)
            {
                if(mark[j] && ans[two][j])
                    continue;
            }
            if(i==two)
            {
                if(mark[j] && ans[one][j])
                    continue;
            }
            if(mark[i])
            {
                if(j==one && ans[i][two])
                    continue;
                if(j==two && ans[i][one])
                    continue;
            }

            ans[i][j] = 1;
            ans[j][i] = 1;
            m--;
        }
    }

    if(m!=0)
    {
        cout << "-1" << endl;
    }
    else
    {
        fr(i,1,n)
        {
            fr(j,i,n)
            {
                if(j==i)
                    continue;
                if(ans[i][j])
                    cout << i << " " << j << endl;
            }
        }
    }
}


#include<bits/stdc++.h>
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

#define ll long long

#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define fill(ar,val) memset(ar, val, sizeof(ar))
#define fill0(ar) fill((ar), 0)
#define debug(x) cout<<#x<<": "<<x<<endl

#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;
typedef vector<int> vi;

#define INF 1000000000000000000
#define PI 3.14159265358979323846L

ll ans[301][301];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    ll n,m,k;
    cin >> n >> m >> k;

    ll mark[n+1];
    fill0(mark);

    rep(i,k)
    {
        ll a;
        cin >> a;
        mark[a] = 1;
    }

    ll one = 0;
    ll two = 0;
    ll thr = 0;

    if(k==n)
    {
        cout << "-1" << endl;
        return 0;
    }

    fr(i,1,n)
    {
        if(!mark[i] && thr==0)
            thr = i;
        if(mark[i])
        {
            if(one==0)
                one = i;
            else if(two==0)
                two = i;
        }
    }

    ans[one][thr] = 1;
    ans[thr][one] = 1;
    ans[two][thr] = 1;
    ans[thr][two] = 1;
    m--;
    m--;

    fr(i,1,n)
    {
        if(m==0)
            break;
        fr(j,1,n)
        {
            if(m==0)
                break;
            if(i==j)
                continue;
            if(ans[i][j])
                continue;
            if(i==one)
            {
                if(mark[j] && ans[two][j])
                    continue;
            }
            if(i==two)
            {
                if(mark[j] && ans[one][j])
                    continue;
            }

            ans[i][j] = 1;
            ans[j][i] = 1;
        }
    }

    if(m!=0)
    {
        cout << "-1" << endl;
    }
    else
    {
        fr(i,1,n)
        {
            fr(j,i,n)
            {
                if(j==i)
                    continue;
                if(ans[i][j])
                    cout << i << " " << j << endl;
            }
        }
    }
}


#include <bits/stdc++.h>

using namespace std;

int n, m, k, ispiv[303];
vector<int> piv, notpiv, bolo;
vector<pair<int, int>> edg;

int main() {
    scanf("%d %d %d", &n, &m, &k);
    if(k == n) {
        puts("-1");
        return 0;
    }

    for(int i = 0; i < k; i++) {
        int x;
        scanf("%d", &x);
        piv.push_back(x);
        ispiv[x] = 1;
    }
    for(int i = 1; i <= n; i++) {
        if(!ispiv[i]) notpiv.push_back(i);
    }

    int s, t, mid;

    mid = notpiv.back();
    notpiv.pop_back();

    s = piv.back();
    piv.pop_back();

    t = piv.back();
    piv.pop_back();

    edg.emplace_back(s, mid);
    edg.emplace_back(mid, t);

    while(!notpiv.empty()) {
        int u = notpiv.back();
        notpiv.pop_back();
        bolo.push_back(u);
        edg.emplace_back(u, t);
    }

    while(!piv.empty()) {
        int u = piv.back();
        piv.pop_back();
        bolo.push_back(u);
        edg.emplace_back(u, t);
    }

    while(!bolo.empty()) {
        int u = bolo.back();
        bolo.pop_back();

        for(int v : bolo)
            edg.emplace_back(u, v);

        edg.emplace_back(u, mid);
        if(!ispiv[u]) edg.emplace_back(s, u);
    }

    if(edg.size() < m) {
        puts("-1");
        return 0;
    }

    edg.resize(m);
    for(auto e : edg) {
        printf("%d %d\n", e.first, e.second);
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int N = 303;
int a[N], mp[N];
int mat[N][N];
int n, m, k, tmp;
vector<pair<int, int>> v;

int main() {

	scanf("%d%d%d", &n, &m, &k);
	if (k == n || m == n * (n - 1) / 2) {
		puts("-1");
		return 0;
	}

	for (int i = 1; i <= n; i++) {
		mp[i] = i;
		if (i <= k) {
			scanf("%d", &tmp);
			a[tmp] = 1;
		}

		if (i + 1 <= n) {
			mat[i][i + 1] = 1;
			v.push_back( { i, i + 1 });
			m--;
		}
	}

	if (!a[1]) {
		swap(a[tmp],a[1]);
		swap(mp[tmp],mp[1]);
	}

	if(a[2]){
		for(int i = 3 ; i <= n ; i++){
			if(!a[i]){
				swap(a[i],a[2]);
				swap(mp[i],mp[2]);
				break;
			}
		}
	}

	for (int i = 1; i <= n && m; i++) {
		for (int j = i + 2; j <= n && m; j++) {
			if ((i == 1 && !a[j]) || i != 1) {
				mat[i][j] = 1;
				v.push_back( { i, j });
				m--;
			}
		}
	}

	if(m)
		puts("-1");
	else{
		for(int i = 0 ; i < v.size() ; i++){
			printf("%d %d\n",mp[v[i].first],mp[v[i].second]);
		}
	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int N = 303;
int a[N], mp[N];
int mat[N][N];
int n, m, k, tmp;
vector<pair<int, int>> v;

int main() {

	scanf("%d%d%d", &n, &m, &k);
	if (k == n || m == n * (n - 1) / 2) {
		puts("-1");
		return 0;
	}

	for (int i = 1; i <= n; i++) {
		mp[i] = i;
		if (i <= k) {
			scanf("%d", &tmp);
			a[tmp] = 1;
		}

		if (i + 1 <= n) {
			mat[i][i + 1] = 1;
			v.push_back( { i, i + 1 });
			m--;
		}
	}

	if (!a[1]) {
		swap(a[tmp],a[1]);
		swap(mp[tmp],mp[1]);
	}

	if(a[2]){
		for(int i = 3 ; i <= n ; i++){
			if(!a[i]){
				swap(a[i],a[2]);
				swap(mp[i],mp[2]);
				break;
			}
		}
	}

	for (int i = 1; i <= n && m; i++) {
		for (int j = i + 2; j <= n && m; j++) {
			if ((i == 1 && !a[j]) || i != 1) {
				mat[i][j] = 1;
				v.push_back( { i, j });
				j--;
			}
		}
	}

	if(m)
		puts("-1");
	else{
		for(int i = 0 ; i < v.size() ; i++){
			printf("%d %d\n",mp[v[i].first],mp[v[i].second]);
		}
	}

	return 0;
}


#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 1000000007LL
#define IN freopen("C.in","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2

using namespace __gnu_pbds;
using namespace std ;

typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef pair<i64, i64> pii;

#define INF 2000000000
#define maxn 10005

int marked[maxn] ;
vector <int> unmarked ;

vector < pair<int,int> > vp ;

int main()
{
    int n , m , k ;

    scanf("%d %d %d",&n,&m,&k) ;

    for(int i=1 ; i<=k ; i++)
    {
        int a ;
        scanf("%d",&a) ;
        marked[a] = 1;
    }

    if( k==n || m > (n*(n-1))/2 - k + 1 )
    {
        printf("-1\n") ;
        return 0 ;
    }

    int u , v ;
    for(int i=1 ; i<=n ; i++)
    {
        for(int j=i+1 ; j<=n ; j++)
        {
            if( marked[i] && marked[j]  )
            {
                u = i ; v = j ;
            }
        }
    }

  //  DBG ;

    for(int i=1 ;i<=n ; i++)
    {
        if( !marked[i] ) unmarked.pb(i) ;
    }

    vp.pb( mp(v,unmarked[0]) ) ;

    for(int i=1 ; i<=n ; i++)
    {
        if( i==u || i==v ) continue ;
        vp.pb( mp( u , i ) ) ;
    }

    m -= (n-1) ;

    for(int i=1 ; i<=n ; i++)
    {
        if(i==u || v==i) continue ;
        for(int j=i+1 ; j<=n ; j++)
        {
            if( j==u || j==v ) continue ;
            if(m==0) continue ;
            vp.pb( mp(i,j) ) ;
            m-- ;
        }
    }

   // DBG ;

    int i=1 ;

    while( m!=0 )
    {
        vp.pb( mp( v,unmarked[i++] ) ) ;
        m-- ;
    }

    for(int i=0 ; i<vp.size() ; i++) printf("%d %d\n" , vp[i].xx , vp[i].yy ) ;

    return 0 ;
}


#include <bits/stdc++.h>
using namespace std;

bool marked[500];
int main(){
	int N,M,K;cin>>N>>M>>K;

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

	for(int i=0;i<K;i++){
		int x;cin>>x;x--;
		marked[x] = true;
	}

	int umark = 0;
	while(marked[umark]) umark++;

	int other = 0;
	while(!marked[other]) other++;

	vector< pair< int,int > > ans(M);
	ans[M-1] = make_pair(umark+1,other+1);
	M -= 1;

	for(int i=0;i<N && M>0;i++){
		if(i == other) continue;
		for(int j=i+1;j<N && M > 0;j++){
			if(j == other) continue;
			ans[M-1] = make_pair(i+1,j+1);
			M -= 1;
		}
	}

	for(int i=0;i<N && M>0;i++){
		if(i == umark || i == other || marked[i] == true) continue;
		ans[M-1] = make_pair(i+1,other+1);
		M -= 1;
	}
	if(M != 0){
		cout<<-1<<endl;
	}else{
		for(int i=0;i<ans.size();i++) cout<<ans[i].first<<" "<<ans[i].second<<endl;
	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;

bool marked[500];
int main(){
	int N,M,K;cin>>N>>M>>K;

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

	for(int i=0;i<N;i++){
		int x;cin>>x;x--;
		marked[x] = true;
	}

	int umark = 0;
	while(marked[umark]) umark++;

	int other = 0;
	if(umark == other) other++;

	vector< pair< int,int > > ans(M);
	ans[M-1] = make_pair(umark+1,other+1);
	M -= 1;

	for(int i=0;i<N && M>0;i++){
		if(i == other) continue;
		for(int j=i+1;j<N && M > 0;j++){
			if(j == other) continue;
			ans[M-1] = make_pair(i+1,j+1);
			M -= 1;
		}
	}

	if(M != 0){
		cout<<-1<<endl;
	}else{
		for(int i=0;i<ans.size();i++) cout<<ans[i].first<<" "<<ans[i].second<<endl;
	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
	ll n,m,k;
	cin>>n>>m>>k;
	ll a[n+4]={0};
	ll x;
	for(ll i=0;i<k;i++)
	{
		cin>>x;
		a[x]=1;
	}
	ll q,p;
	for(ll i=1;i<=n;i++)
	{
		if(a[i]==0)
		{
			q=i;
			break;
		}
	}
	for(ll i=1;i<=n;i++)
	{
		if(a[i]==1)
		{
			p=i;
			break;
		}
	}
	if(m>(((n*(n-1))/2))-(k-1))
	{
		cout<<-1;
		return 0;
	}
	for(ll i=1;i<=n;i++)
	{
		if(i!=q)
		{
			cout<<i<<' '<<q<<endl;
		}
	}
	ll w=m-n+1;
	for(ll i=1;i<=n;i++)
	{
		for(ll j=i+1;j<=n;j++)
		{
			if(i==q||j==q)
			continue;
			if(i==p&&a[j]==1)
			continue;
			if(a[i]==1&&j==p)
			continue;
			if(w==0)
			return 0;
			cout<<i<<' '<<j<<endl;
			w--;
		}
	}
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
	ll n,m,k;
	cin>>n>>m>>k;
	if(k==n)
	{
		cout<<-1;
		return 0;
	}
	ll a[n+4]={0};
	ll x;
	for(ll i=0;i<k;i++)
	{
		cin>>x;
		a[x]=1;
	}
	ll q=1,p=n;
	for(ll i=1;i<=n;i++)
	{
		if(a[i]==0)
		{
			q=i;
			break;
		}
	}
	for(ll i=1;i<=n;i++)
	{
		if(a[i]==1)
		{
			p=i;
			break;
		}
	}
	if(m>(((n*(n-1))/2))-(k-1))
	{
		cout<<-1;
		return 0;
	}
	for(ll i=1;i<=n;i++)
	{
		if(i!=q)
		{
			cout<<i<<' '<<q<<endl;
		}
	}
	ll w=m-n+1;
	for(ll i=1;i<=n;i++)
	{
		for(ll j=i+1;j<=n;j++)
		{
			if(i==q||j==q)
			continue;
			if(i==p&&a[j]==1)
			continue;
			if(a[i]==1&&j==p)
			continue;
			if(w==0)
			return 0;
			cout<<i<<' '<<j<<endl;
			w--;
		}
	}
}


#include <bits/stdc++.h>
#define ull uint64_t
#define ll long long int
#define pb push_back
#define mp make_pair
#define pi pair<int, int>
#define vi vector<int>
#define ff first
#define ss second
#define mx5 100005
#define mx52 200005
#define mx6 1000005
#define mod 1000000007
#define smod 998244353
#define nfs                       \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);
using namespace std;

template <typename T>
bool MinPlace(T &a, const T &b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool MaxPlace(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

template <typename S, typename T>
ostream &operator<<(ostream &out, const pair<S, T> &p)
{
    out << "{" << p.ff << ", " << p.ss << "}";
    return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v)
{
    out << "[";
    for (int i = 0; i < (int)v.size(); i++)
    {
        out << v[i];
        if (i != (int)v.size() - 1)
            out << ", ";
    }
    out << "]";
    return out;
}

int main()
{
    nfs;
    int i, j, n, m, k;
    cin >> n >> m >> k;
    set<int> mark;
    for (int i = 0; i < k; i++)
    {
        int v;
        cin >> v;
        mark.insert(v);
    }
    if (m > ((n - 1) * (n - 2)) / 2 + (n - k))
    {
        cout << "-1";
        return 0;
    }
    int culp = *(mark.begin());
    for (int i = 1; i <= n && m; i++)
    {
        for (int j = i + 1; j <= n && m; j++)
        {
            if (i == j)
                continue;
            if ((i == culp && mark.count(j)) || (j == culp && mark.count(i)))
                continue;
            cout << i << " " << j << "\n";
            m--;
        }
    }
}


#include <bits/stdc++.h>
#define ull uint64_t
#define ll long long int
#define pb push_back
#define mp make_pair
#define pi pair<int, int>
#define vi vector<int>
#define ff first
#define ss second
#define mx5 100005
#define mx52 200005
#define mx6 1000005
#define mod 1000000007
#define smod 998244353
#define nfs                       \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);
using namespace std;

template <typename T>
bool MinPlace(T &a, const T &b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool MaxPlace(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

template <typename S, typename T>
ostream &operator<<(ostream &out, const pair<S, T> &p)
{
    out << "{" << p.ff << ", " << p.ss << "}";
    return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v)
{
    out << "[";
    for (int i = 0; i < (int)v.size(); i++)
    {
        out << v[i];
        if (i != (int)v.size() - 1)
            out << ", ";
    }
    out << "]";
    return out;
}

class dsu
{
    int n;
    vector<int> pa, sz;

public:
    dsu(int n) : n(n)
    {
        pa.resize(n + 1);
        sz.resize(n + 1, 1);
        for (int i = 1; i <= n; i++)
            pa[i] = i;
    }

    int get_pa(int u)
    {
        return (pa[u] == u) ? u : pa[u] = get_pa(pa[u]);
    }

    // returns true if important edge
    bool add_edge(int u, int v)
    {
        int pu = get_pa(u), pv = get_pa(v);
        if (pu == pv)
            return false;
        if (sz[pu] < sz[pv])
            swap(pu, pv);
        sz[pu] += sz[pv];
        pa[pv] = pu;
        return true;
    }

    int comp(int u)
    {
        return get_pa(u);
    }
};

int main()
{
    nfs;
    int i, j, n, m, k;
    cin >> n >> m >> k;
    set<int> mark;
    for (int i = 0; i < k; i++)
    {
        int v;
        cin >> v;
        mark.insert(v);
    }
    if (k == n || m > ((n - 1) * (n - 2)) / 2 + (n - k))
    {
        cout << "-1";
        return 0;
    }
    int culp = *(mark.begin());
    dsu d(n);
    vector<pi> optionals, compulsory;
    for (int i = 1; i <= n && m; i++)
    {
        for (int j = i + 1; j <= n && m; j++)
        {
            if (i == j)
                continue;
            if ((i == culp && mark.count(j)) || (j == culp && mark.count(i)))
                continue;
            if (d.add_edge(i, j))
                compulsory.pb({i, j});
            else
                optionals.pb({i, j});
        }
    }

    for (auto e : compulsory)
        cout << e.ff << " " << e.ss << "\n";
    m -= n - 1;
    for (int i = 0; i < m; i++)
        cout << optionals[i].ff << " " << optionals[i].ss << "\n";
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

ll f(ll x){
    return x*(x-1)/2;
}

int main(){

    //freopen("input.in", "r", stdin);freopen("input.out", "w", stdout);

    int n, m, k;
    cin>>n>>m>>k;
    vector<int>a(k);
    vector<int>c(n+1, 0);
    for (int i=0; i<k; i++){
        cin>>a[i];
        c[a[i]]=1;
    }

    if (k==n){
        cout<<-1;
        return 0;
    }
    if (m==f(n)){
        cout<<-1;
        return 0;
    }
    int V;
    for (int x=1; x<=n; x++){
        if (!c[x]){
            V=x;
            break;
        }
    }
    for (ll s1=1; s1<n; s1++){
        ll s2=n-1-s1;
        if (s2>=1 && n-1<=m && m<=(n-1)+f(s1)+f(s2)){
            vector<int>d1, d2;
            int x=1;
            while(d1.size()<s1){
                if (x==V){
                    x++;
                    continue;
                }
                d1.push_back(x);
                x++;
            }
            while(d2.size()<s2){
                if (x==V){
                    x++;
                    continue;
                }
                d2.push_back(x);
                x++;
            }
            for (int i=0; i<d1.size(); i++){
                cout<<V<<" "<<d1[i]<<endl;
            }
            for (int i=0; i<d2.size(); i++){
                cout<<V<<" "<<d2[i]<<endl;
            }
            m-=(n-1);
            for (int i=0; i<d1.size(); i++){
                for (int j=i+1; j<d1.size(); j++){
                    if (m){
                        cout<<d1[i]<<" "<<d1[j]<<endl;
                        m--;
                    }
                }
            }

            for (int i=0; i<d2.size(); i++){
                for (int j=i+1; j<d2.size(); j++){
                    if (m){
                        cout<<d2[i]<<" "<<d2[j]<<endl;
                        m--;
                    }
                }
            }
            return 0;
        }
    }
    while(1){

    }
    cout<<-1;

    return 0;
}

/* Thu Jan 30 2020 13:30:10 GMT+0300 (MSK) */

/* Thu Jan 30 2020 23:59:47 GMT+0300 (MSK) */


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

ll f(ll x){
    return x*(x-1)/2;
}

int main(){

    //freopen("input.in", "r", stdin);freopen("input.out", "w", stdout);

    int n, m, k;
    cin>>n>>m>>k;
    vector<int>a(k);
    vector<int>c(n+1, 0);
    for (int i=0; i<k; i++){
        cin>>a[i];
        c[a[i]]=1;
    }

    if (k==n){
        cout<<-1;
        return 0;
    }
    if (m==f(n)){
        cout<<-1;
        return 0;
    }
    int V;
    for (int x=1; x<=n; x++){
        if (!c[x]){
            V=x;
            break;
        }
    }
    for (ll s1=1; s1<n; s1++){
        ll s2=n-1-s1;
        if (s2>=1 && n-1<=m && m<=(n-1)+f(s1)+f(s2)){
            vector<int>d1, d2;
            int x=1;
            while(d1.size()<s1){
                if (x==V){
                    x++;
                    continue;
                }
                d1.push_back(x);
                x++;
            }
            while(d2.size()<s2){
                if (x==V){
                    x++;
                    continue;
                }
                d2.push_back(x);
                x++;
            }
            for (int i=0; i<d1.size(); i++){
                cout<<V<<" "<<d1[i]<<endl;
            }
            for (int i=0; i<d2.size(); i++){
                cout<<V<<" "<<d2[i]<<endl;
            }
            m-=(n-1);
            for (int i=0; i<d1.size(); i++){
                for (int j=i+1; j<d1.size(); j++){
                    if (m){
                        cout<<d1[i]<<" "<<d1[j]<<endl;
                        m--;
                    }
                }
            }

            for (int i=0; i<d2.size(); i++){
                for (int j=i+1; j<d2.size(); j++){
                    if (m){
                        cout<<d2[i]<<" "<<d2[j]<<endl;
                        m--;
                    }
                }
            }
            return 0;
        }
    }
    cout<<-1;

    return 0;
}

/* Thu Jan 30 2020 13:30:10 GMT+0300 (MSK) */


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

ll f(ll x){
    return x*(x-1)/2;
}

vector<int>g[303];
int m1[303][303];
int m2[303][303];
int main(){

    //freopen("input.in", "r", stdin);freopen("input.out", "w", stdout);

    int n, m, k;
    cin>>n>>m>>k;
    vector<int>a(k);
    vector<int>c(n+1, 0);
    for (int i=0; i<k; i++){
        cin>>a[i];
        c[a[i]]=1;
    }

    if (k==n){
        cout<<-1;
        return 0;
    }
    if (m>f(n-1)+1+(n-2)){
        cout<<-1;
        return 0;
    }
    int V, X;
    for (int x=1; x<=n; x++){
        if (!c[x])
            V=x;
        else
            X=x;
    }

    m--;
    cout<<X<<" "<<V<<endl;
    for (int x=1; x<=n; x++){
        if (x==V || x==X)
            continue;
        if (m>0){
            cout<<V<<" "<<x<<endl;
            m--;
        }
    }
    for (int x=1; x<=n; x++){
        if (x==V || x==X)
            continue;
        for (int y=x+1; y<=n; y++){
            if (x==V || x==X)
                continue;
            if (m>0){
                m--;
                cout<<x<<" "<<y<<endl;
            }
        }
    }

    for (int x=1; x<=n; x++){
        if (X==x || V==x)
            continue;
        if (m>0){
            m--;
            cout<<X<<" "<<x<<endl;
        }
    }
    return 0;
}

/* Thu Jan 30 2020 13:53:11 GMT+0300 (MSK) */

/* Fri Jan 31 2020 01:11:11 GMT+0300 (MSK) */


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

ll f(ll x){
    return x*(x-1)/2;
}

vector<int>g[303];
int m1[303][303];
int m2[303][303];
int main(){

    //freopen("input.in", "r", stdin);freopen("input.out", "w", stdout);

    int n, m, k;
    cin>>n>>m>>k;
    vector<int>a(k);
    vector<int>c(n+1, 0);
    for (int i=0; i<k; i++){
        cin>>a[i];
        c[a[i]]=1;
    }

    if (k==n){
        cout<<-1;
        return 0;
    }
    vector<int>v, b;
    for (int x=1; x<=n; x++){
        if (!c[x])
            v.push_back(x);
        else
            b.push_back(x);
    }

    m-=(v.size()-1);
    for (int i=0; i<(int)v.size()-1; i++){
        g[v[i]].push_back(v[i+1]);
        g[v[i+1]].push_back(v[i]);
    }
    if (b.size()){
        m--;
        g[v[0]].push_back(b[0]);
        g[b[0]].push_back(v[0]);
        for (int i=1; i<b.size() && m>0; i++){
            m--;
            g[v.back()].push_back(b[i]);
            g[b[i]].push_back(v.back());
        }

        for (int i=1; i<b.size(); i++){
            for (int j=i+1; j<b.size(); j++){
                if (m>0){
                    m--;
                    g[b[i]].push_back(b[j]);
                    g[b[j]].push_back(b[i]);
                }
            }
        }
        for (int i=(int)v.size()-2; i>=0; i--){
            for (int j=1; j<b.size(); j++){
                if (m>0){
                    m--;
                    g[v[i]].push_back(b[j]);
                    g[b[j]].push_back(v[i]);
                }
            }
        }
        for (int i=1; i<v.size(); i++){
            if (m>0){
                m--;
                g[v[i]].push_back(b[0]);
                g[b[0]].push_back(v[i]);
            }
        }
        if (m){
            cout<<-1;
            return 0;
        }
        for(int i = 1; i <= n; i++) {
            for(int j = 1; j <= n; j++) {
                if (i == j)
                    m2[i][j] = 0;
                else
                    m2[i][j] = 1e9;
            }
        }
        for (int x=1; x<=n; x++){
            for (int y:g[x]){
                m2[x][y]=1;
            }
        }

        for (int i = 0; i < k; i++) {
            int v = a[i];
            for(int j = 1; j <= n; j++)
                for(int r = 1; r <= n; r++)
                    m2[j][r] = min(m2[j][r], m2[j][v] + m2[v][r]);
        }

        for(int i = 1; i <= n; i++) {
            for(int j = 1; j <= n; j++) {
                if (i == j)
                    m1[i][j] = 0;
                else
                    m1[i][j] = 1e9;
            }
        }
        for (int x=1; x<=n; x++){
            for (int y:g[x]){
                m1[x][y]=1;
            }
        }

        for (int i = 1; i <= n; i++) {
            int v = i;
            for(int j = 1; j <= n; j++)
                for(int r = 1; r <= n; r++)
                    m2[j][r] = min(m2[j][r], m2[j][v] + m2[v][r]);
        }
        for (int x=1; x<=n; x++){
            for (int y=1; y<=n; y++){
                if (m1[x][y]!=m2[x][y]){
                    for (int x=1; x<=n; x++){
                        for (int y:g[x]){
                            if (x<y){
                                cout<<x<<" "<<y<<endl;
                            }
                        }
                    }
                    return 0;
                }
            }
        }
        cout<<-1;
    }

    return 0;
}

/* Thu Jan 30 2020 13:53:11 GMT+0300 (MSK) */


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

ll f(ll x){
    return x*(x-1)/2;
}

vector<int>g[303];
int m1[303][303];
int m2[303][303];
int main(){

    //freopen("input.in", "r", stdin);freopen("input.out", "w", stdout);

    int n, m, k;
    cin>>n>>m>>k;
    vector<int>a(k);
    vector<int>c(n+1, 0);
    for (int i=0; i<k; i++){
        cin>>a[i];
        c[a[i]]=1;
    }

    if (k==n){
        cout<<-1;
        return 0;
    }
    if (m>f(n-1)+1){
        cout<<-1;
        return 0;
    }
    int V, X;
    for (int x=1; x<=n; x++){
        if (!c[x])
            V=x;
        else
            X=x;
    }

    m--;
    cout<<X<<" "<<V<<endl;
    for (int x=1; x<=n; x++){
        if (x==V || x==X)
            continue;
        if (m>0){
            cout<<V<<" "<<x<<endl;
            m--;
        }
    }
    for (int x=1; x<=n; x++){
        if (x==V || x==X)
            continue;
        for (int y=x+1; y<=n; y++){
            if (x==V || x==X)
                continue;
            if (m>0){
                m--;
                cout<<x<<" "<<y<<endl;
            }
        }
    }
    return 0;
}

/* Thu Jan 30 2020 13:53:11 GMT+0300 (MSK) */

/* Fri Jan 31 2020 00:45:32 GMT+0300 (MSK) */


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

ll f(ll x){
    return x*(x-1)/2;
}

int main(){

    //freopen("input.in", "r", stdin);freopen("input.out", "w", stdout);

    int n, m, k;
    cin>>n>>m>>k;
    vector<int>a(k);
    vector<int>c(n+1, 0);
    for (int i=0; i<k; i++){
        cin>>a[i];
        c[a[i]]=1;
    }

    if (k==n){
        cout<<-1;
        return 0;
    }
    if (m==f(n)){
        cout<<-1;
        return 0;
    }
    int V;
    for (int x=1; x<=n; x++){
        if (!c[x]){
            V=x;
            break;
        }
    }
    for (ll s1=0; s1<=n; s1++){
        ll s2=n-1-s1;
        if (s2>=1 && n-1<=m && m<=(n-1)+f(s1)+f(s2)){
            vector<int>d1, d2;
            int x=1;
            while(d1.size()<s1){
                if (x==V){
                    x++;
                    continue;
                }
                d1.push_back(x);
                x++;
            }
            while(d2.size()<s2){
                if (x==V){
                    x++;
                    continue;
                }
                d2.push_back(x);
                x++;
            }
            for (int i=0; i<d1.size(); i++){
                cout<<V<<" "<<d1[i]<<endl;
            }
            for (int i=0; i<d2.size(); i++){
                cout<<V<<" "<<d2[i]<<endl;
            }
            m-=(n-1);
            for (int i=0; i<d1.size(); i++){
                for (int j=i+1; j<d1.size(); j++){
                    if (m){
                        cout<<d1[i]<<" "<<d1[j]<<endl;
                        m--;
                    }
                }
            }

            for (int i=0; i<d2.size(); i++){
                for (int j=i+1; j<d2.size(); j++){
                    if (m){
                        cout<<d2[i]<<" "<<d2[j]<<endl;
                        m--;
                    }
                }
            }
            return 0;
        }
    }

    cout<<-1;

    return 0;
}

/* Thu Jan 30 2020 13:30:10 GMT+0300 (MSK) */

/* Fri Jan 31 2020 00:00:31 GMT+0300 (MSK) */


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

ll f(ll x){
    return x*(x-1)/2;
}

vector<int>g[303];
int m1[303][303];
int m2[303][303];
int main(){

    //freopen("input.in", "r", stdin);freopen("input.out", "w", stdout);

    int n, m, k;
    cin>>n>>m>>k;
    vector<int>a(k);
    vector<int>c(n+1, 0);
    for (int i=0; i<k; i++){
        cin>>a[i];
        c[a[i]]=1;
    }

    if (k==n){
        cout<<-1;
        return 0;
    }
    vector<pair<int, int>>r;

    vector<int>v1, v2;
    for (int x=1; x<=n; x++){
        if (c[x])
            v1.push_back(x);
        else
            v2.push_back(x);
    }
    for (int x=1; x<=n; x++){
        if (x!=v2[0]){
            m--;
            r.push_back({x, v2[0]});
        }
    }
    for (int x=1; x<=n; x++){
        if (x==v1[0] || x==v1[1] || x==v2[0])
            continue;
        for (int y=x+1; y<=n; y++){
            if (y==v1[0] || y==v1[1] || x==v2[0])
                continue;
            if (m>0){
                r.push_back({x, y});
                m--;
            }
        }
    }
    for (int x=1; x<=n; x++){
        if (x==v1[0] || x==v1[1] || x==v2[0])
            continue;
        if (m>0){
            r.push_back({x, v1[0]});
            m--;
        }
    }
    for (int x:v2){
        if (x!=v2[0] && m>0){
            m--;
            r.push_back({x, v1[1]});
        }
    }
    if (m){
        cout<<-1;
        return 0;
    }
    for (int i=0; i<r.size(); i++){
        cout<<r[i].first<<" "<<r[i].second<<endl;
    }
    return 0;
}

/* Thu Jan 30 2020 13:53:11 GMT+0300 (MSK) */

/* Fri Jan 31 2020 02:02:59 GMT+0300 (MSK) */


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

ll f(ll x){
    return x*(x-1)/2;
}

vector<int>g[303];
int m1[303][303];
int m2[303][303];
int main(){

    //freopen("input.in", "r", stdin);freopen("input.out", "w", stdout);

    int n, m, k;
    cin>>n>>m>>k;
    vector<int>a(k);
    vector<int>c(n+1, 0);
    for (int i=0; i<k; i++){
        cin>>a[i];
        c[a[i]]=1;
    }

    if (k==n){
        cout<<-1;
        return 0;
    }
    if (m>f(n-1)+1+(n-3)){
        cout<<-1;
        return 0;
    }
    int V, X;
    for (int x=1; x<=n; x++){
        if (!c[x])
            V=x;
        else
            X=x;
    }

    m--;
    cout<<X<<" "<<V<<endl;
    for (int x=1; x<=n; x++){
        if (x==V || x==X)
            continue;
        if (m>0){
            cout<<V<<" "<<x<<endl;
            m--;
        }
    }
    for (int x=1; x<=n; x++){
        if (x==V || x==X)
            continue;
        for (int y=x+1; y<=n; y++){
            if (x==V || x==X)
                continue;
            if (m>0){
                m--;
                cout<<x<<" "<<y<<endl;
            }
        }
    }

    for (int x=1; x<=n; x++){
        if (X==x || V==x)
            continue;
        if (m>0){
            m--;
            cout<<X<<" "<<x<<endl;
        }
    }
    return 0;
}

/* Thu Jan 30 2020 13:53:11 GMT+0300 (MSK) */

/* Fri Jan 31 2020 01:12:26 GMT+0300 (MSK) */


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

ll f(ll x){
    return x*(x-1)/2;
}

vector<int>g[303];
int m1[303][303];
int m2[303][303];
int main(){

    //freopen("input.in", "r", stdin);freopen("input.out", "w", stdout);

    int n, m, k;
    cin>>n>>m>>k;
    vector<int>a(k);
    vector<int>c(n+1, 0);
    for (int i=0; i<k; i++){
        cin>>a[i];
        c[a[i]]=1;
    }
    vector<pair<int, int>>r;
    if (k==n){
        cout<<-1;
        return 0;
    }
    int V, X;
    for (int x=1; x<=n; x++){
        if (!c[x])
            V=x;
        else
            X=x;
    }

    m--;
    r.push_back({X, V});

    for (int x=1; x<=n; x++){
        if (x==V || x==X)
            continue;
        if (m>0){
            r.push_back({x, V});
            m--;
        }
    }
    for (int x=1; x<=n; x++){
        if (x==V || x==X)
            continue;
        for (int y=x+1; y<=n; y++){
            if (y==V || y==X)
                continue;
            if (m>0){
                m--;
               // cout<<x<<" ! "<<y<<endl;
                r.push_back({x, y});
            }
        }
    }

    for (int x=1; x<=n; x++){
        if (X==x || V==x || c[x])
            continue;
        if (m>0){
            m--;
            r.push_back({X, x});;
        }
    }
    if (m){
        cout<<-1;
        return 0;
    }
    for (int i=0; i<r.size(); i++){
        cout<<r[i].first<<" "<<r[i].second<<endl;
    }
    return 0;
}

/* Thu Jan 30 2020 13:53:11 GMT+0300 (MSK) */

/* Fri Jan 31 2020 01:12:26 GMT+0300 (MSK) */

/* Fri Jan 31 2020 16:02:42 GMT+0300 (MSK) */


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

ll f(ll x){
    return x*(x-1)/2;
}

int main(){

    //freopen("input.in", "r", stdin);freopen("input.out", "w", stdout);

    int n, m, k;
    cin>>n>>m>>k;
    vector<int>a(k);
    vector<int>c(n+1, 0);
    for (int i=0; i<k; i++){
        cin>>a[i];
        c[a[i]]=1;
    }
    if (k==n){
        cout<<-1;
        return 0;
    }
    int V;
    for (int x=1; x<=n; x++){
        if (!c[x]){
            V=x;
            break;
        }
    }
    for (ll s1=1; s1<n; s1++){
        ll s2=n-1-s1;
        if (s2>=1 && n-1<=m && m<=(n-1)+f(s1)+f(s2)){
            vector<int>d1, d2;
            int x=1;
            while(d1.size()<s1){
                if (x==V){
                    x++;
                    continue;
                }
                d1.push_back(x);
                x++;
            }
            while(d2.size()<s2){
                if (x==V){
                    x++;
                    continue;
                }
                d2.push_back(x);
                x++;
            }
            for (int i=0; i<d1.size(); i++){
                cout<<V<<" "<<d1[i]<<endl;
            }
            for (int i=0; i<d2.size(); i++){
                cout<<V<<" "<<d2[i]<<endl;
            }
            m-=(n-1);
            for (int i=0; i<d1.size(); i++){
                for (int j=i+1; j<d1.size(); j++){
                    if (m){
                        cout<<d1[i]<<" "<<d1[j]<<endl;
                        m--;
                    }
                }
            }

            for (int i=0; i<d2.size(); i++){
                for (int j=i+1; j<d2.size(); j++){
                    if (m){
                        cout<<d2[i]<<" "<<d2[j]<<endl;
                        m--;
                    }
                }
            }
            return 0;
        }
    }
    cout<<-1;

    return 0;
}

/* Thu Jan 30 2020 12:57:05 GMT+0300 (MSK) */


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

ll f(ll x){
    return x*(x-1)/2;
}

vector<int>g[303];
int m1[303][303];
int m2[303][303];
int main(){

    //freopen("input.in", "r", stdin);freopen("input.out", "w", stdout);

    int n, m, k;
    cin>>n>>m>>k;
    vector<int>a(k);
    vector<int>c(n+1, 0);
    for (int i=0; i<k; i++){
        cin>>a[i];
        c[a[i]]=1;
    }

    if (k==n){
        cout<<-1;
        return 0;
    }
    int V;
    for (int x=1; x<=n; x++){
        if (!c[x])
            V=x;
    }

    for (int x=1; x<=n; x++){
        if (m>0 && x!=V){
            m--;
            g[x].push_back(V);
            g[V].push_back(x);
        }
    }
    for (int x=1; x<=n; x++){
        if (x==V)
            continue;
        for (int y=x+1; y<=n; y++){
            if (y==V)
                continue;
            if (m>0){
                m--;
                g[x].push_back(y);
                g[y].push_back(x);
            }
        }
    }

    for(int i = 1; i <= n; i++) {
            for(int j = 1; j <= n; j++) {
                if (i == j)
                    m2[i][j] = 0;
                else
                    m2[i][j] = 1e9;
            }
        }
        for (int x=1; x<=n; x++){
            for (int y:g[x]){
                m2[x][y]=1;
            }
        }

        for (int i = 0; i < k; i++) {
            int v = a[i];
            for(int j = 1; j <= n; j++)
                for(int r = 1; r <= n; r++)
                    m2[j][r] = min(m2[j][r], m2[j][v] + m2[v][r]);
        }

        for(int i = 1; i <= n; i++) {
            for(int j = 1; j <= n; j++) {
                if (i == j)
                    m1[i][j] = 0;
                else
                    m1[i][j] = 1e9;
            }
        }
        for (int x=1; x<=n; x++){
            for (int y:g[x]){
                m1[x][y]=1;
            }
        }

        for (int i = 1; i <= n; i++) {
            int v = i;
            for(int j = 1; j <= n; j++)
                for(int r = 1; r <= n; r++)
                    m2[j][r] = min(m2[j][r], m2[j][v] + m2[v][r]);
        }
        for (int x=1; x<=n; x++){
            for (int y=1; y<=n; y++){
                if (m1[x][y]!=m2[x][y]){
                    for (int x=1; x<=n; x++){
                        for (int y:g[x]){
                            if (x<y){
                                cout<<x<<" "<<y<<endl;
                            }
                        }
                    }
                    return 0;
                }
            }
        }
        cout<<-1;

    return 0;
}

/* Thu Jan 30 2020 13:53:11 GMT+0300 (MSK) */

/* Fri Jan 31 2020 00:17:32 GMT+0300 (MSK) */


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
#define fs first
#define sc second
#define pb push_back
const int mod = 1000000007;
const int N = 600;

int P[N], F[N][N], M[N];
int n, m, k;

bool print(){
	int s = 2;
	for(int i = 2; i <= n; ++i)
		if(!M[P[i]]) swap(P[s++], P[i]);
	int u = P[2], v = P[1], ec = 1;
	F[u][v] = F[v][u] = 1;
	for(int l = 1; l <= n; ++l){
		for(int j = 2; j + l <= n; ++j){
			u = P[j];
			v = P[j + l];
			F[u][v] = F[v][u] = 1;
			ec++;
			if(ec == m) goto out;
		}
	}
	for(int j = 3; j <= n; ++j){
		u = P[j];
		v = P[1];
		F[u][v] = F[v][u] = 1;
		ec++;
		if(ec == m) break;
	}
	out:
	int cut = 0;
	for(int i = 2; i <= n; ++i){
		u = P[i];
		v = P[1];
		if(F[u][v] && M[u])
			return false;
		if(!F[u][v]) cut++;
	}
	return cut;
}

int main(){
	cin >> n >> m >> k;
	int md = 1;
	for(int i = 1; i <= k; ++i){
		cin >> md;
		M[md] = 1;
	}
	for(int i = 1; i <= n; ++i)
		P[i] = i;
	swap(P[md], P[1]);

	if(!print()){
		puts("-1");
		return 0;
	}
	for(int i = 1; i <= n; ++i)
		for(int j = 1; j < i; ++j)
			if(F[i][j]) cout << j << " " << i << "\n";
}


/*بِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيم*/

#include <bits/stdc++.h>
using namespace std;

bool chk[305];
int main ()
{
    int i,n,m,k,x,y,z;

    scanf ("%d %d %d",&n,&m,&k);
    for (i=0;i<k;i++) {
        scanf ("%d",&x);
        chk[x]=true;
    }
    if (k==n) cout<<-1;
    else {
        for (i=1;i<=n;i++) if (!chk[i]) {
            x=(i-1+n)%n;
            break;
        }
        for (i=0;i<m;i++) {
            if (i%(n-1)==0) {
                z=i/(n-1)+1;
                y=(x+z)%n;
            }
            if (x==0) x+=n;
            if (y==0) y+=n;
            printf ("%d %d\n",x,y);
            x=y;
            y=(y+1)%n;
        }
    }

    return 0;
}


/*بِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيم*/

#include <bits/stdc++.h>
using namespace std;

bool chk[305];
int main ()
{
    int i,n,m,k,x,y;

    scanf ("%d %d %d",&n,&m,&k);
    for (i=0;i<k;i++) {
        scanf ("%d",&x);
        chk[x]=true;
    }
    if (m!=n-1 || k==n) cout<<-1;
    else {
        for (i=1;i<=n;i++) if (!chk[i]) {
            x=(i-1+n)%n;
            y=(i+n)%n;
            break;
        }
        for (i=1;i<n;i++) {
            if (x==0) x+=n;
            if (y==0) y+=n;
            printf ("%d %d\n",x,y);
            x=y;
            y=(y+1)%n;
        }
    }

    return 0;
}


/*بِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيم*/

#include <bits/stdc++.h>
using namespace std;

char edge[305][305];
bool chk[305];
int main ()
{
    int i,j,n,m,k,x,y,z,E;

    scanf ("%d %d %d",&n,&m,&k);
    for (i=0;i<k;i++) {
        scanf ("%d",&x);
        chk[x]=true;
    }
    y=(n*(n-1))/2-k+1;
    if (k==n || m>y) printf ("-1\n");
    else {
        for (i=1;i<=n;i++) if (!chk[i]) {
            y=i;
            break;
        }
        for (i=1;i<=n;i++) {
            if (i!=y) {
                if (i<y) edge[i][y]=1;
                else edge[y][i]=1;
            }
            if (chk[i]) {
                if (i<x) edge[i][x]=2;
                else edge[x][i]=2;
            }
        }
        E=n-1;
        for (i=1;i<=n && E<m;i++) for (j=i+1;j<=n && E<m;j++) if (edge[i][j]==0) {
            E++;
            edge[i][j]=1;
        }
        for (i=1;i<=n;i++) for (j=i+1;j<=n;j++) if (edge[i][j]==1) printf ("%d %d\n",i,j);
    }

    return 0;
}


/*بِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيم*/

#include <bits/stdc++.h>
using namespace std;

bool chk[305],edge[305][305];
int main ()
{
    int i,j,n,m,k,x,y,z;
    bool flag=false;

    scanf ("%d %d %d",&n,&m,&k);
    for (i=0;i<k;i++) {
        scanf ("%d",&x);
        chk[x]=true;
    }
    if (k==n) cout<<-1;
    else {
        for (i=1;i<=n;i++) if (!chk[i]) {
            x=(i-1+n)%n;
            break;
        }
        for (i=0;i<m;i++) {
            if (i%(n-1)==0) {
                z=i/(n-1)+1;
                y=(x+z)%n;
            }
            if (x==0) x+=n;
            if (y==0) y+=n;
            if (edge[x][y]) {
                flag=true;
                break;
            }
            else edge[x][y]=edge[y][x]=true;
            x=y;
            y=(y+1)%n;
        }
        if (flag) cout<<-1;
        else for (i=1;i<=n;i++) for (j=i+1;j<=n;j++) if (edge[i][j]) printf ("%d %d\n",i,j);
    }

    return 0;
}


#include <stdio.h>
#include <bits/stdc++.h>

#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)

using namespace std;

const int N = 50000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 239;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const double eps = 1e-9;
const double pi = atan2(0, -1);
const int ABC = 26;

int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    int n, m, k;
    cin >> n >> m >> k;
    bool bad[n]; fill(bad, bad + n, false);
    rep(i, 0, k)
    {
        int x;
        cin >> x;
        bad[x - 1] = true;
    }
    if (k == n || m > n * (n - 1) / 2 - 1 - (k - 2))
    {
        cout << -1 << "\n";
        return 0;
    }
    set<pair<int, int> > ans;
    int good = -1;
    rep(i, 0, n)
        if (!bad[i])
        {
            good = i;
            break;
        }
    vector<int> order;
    rep(i, 0, n)
        if (bad[i])
        {
            order.push_back(i);
            bad[i] = false;
            break;
        }
    order.push_back(good);
    rep(i, 0, n)
        if (bad[i])
        {
            order.push_back(i);
            bad[i] = false;
            break;
        }
    rep(i, 0, n)
        if (i != order[0] && i != order[1] && i != order[2])
            order.push_back(i);
    rep(i, 0, sz(order) - 1)
        ans.insert({min(order[i], order[i + 1]), max(order[i], order[i + 1])});
    rep(i, 0, n)
        rep(j, i + 1, n)
        {
            if (i == order[0] && j == order[2] || i == order[2] && j == order[0])
                continue;
            if (bad[i] && j == order[2] || bad[j] && i == order[2])
                continue;
            if (ans.find({i, j}) != ans.end())
                continue;
            if (sz(ans) == m)
                continue;
            ans.insert({i, j});
        }
    for (auto it : ans)
        cout << it.fi + 1 << " " << it.se + 1 << "\n";
    return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int n,m,mp[110000][2];
struct edge
{
    int w;
    int u;
    int numb;
}e[110000];
bool cmp(edge a,edge b)
{
    if(a.w!=b.w)
    return a.w<b.w;
    else
        return a.u>b.u;
}
int main()
{
    int i,plu=0,fi=2,fj=3,sum=0;
    cin>>n>>m;
    for(i=0;i<m;i++)
    {
        scanf("%d %d",&e[i].w,&e[i].u);
        e[i].numb=i;
    }
    sort(e,e+m,cmp);
    for(i=0;i<m;i++)
    {
        if(!e[i].u)
        {
            if(sum<1)
            {
                cout<<"-1"<<endl;
                return 0;
            }
            else
            {
                sum--;
                mp[e[i].numb][0]=fi;
                mp[e[i].numb][1]=fj;
                if(fi+1<fj)
                    fi++;
                else
                {
                    fj++;
                    fi=2;
                }
            }
        }
        else
        {
            sum+=plu;
            plu++;
            mp[e[i].numb][0]=1;
            mp[e[i].numb][1]=plu+1;
        }
    }
    for(i=0;i<m;i++)
    {
        printf("%d %d\n",mp[i][0],mp[i][1]);
    }
}


#include<stdio.h>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
#define maxn 100010
struct node
{
    int x,y;
}e[maxn],edge[maxn];
int cmp(node c,node d)
{
    return c.x<d.x;
}
int main()
{
    int n,m,i,j,k,sum,ans,ant;
    while(~scanf("%d%d",&n,&m))
    {
        sum=0;
        ans=0;
        for(i=1;i<=m;i++)
        {
            scanf("%d%d",&e[i].x,&e[i].y);
            if(e[i].y==1)
                sum+=e[i].x;
            edge[i].x=e[i].x;
            edge[i].y=e[i].y;
        }
        sort(edge+1,edge+1+m,cmp);
        for(i=1;i<n;i++)
            ans+=edge[i].x;
        ant=1;
        j=1;
        k=3;
        if(ans<sum)
            printf("-1\n");
        else
        {
            for(i=1;i<=m;i++)
            {
                if(e[i].y==1)
                {
                    printf("%d %d\n",ant,ant+1);
                    ant=ant+1;
                }
                else if(e[i].y==0)
                {
                    if(k>n)
                    {
                        j=j+1;
                        k=j+2;
                    }
                    printf("%d %d\n",j,k);
                    k=k+1;
                }
            }
        }
    }
}


#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
struct edge
{
    int num,cost,vis;
};
bool comp(const edge& e1,const edge& e2)
{
    if(e1.cost==e2.cost) return e1.vis>e2.vis;
    else
    return e1.cost<e2.cost;
}
edge es[1000500];
int used[1000500];
struct node
{
    int u,v;
};
node ans[1000500];
int main()
{
    int n,m;
    while(scanf("%d%d",&n,&m)!=EOF)
    {
        int w,b;
        memset(used,0,sizeof(used));
        for(int i=0;i<m;i++)
        {
            scanf("%d%d",&w,&b);
            es[i].num=i;
            es[i].vis=b;
            es[i].cost=w;
        }
        sort(es,es+m,comp);
        int ok=0;
        for(int i=0;i<n-1;i++)
        {
            if(es[i].vis==0) {ok=1;break;}
        }
        if(ok) printf("-1\n");
        else{
                int k=1,k1=2,k2=3;
            for(int i=0;i<m;i++)
            {
                if(es[i].vis==1)
                {
                    ans[es[i].num].u=1;
                    k++;
                    ans[es[i].num].v=k;
                }
                else{
                     ans[es[i].num].u=k1;
                     ans[es[i].num].v=k2;
                     k2++;
                     if(k2>n)
                     {
                         k1++;
                         k2=k1+1;
                     }
                }
            }
            for(int i=0;i<m;i++)
            {
                printf("%d %d\n",ans[i].u,ans[i].v);
            }
        }
    }
}


#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
using namespace std;
const int maxe = 110000;
struct node{
	int w;
	int ok;
}e[maxe], bao[maxe];
struct no{
	int u ,v;
}ee[maxe];

int cmp(node a, node b)
{
	if(a.w == b.w)	return a.ok > b.ok;
	else return a.w < b.w;
}

int main()
{
	int n, m;
	scanf("%d%d", &n, &m);
	for(int i = 0; i < m; i++)
	{
		scanf("%d%d", &e[i].w, &e[i].ok);
		bao[i].ok = e[i].ok;
		bao[i].w = e[i].w;
	}
	sort(e, e + m, cmp);
	int ok = 0;
	for(int i = 0; i < n - 1; i++)
	{
		if(e[i].ok == 0)
		{
			ok = 1;
			break;
		}
	}
	if(ok)
	{
		cout << -1 << endl;
		return 0;
	}
	int p = 0;
	for(int u = 1; u <= n; u++)
		for(int v = u + 1; v <= n; v++)
			if(v != u + 1)
			{
				ee[p].u = u;
				ee[p].v = v;
				p++;
			}
	int k = 1;
	int a = 0;
	for(int i = 0; i < m; i++)
	{
		if(bao[i].ok == 1)
		{
			printf("%d %d\n", k, k + 1);
			k++;
		}
		if(!bao[i].ok)
		{
			printf("%d %d\n", ee[a].u, ee[a].v);
			a++;
		}
	}
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
const int N=100010;
int n,m;
int a[N],b[N];
int c[N],d[N];

int cmp(int a,int b)
{
	return a<b;
}

int main()
{
	while(~scanf("%d%d",&n,&m))
	{
		int cnt=0,cot=0;
		for(int i=1;i<=m;i++)
		{
			scanf("%d%d",&a[i],&b[i]);
			if(b[i])
			c[cnt++]=a[i];
			else
			d[cot++]=a[i];

		}
		int p=n-1,q=m-n+1;
		sort(c,c+p,cmp);
		sort(d,d+q,cmp);
		int kk=0;
		int flag=0;
		for(int i=0;i<p;i++)
		{
			for(int j=i+1;j<p;j++)
			{
				if(d[kk]>=c[j])
				kk++;
				if(kk==q)
				{
					flag=1;
					break;
				}
			}
			if(flag)
			break;
		}
		if(kk!=q)
		{
			printf("-1\n");
			continue;
		}
		int t=2;
		int s=2;
		int e=3;
		for(int i=1;i<=m;i++)
		{
			if(b[i])
			printf("1 %d\n",t++);
			else
			{
				printf("%d %d\n",s,e++);
				if(e>n)
				{
					s++;
					e=s+1;
				}
			}
		}
	}
}


#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

struct Edge{
    int id,w,c,x,y;
}e[2000000];
bool cmp1(Edge a,Edge b){
    return a.w==b.w?a.c>b.c:a.w<b.w;
}
bool cmp2(Edge a,Edge b){
    return a.id<b.id;
}
int main(){
    int n,m,i,k,flag,a,b,num,j;
    while(~scanf("%d %d",&n,&m)){
        k=2;
        for(i=0;i<m;i++){
            scanf("%d %d",&a,&b);
            e[i].id=i;
            e[i].w=a;
            e[i].c=b;
            if(b){
                e[i].x=1;
                e[i].y=k++;
            }
        }
        sort(e,e+m,cmp1);
        k=flag=1;
        int p=2,q=3;
        for(i=0;i<m;i++){
            if(e[i].c==0)
            {
                if(k*(k-1)/2<i+1){flag=0;break;}
            }
            else k++;
        }
        num=0;
        if(flag){
            sort(e,e+m,cmp2);
            if(n==2) printf("1 2\n");
            for(i=2;i<n;i++){
                for(j=i+1;j<=n;j++)
                {
                    if(e[num++].c) j--,printf("%d %d\n",e[num-1].x,e[num-1].y);
                    else printf("%d %d\n",i,j);
                    if(num==m) break;
                }
                if(num==m) break;
            }
        }
        else printf("-1\n");
    }
    return 0;
}


#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
using namespace std;
const int maxe = 110000;
struct node{
	int w;
	int ok;
}e[maxe], bao[maxe];

int cmp(node a, node b)
{
	return a.w < b.w;
}

int main()
{
	int n, m;
	scanf("%d%d", &n, &m);
	for(int i = 0; i < m; i++)
	{
		scanf("%d%d", &e[i].w, &e[i].ok);
		bao[i].ok = e[i].ok;
		bao[i].w = e[i].w;
	}
	sort(e, e + m, cmp);
	int ok = 0;
	for(int i = 0; i < n - 2; i++)
	{
		if(e[i].ok == 0)
		{
			ok = 1;
			break;
		}
	}
	if(ok)
	{
		cout << -1 << endl;
		return 0;
	}
	int t = 0;
	int k = 1;
	for(int u = 1; u <= n; u++)
	{
		for(int v = 1; v <= n; v++)
		{
			if(t == m)
				return 0;
			if(bao[t].ok == 1)
			{
				printf("%d %d\n", k, k + 1);
				k++;
				t++;
			}
			else if(!bao[t].ok && u != v && u != v + 1 && u != v - 1)
			{
				printf("%d %d\n", u, v);
				t++;
			}
		}
	}
	return 0;
}


#include<iostream>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<ctime>
#define N 1100
#define M 100010
using namespace std;

struct node
{
    int num,valid;
};
node a[M];
int valid[M];
int n,m;
int cmp(const node &a,const node &b)
{
    return a.num<b.num||(a.num==b.num&&a.valid>b.valid);
}
int ansx[M],ansy[M];
int main()
{
    scanf("%d%d",&n,&m);

    for (int i=0; i<m; ++i)
    {
        scanf("%d%d",&a[i].num,&a[i].valid);
        valid[i]=a[i].valid;
    }
    sort(a,a+m,cmp);
    int cnt=0;
    for (int i=0; i<m; ++i)
    {
        cnt+=a[i].valid;
    }
    if (cnt!=n-1||a[0].valid==0)
    {
        printf("-1\n");
        return 0;
    }
    int cnt1=2,cnt2=2,cnt3=3;
    for (int i=0; i<m; ++i)
    {
        if (valid[i])
        {
           // printf("%d %d\n",1,cnt1++);
            ansx[i]=1;
            ansy[i]=cnt1++;
        }
        else
        {
        //    printf("%d %d\n",cnt2,cnt3++);

            ansx[i]=cnt2--;
            ansy[i]=cnt3;
            if (cnt2==1)
            {
                cnt3++;
                cnt2=cnt3-1;
            }
            if (ansx[i]>=cnt1||ansy[i]>=cnt1)
            {
                printf("-1\n");
                return 0;
            }
        }
    }
    for (int i=0;i<m;++i)
    {
        printf("%d %d\n",ansx[i],ansy[i]);
    }

    return 0;
}
/*2018-03-10 14:56:28.342*/


#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
typedef long long LL;
//strattime:2017/10/9 21:00
//endtime:2017/10/9 21:07

struct point
{
	int x,y,value,flag,index;
}a[100005];
bool cmp(point x,point y)
{
	if(x.value == y.value)
		return x.flag>y.flag;
	else
		return x.value<y.value;
}
bool cmp1(point x,point y)
{
	return x.index<y.index;
}
int n,m,i,j,ans,x,y,sum;
int main()
{
	cin>>n>>m;
	for(i=1;i<=m;i++)
	{
		cin>>a[i].value>>a[i].flag;
		a[i].index=i;
		if(a[i].flag)
			sum++;
	}
	if(sum!=n-1)
	{
		cout<<-1<<endl;
		return 0;
	}
	sort(a+1,a+1+m,cmp);
	ans= 1;
	x = y =1;
	for(i=1;i<=m;i++)
	{
		if(a[i].flag)
		{
			a[i].x = 1;
			a[i].y = ++ans;
		}
		else
		{
			if(y==ans)
			{
				x++;
				y=x;
			}
			if(x<ans)
			{
				a[i].x = x;
				a[i].y = ++y;
			}
			else
			{
				cout<<-1<<endl;
				return 0;
			}
		}
	}
	sort(a+1,a+1+m,cmp1);
	for(i=1;i<=m;i++)
	{
		cout<<a[i].x<<" "<<a[i].y<<endl;
	}
 return 0;
}/*2018-03-10 17:25:39.123*/


#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <functional>
#include <cstdlib>
#define PI acos(-1.0)
#define E exp(1.0)
#define ll long long int
#define db double
#define ull unsigned long long int
#define Fill(x,y) memset(x,y,sizeof(x))
#define bug printf("!!!!!!\n");
#define fi first
#define se second
#define pii pair<int,int>
#define pb push_back
#define sz(a) (int)(a).size()
using namespace std;
const db eps = 1e-6;
const int inf = 0x3f3f3f3f; //用这个可以直接mem
const ll INF = 1e18;
const int mod = 1e9+7;
const int maxn = 1e5+5;
pii e[maxn];
struct node {
    int u, v, w, id;
    node() {}
    node(int u, int v, int w, int id):
        u(u), v(v), w(w), id(id) {}
}s[maxn];
bool cmp1(node x, node y) {
    return x.w < y.w;
}
bool cmp2(node x, node y) {
    return x.id < y.id;
}
int fa[maxn], r[maxn];
int n, m;
void init() {
    for (int i = 1 ; i <= n ; i ++) {
        fa[i] = i;
        r[i] = 1;
    }
}
int Find(int x) {
    return fa[x] == x ? x : fa[x] = Find(fa[x]);
}
bool Un(int x, int y) {
    x = Find(x), y = Find(y);
    if (x == y) return false;
    if(r[x] < r[y])
        swap(x, y);
    fa[y] = x;
    r[x] += r[y];
    return true;
}
void solve()
{
    scanf("%d%d", &n, &m);
    int cnt = 0, mi = 0;
    for (int i = 1 ; i <= m ; i ++) {
        scanf("%d%d", &e[i].fi, &e[i].se);
        if (e[i].se) mi += e[i].fi, cnt++;
    }
    if (cnt != n-1) {
        printf("-1\n");
        return ;
    }
    int id1 = 1, id2 = 1, id3 = 3;
    for (int i = 1 ; i <= m ; i ++) {
        if (e[i].se) {
            int tmp = id1 + 1;
            s[i] = (node){id1, tmp, e[i].fi, i};
            ++id1;
        }
        else {
            if (id3 == n + 1) {
                ++id2;
                id3 = id2 + 2;
            }
            s[i] = (node){id2, id3, e[i].fi, i};
//            printf("%d %d\n", id2, id3);
            ++id3;
        }
    }
    sort(s+1, s+1+m, cmp1);
    int sum = 0, num = 0;
    init();
    for (int i = 1 ; i <= m ; i ++) {
        if (Un(s[i].u, s[i].v)) {
            sum += s[i].w;
            num ++;
        }
        if (num == n-1) break;
    }
    if (sum != mi) printf("-1\n");
    else {
        sort(s+1, s+1+m, cmp2);
        for (int i = 1 ; i <= m ; i ++) {
            printf("%d %d\n", s[i].u, s[i].v);
        }
    }
}
int main()
{
    // freopen("in.txt","r",stdin);
    //  freopen("out.txt","w",stdout);
    int t = 1 , cas = 1;
    //scanf("%d",&t);
    while(t--){
       // printf("Case %d: ", cas++);
        solve();
        //printf("\n");
    }
}

/*2018-03-10 14:34:21.371*/


#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long LL;
const int Max = 1e5;

struct PP{
	int num, f, pos;
};
PP a[Max + 5], b[Max + 5];
bool vis[Max + 5];

bool cmp(PP x, PP y) {
	return x.num < y.num;
}
int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= m; i++) {
		scanf("%d%d", &a[i].num, &a[i].f);
		a[i].pos = i;
	}
	sort(a + 1, a + m + 1, cmp);
	bool f = 0;
	if(a[1].f == 0) {
		f = 1;
	}
	int x = 0, y = 1, fx = 1, fy = 3;
	int sum = 0, su = 0;
	for(int i = 1; i <= m; i++) {
		if(a[i].f == 0) {
			if(fy == n) {
				fx++;
				fy = fx + 2;
			}
			if(fx == n - 1) f = 1;
			b[a[i].pos].num = fx;
			b[a[i].pos].pos = fy;
			fy++;
		}
		else {
			b[a[i].pos].num = ++x;
			b[a[i].pos].pos = ++y;
			vis[x] = 1; vis[y] = 1;
			su++;
		}
	}
	for(int i = 1; i <= n; i++) if(vis[i]) sum++;
	if(sum != n || su != n - 1) f = 1;
	if(f == 1) printf("-1\n");
	else {
		for(int i = 1; i <= m; i++) printf("%d %d\n", b[i].num, b[i].pos);
	}
	return 0;
}
/*2018-03-10 13:27:08.889*/


#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
const int MaxN = 1e5;
using namespace std;
struct EDGE {
	int w, id, pos;
	int u, v;
}a[MaxN + 5], res[MaxN + 5];

bool cmp(EDGE A, EDGE B) {
	return A.w < B.w;
}

int main()
{
	int n, m; scanf("%d%d", &n, &m);
	for (int i = 1; i <= m; i++) scanf("%d %d", &a[i].w, &a[i].id), a[i].pos = i;
	sort (a + 1, a + m + 1, cmp);
	int l = 2, r = 2, cnt = 1;
	bool ok = 1;
	for (int i = 1; i <= m; i++) {
		if(a[i].id == 0) {
			while(r <= l && r < cnt) r++;
			if(l >= r) ok = 0;
			else {
				res[a[i].pos].u = l, res[a[i].pos].v = r;
			}
			if(r >= cnt) l++, r = l;
			else r++;
		}
		else {
			res[a[i].pos].u = 1, res[a[i].pos].v = ++cnt;
		}
	}
	if(!ok || cnt < n) printf("-1\n");
	else {
		for (int i = 1; i <= m; i++) printf("%d %d\n", res[i].u, res[i].v);
	}
}
/*2018-03-10 15:17:43.98*/


#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
typedef long long LL;
//strattime:2017/10/9 21:00
//endtime:2017/10/9 21:07

struct point
{
	int x,y,value,flag,index;
}a[100005];
bool cmp(point x,point y)
{
	if(x.value == y.value)
		return x.flag>y.flag;
	else
		return x.value<y.value;
}
bool cmp1(point x,point y)
{
	return x.index<y.index;
}
int n,m,i,j,ans,x,y,sum;
int main()
{
	cin>>n>>m;
	for(i=1;i<=m;i++)
	{
		cin>>a[i].value>>a[i].flag;
		a[i].index=i;
		if(a[i].flag)
			sum++;
	}
	if(sum!=n-1)
	{
		cout<<-1<<endl;
		return 0;
	}
	sort(a+1,a+1+m,cmp);
	ans= 1;
	x = y =2;
	for(i=1;i<=m;i++)
	{
		if(a[i].flag)
		{
			a[i].x = 1;
			a[i].y = ++ans;
		}
		else
		{
			if((ans-1+1)*(ans-1)/2>=i)
			{
				if(x<2)
				{
					y++;
					x=y-1;
					a[i].x = x--;
					a[i].y = y;
				}
				else
				{
					a[i].x = x--;
					a[i].y =y;
				}
			}
			else
			{
				cout<<-1<<endl;
				return 0;
			}
		}
	}
	sort(a+1,a+1+m,cmp1);
	for(i=1;i<=m;i++)
	{
		cout<<a[i].x<<" "<<a[i].y<<endl;
	}
 return 0;
}/*2018-03-10 17:54:08.188*/


#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<stack>
#include<map>

using namespace std;

#define FOU(i,x,y) for(int i=x;i<=y;i++)
#define FOD(i,x,y) for(int i=x;i>=y;i--)
#define MEM(a,val) memset(a,val,sizeof(a))
#define PI acos(-1.0)

const double EXP = 1e-9;
typedef long long ll;
typedef unsigned long long ull;
const int INF = 0x3f3f3f3f;
const ll MINF = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9+7;
const int N = 1e6+5;

int n,m;

struct node
{
    int num;
    int val;
    int idx;
}a[100005];

bool cmp(node A,node B)
{
    return A.num<B.num;
}

struct node1
{
    int x;
    int y;
    int pos;
}ans[100005];

bool cmp1(node1 A,node1 B)
{
    return A.pos<B.pos;
}

bool solve()
{
    int cnt=1;
    int now=0,next=-1;
    for(int i=1;i<=m;i++)
    {
        if(a[i].val==0)
        {
            if(next==-1||next==cnt+1)
            {
                now++;
                next=now+2;
                if(next<=cnt)
                {
                    ans[i].x=now;
                    ans[i].y=next;
                    ans[i].pos=a[i].idx;
                    next++;
                }
                else
                    return false;
            }
            else
            {
                ans[i].x=now;
                ans[i].y=next;
                ans[i].pos=a[i].idx;
                next++;
            }
        }
        else if(a[i].val==1)
        {
            if(cnt==n)
            {
                if(next==-1||next==cnt+1)
                {
                    now++;
                    next=now+2;
                    if(next<=cnt)
                    {
                        ans[i].x=now;
                        ans[i].y=next;
                        ans[i].pos=a[i].idx;
                        next++;
                    }
                    else
                        return false;
                }
                else
                {
                    ans[i].x=now;
                    ans[i].y=next;
                    ans[i].pos=a[i].idx;
                    next++;
                }
            }
            else
            {
                ans[i].x=cnt;
                ans[i].y=cnt+1;
                ans[i].pos=a[i].idx;
                cnt++;
            }
        }
    }
    return true;
}

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    std::ios::sync_with_stdio(false);
    while(~scanf("%d%d",&n,&m))
    {
        for(int i=1;i<=m;i++)
        {
            scanf("%d%d",&a[i].num,&a[i].val);
            a[i].idx=i;
        }
        sort(a+1,a+1+m,cmp);
        bool flag=solve();
        if(flag==false)
            printf("-1\n");
        else
        {
            sort(ans+1,ans+1+m,cmp1);
            for(int i=1;i<=m;i++)
                printf("%d %d\n",ans[i].x,ans[i].y);
        }
    }
    return 0;
}
/*2018-03-12 17:38:47.935*/


#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;
const int maxn = 100000;
struct NOOD {
	int u, v, w, pos, is;
}num[maxn + 5];
int n, m;
bool cmp(NOOD x, NOOD y) {
	return x.w < y.w;
}
bool cmp2(NOOD x, NOOD y) {
	return x.pos < y.pos;
}
int main() {
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= m; i++) {
		scanf("%d%d", &num[i].w, &num[i].is);
		num[i].pos = i;
	}
	sort(num + 1, num + m + 1, cmp);
	int cnt = 0;
	for(int i = 1; i <= m; i++) {
		if(i <= n - 1) {
			if(num[i].is == 0) {
				printf("-1\n");
				return 0;
			}
		}
		if(num[i].is == 1)cnt++;
	}
	if(cnt != n - 1) {
		printf("-1\n");
		return 0;
	}
	int len = 0;
	for(int i = 1; i <= n - 1; i++) {
		if(len >= m)break;
		num[++len].u = i, num[len].v = i + 1;
	}
	for(int l = 2; l <= n - 1; l++) {
		if(len >= m)break;
		for(int i = 1; i <= n - l; i++) {
			if(len >= m)break;
			num[++len].u = i, num[len].v = i + l;
		}
	}
	sort(num + 1, num + m + 1, cmp2);
	for(int i = 1; i <= m; i++)printf("%d %d\n", num[i].u, num[i].v);
	return 0;
}/*2018-03-10 17:12:52.641*/


#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int num[100005],x[100005],y[100005];
bool vail[100005];
int ss[100005];
int main()
{
	int n,m,a,b;
	int Max = 0,cnt = 0,tt = 0,cc = 0;
	scanf("%d%d",&n,&m);
	for(int i = 1;i <= m; i++){
		scanf("%d%d",&a,&b);
		num[i] = a; vail[i] = b;
		if(b){
			cnt++;
			Max = max(Max,a);
		}
		else{
			ss[++tt] = i;
			cc++;
		}
	}
	int flag = 0;
	for(int i = 1; i <= m; i++){
		if(vail[i] == 0){
			if(num[i] < Max)
				flag = 1;
		}
	}
	if(cnt != n - 1 || flag){
		printf("-1\n");
		return 0;
	}
	int tot = 1;
	for(int i = 1; i <= m; i++){
		if(vail[i] == 1){
			x[i] = tot++;
			y[i] = tot;
		}
     }
     tt = 0;
     for(int i = 1;i <= n; i++){
     	 for(int j= i + 2; j <= n; j++){
              x[ss[++tt]]= i;
              y[ss[tt]] = j;
              if(tt == cc) break;
         }
         if(tt == cc) break;
	 }
	 for(int i = 1; i <= m; i++){
	 	 printf("%d %d\n",x[i],y[i]);
	 }
	 return 0;
}
    /*2018-03-10 15:22:17.037*/


#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<stack>
#include<map>

using namespace std;

#define FOU(i,x,y) for(int i=x;i<=y;i++)
#define FOD(i,x,y) for(int i=x;i>=y;i--)
#define MEM(a,val) memset(a,val,sizeof(a))
#define PI acos(-1.0)

const double EXP = 1e-9;
typedef long long ll;
typedef unsigned long long ull;
const int INF = 0x3f3f3f3f;
const ll MINF = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9+7;
const int N = 1e6+5;

int n,m;

struct node
{
    int num;
    int val;
    int idx;
}a[100005];

bool cmp(node A,node B)
{
    return A.num<B.num;
}

struct node1
{
    int x;
    int y;
    int pos;
}ans[100005];

bool cmp1(node1 A,node1 B)
{
    return A.pos<B.pos;
}

int len[100005];  //len[i]表示i点连的最后一个点，初始化为i

bool solve()
{
    for(int i=1;i<=n;i++)
        len[i]=i;
    int cnt=1;
    for(int i=1;i<=m;i++)
    {
        if(a[i].val==0)
        {
            bool flag=true;
            for(int j=1;j<=cnt;j++)
            {
                if(len[j]<cnt)
                {
                    flag=false;
                    ans[i].x=j;
                    ans[i].y=++len[j];
                    ans[i].pos=a[i].idx;
                    break;
                }
                else
                    ;
            }
            if(flag)
                return false;
            else
                ;
        }
        else if(a[i].val==1)
        {
            if(cnt==n)
                return false;
            else
            {
                len[cnt]++;
                ans[i].x=cnt;
                ans[i].y=++cnt;
                ans[i].pos=a[i].idx;
            }
        }
    }
    return true;
}

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    std::ios::sync_with_stdio(false);
    while(~scanf("%d%d",&n,&m))
    {
        for(int i=1;i<=m;i++)
        {
            scanf("%d%d",&a[i].num,&a[i].val);
            a[i].idx=i;
        }
        sort(a+1,a+1+m,cmp);
        bool flag=solve();
        if(flag==false)
            printf("-1\n");
        else
        {
            sort(ans+1,ans+1+m,cmp1);
            for(int i=1;i<=m;i++)
                printf("%d %d\n",ans[i].x,ans[i].y);
        }
    }
    return 0;
}
/*2018-03-12 18:08:48.609*/


#include<iostream>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<ctime>
#define N 1100
#define M 100010
using namespace std;

struct node
{
    int num,valid;
};
node a[M];
int valid[M];
int n,m;
int cmp(const node &a,const node &b)
{
    return a.num<b.num||(a.num==b.num&&a.valid>b.valid);
}
int ansx[M],ansy[M];
int main()
{
    scanf("%d%d",&n,&m);

    for (int i=0; i<m; ++i)
    {
        scanf("%d%d",&a[i].num,&a[i].valid);
        valid[i]=a[i].valid;
    }
    sort(a,a+m,cmp);
    int cnt=0;
    int cnt1=1,cnt2=2,cnt3=3;
    for (int i=0; i<m; ++i)
    {
        cnt+=a[i].valid;
    }
    if (cnt!=n-1||a[0].valid==0)
    {
        printf("-1\n");
        return 0;
    }
    cnt1=1,cnt2=0;
    for (int i=0;i<m;++i)
    {
        if (a[i].valid==1)
        {
            cnt1++;
        }
        else
        {
            cnt2++;
            if (cnt2>(cnt1-1)*(cnt1-2)/2)
            {
                printf("-1\n");
            //    return 0;
            }
        }

        //    printf("%d %d\n",cnt1,cnt2);
    }
    cnt1=1,cnt2=2,cnt3=3;
    for (int i=0; i<m; ++i)
    {
        if (valid[i])
        {
           // printf("%d %d\n",1,cnt1++);
            ansx[i]=1;
            ansy[i]=++cnt1;
        }
        else
        {
        //    printf("%d %d\n",cnt2,cnt3++);

            ansx[i]=cnt2--;
            ansy[i]=cnt3;
            if (cnt2==1)
            {
                cnt3++;
                cnt2=cnt3-1;
            }
          //  if (ansx[i]>cnt1||ansy[i]>cnt1)
          //  {
          //      printf("-1\n");
          //      return 0;
          //  }
        }
    }
    for (int i=0;i<m;++i)
    {
        printf("%d %d\n",ansx[i],ansy[i]);
    }

    return 0;
}
/*2018-03-10 15:11:57.094*/