#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef map<int, int>  mii;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define fi first
#define se second
const int MAX = numeric_limits<int>::max();
const int MIN = numeric_limits<int>::min();
const ll mod = 1e9 + 7;
const int N = 100010;
void Pause() {
    cin.clear();
    cin.sync();
    cin.get();
}
void FastRead() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}
inline char Nowchar() {
    static char buf[1 << 20], *p1 = buf, *p2 = buf;
    bool flag = (p1 == p2) &&
                (p2 = (p1 = buf) + fread(buf, 1, 1 << 20, stdin), p1 == p2);
    return flag ? EOF : *p1++;
}
inline int Read() {
    int x = 0, f = 1;
    static char c = Nowchar();
    for (; c > '9' || c < '0'; c = Nowchar()) {
        if (c == '-') f = -1;
    }
    for (; c <= '9' && c >= '0'; c = Nowchar()) {
        x = (x << 3) + (x << 1) + c - 48;
    }
    return x * f;
}

// void Solve() {
//     int t;
//     cin >> t;
//     while (t--) {
//         int n;
//         cin >> n;
//         string s;
//         cin >> s;
//         vector<int> a;
//         for (int i = 0, j; i < n; i = j) {
//             for (j = i; j < n && s[i] == s[j]; ++j)
//                 ;
//             a.push_back(j - i);
//         }
//         for (auto x : a) {
//             cout << x << " ";
//         }
//         cout << endl;
//         int ans = 0;
//         for (int i = 0; i < int(a.size()); ++i) {
//             ans = min(i + 1, ans + a[i] - 1);
//             cout << i << ":" << ans << " ";
//         }
//         cout << endl;
//         cout << ans + (a.size() - ans + 1) / 2 << endl;
//     }
// }
void Solve() {
    int t;
    cin >> t;
    while (t--) {
        int n;
        cin >> n;
        string s;
        cin >> s;
        vector<int> a;
        int i, j;
        for (i = 0; i < n; i = j) {
            for (j = i; j < n && s[i] == s[j]; j++) {}
            a.push_back(j - i);
        }
        a.pop_back();
        int ans = 0;
        for (int i = 0; i < a.size() - 1; i++) {
            if (a[i] == 0) {
                continue;
            }
            ans++;
            if (a[i] == 1) {
                int j = i + 1;
                while (j < a.size() && a[j] < 2) {
                    j++;
                }
                if (j < a.size()) {
                    a[j]--;
                } else {
                    a[i + 1]--;
                }
            }
        }
        if (a[a.size() - 1] > 0) {
            ans++;
        }
        cout << ans << endl;
    }
}

int main(int argc, char** argv) {
    Solve();
    //Pause();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int MAXN = 200100;
char s[MAXN];
int main() {
#ifdef TEST
	freopen("input.txt", "r", stdin);
#endif
	int T;
	scanf("%d", &T);
	while (T--) {
		int n;
		scanf("%d%s", &n, s);
		queue<pair<int, int>> t;
		int num = 0, tim = 1;
		for (int i = 1; i < n; ++i) {
			if (s[i] == s[i - 1]) {
				tim++;
			} else {
				if (tim > 1) t.push(make_pair(num, tim));
				num++;
				tim = 1;
			}
		}
		if (tim > 1) t.push(make_pair(num, tim));
		int st = 0;
		while (!t.empty()) {
			t.front().second--;
			if (t.front().second == 1 || t.front().first == st) {
				t.pop();
			}
			st++;
		}
		printf("%d\n", st + (num - st + 2) / 2);
	}
	return 0;
}

/*
5 1
1 2
2 3
3 4
4 5
2 2 2 2 2
*/


#include<bits/stdc++.h>
using namespace std;
int l[200010],r[200010],len[200010];
char st[200010];
int main(){
	int T;
	scanf("%d",&T);
	while(T--){
		int n;
		scanf("%d",&n);
		scanf("%s",st);
		char ch=st[0];
		int t=1;
		int length=0;
		l[1]=1,r[1]=1;
		for(int i=1;i<n;i++){
			if(ch==st[i]){
				r[t]++;
			}else{
				ch=st[i];
				l[++t]=r[t]=i+1;
			}
		}
		for(int i=1;i<=t;i++){
			len[i]=r[i]-l[i]+1;
			length+=len[i];
		}
		int ans=0;
		int ll=1,rr=t;
		while(t-ll+1){
			if(len[ll]>=2){
				ll++;
				ans++;
			}else{
				bool flg=1;
				for(int j=ll;j<=t;j++){
					if(len[j]>=2) {
						len[j]--;ans++;flg=0;break;
					}
				}
				if(flg){
					ll++;
					ans++;
				}
				if(t-ll+1)ll++;
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
template <typename T>
void readin(T &x) {
	x = 0;
	T fh = 1;
	char ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') fh = -1;
	for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ 48);
	x *= fh;
}
void d_read(double &x) {
	x = 0.0;
	int fh = 1;
	char ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') fh = -1;
	for (; isdigit(ch); ch = getchar()) x = x * 10 + (ch ^ 48);
	if (ch == '.') {
		double num = 1.0;
		ch = getchar();
		for (; isdigit(ch); ch = getchar()) x = x + (num /= 10) * (ch ^ 48);
	}
	x *= fh;
}

template <typename T>
void wt(T x) {
	if (x > 9) wt(x / 10);
	putchar(x % 10 + 48);
}
template <typename T>
void writeln(T x, char c) {
	if (x < 0) {
		putchar('-');
		x = -x;
	}
	wt(x);
	putchar(c);
}
const int N = 2e5 + 5;
char s[N];
int a[N];
int main() {
	int t;
	readin(t);
	while (t --) {
		int n;
		readin(n);
		scanf("%s", s + 1);
		int tot = 1, opt = s[1] - '0', la = 0;
		for (int i = 2; i <= n; i ++) {
			if (s[i] - '0' != opt) {
				la ++;
				a[la] = tot;
				tot = 1;
				opt = s[i] - '0';
			}
			else tot ++;
		}
		la ++;
		a[la] = tot;
		int cnt = 0, l = 1;
		while (cnt < la) {
			while (l <= la && a[l] == 1) l ++;
			if (l > la) la --;
			else a[l] --;
			if (l == cnt + 1) l ++;
			cnt ++;
		}
		writeln(cnt, '\n');
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
template <typename T>
void readin(T &x) {
	x = 0;
	T fh = 1;
	char ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') fh = -1;
	for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ 48);
	x *= fh;
}
void d_read(double &x) {
	x = 0.0;
	int fh = 1;
	char ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') fh = -1;
	for (; isdigit(ch); ch = getchar()) x = x * 10 + (ch ^ 48);
	if (ch == '.') {
		double num = 1.0;
		ch = getchar();
		for (; isdigit(ch); ch = getchar()) x = x + (num /= 10) * (ch ^ 48);
	}
	x *= fh;
}

template <typename T>
void wt(T x) {
	if (x > 9) wt(x / 10);
	putchar(x % 10 + 48);
}
template <typename T>
void writeln(T x, char c) {
	if (x < 0) {
		putchar('-');
		x = -x;
	}
	wt(x);
	putchar(c);
}
const int N = 2e5 + 5;
char s[N];
int a[N], b[N];
int main() {
	int t;
	readin(t);
	while (t --) {
		int n;
		readin(n);
		scanf("%s", s + 1);
		int tot = 1, opt = s[1] - '0', la = 0, lb = 0;
		for (int i = 2; i <= n; i ++) {
			if (s[i] - '0' != opt) {
				la ++;
				a[la] = tot;
				if (tot > 1) {
					lb ++;
					b[lb] = la;
				}
				tot = 1;
				opt = s[i] - '0';
			}
			else tot ++;
		}
		la ++;
		a[la] = tot;
		if (tot > 1) {
			lb ++;
			b[lb] = la;
		}
		int cnt = 0, l = 1;
		while (cnt < la) {
			if (l <= lb) {
				a[b[l]] --;
				if (a[b[l]] == 1) l ++;
			}
			else la --;
			if (l == cnt) l ++;
			cnt ++;
		}
		writeln(cnt, '\n');
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
template <typename T>
void readin(T &x) {
	x = 0;
	T fh = 1;
	char ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') fh = -1;
	for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ 48);
	x *= fh;
}
void d_read(double &x) {
	x = 0.0;
	int fh = 1;
	char ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') fh = -1;
	for (; isdigit(ch); ch = getchar()) x = x * 10 + (ch ^ 48);
	if (ch == '.') {
		double num = 1.0;
		ch = getchar();
		for (; isdigit(ch); ch = getchar()) x = x + (num /= 10) * (ch ^ 48);
	}
	x *= fh;
}

template <typename T>
void wt(T x) {
	if (x > 9) wt(x / 10);
	putchar(x % 10 + 48);
}
template <typename T>
void writeln(T x, char c) {
	if (x < 0) {
		putchar('-');
		x = -x;
	}
	wt(x);
	putchar(c);
}
const int N = 2e5 + 5;
char s[N];
int a[N];
int main() {
	int t;
	readin(t);
	while (t --) {
		int n;
		readin(n);
		scanf("%s", s + 1);
		int tot = 1, opt = s[1] - '0', la = 0;
		for (int i = 2; i <= n; i ++) {
			if (s[i] - '0' != opt) {
				la ++;
				a[la] = tot;
				tot = 1;
				opt = s[i] - '0';
			}
			else tot ++;
		}
		la ++;
		a[la] = tot;
		int cnt = 0, l = 1;
		while (cnt < la) {
			while (l <= la && a[l] == 1) l ++;
			if (l > la) la --;
			else a[l] --;
			if (l == cnt) l ++;
			cnt ++;
		}
		writeln(cnt, '\n');
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
template <typename T>
void readin(T &x) {
	x = 0;
	T fh = 1;
	char ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') fh = -1;
	for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ 48);
	x *= fh;
}
void d_read(double &x) {
	x = 0.0;
	int fh = 1;
	char ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') fh = -1;
	for (; isdigit(ch); ch = getchar()) x = x * 10 + (ch ^ 48);
	if (ch == '.') {
		double num = 1.0;
		ch = getchar();
		for (; isdigit(ch); ch = getchar()) x = x + (num /= 10) * (ch ^ 48);
	}
	x *= fh;
}

template <typename T>
void wt(T x) {
	if (x > 9) wt(x / 10);
	putchar(x % 10 + 48);
}
template <typename T>
void writeln(T x, char c) {
	if (x < 0) {
		putchar('-');
		x = -x;
	}
	wt(x);
	putchar(c);
}
const int N = 2e5 + 5;
char s[N];
int a[N], b[N];
int main() {
	int t;
	readin(t);
	while (t --) {
		int n;
		readin(n);
		scanf("%s", s + 1);
		int tot = 1, opt = s[1] - '0', la = 0, lb = 0;
		for (int i = 2; i <= n; i ++) {
			if (s[i] - '0' != opt) {
				la ++;
				a[la] = tot;
				if (tot > 1) {
					lb ++;
					b[lb] = la;
				}
				tot = 1;
				opt = s[i] - '0';
			}
			else tot ++;
		}
		la ++;
		a[la] = tot;
		if (tot > 1) {
			lb ++;
			b[lb] = la;
		}
		int cnt = 0, l = 0;
		while (cnt < la) {
			if (l < lb) {
				a[b[l]] --;
				if (a[b[l]] == 1) l ++;
			}
			else la --;
			if (l == cnt) l ++;
			cnt ++;
		}
		writeln(cnt, '\n');
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
template <typename T>
void readin(T &x) {
	x = 0;
	T fh = 1;
	char ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') fh = -1;
	for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ 48);
	x *= fh;
}
void d_read(double &x) {
	x = 0.0;
	int fh = 1;
	char ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') fh = -1;
	for (; isdigit(ch); ch = getchar()) x = x * 10 + (ch ^ 48);
	if (ch == '.') {
		double num = 1.0;
		ch = getchar();
		for (; isdigit(ch); ch = getchar()) x = x + (num /= 10) * (ch ^ 48);
	}
	x *= fh;
}

template <typename T>
void wt(T x) {
	if (x > 9) wt(x / 10);
	putchar(x % 10 + 48);
}
template <typename T>
void writeln(T x, char c) {
	if (x < 0) {
		putchar('-');
		x = -x;
	}
	wt(x);
	putchar(c);
}
const int N = 2e5 + 5;
char s[N];
int a[N], b[N];
int main() {
	int t;
	readin(t);
	while (t --) {
		int n;
		readin(n);
		scanf("%s", s + 1);
		int tot = 1, opt = s[1] - '0', la = 0, lb = 0;
		for (int i = 2; i <= n; i ++) {
			if (s[i] - '0' != opt) {
				la ++;
				a[la] = tot;
				if (tot > 1) {
					lb ++;
					b[lb] = la;
				}
				tot = 1;
				opt = s[i] - '0';
			}
			else tot ++;
		}
		la ++;
		a[la] = tot;
		if (tot > 1) {
			lb ++;
			b[lb] = la;
		}
		int cnt = 0, l = 1;
		while (cnt < la) {
			if (l <= lb) {
				a[b[l]] --;
				if (a[b[l]] == 1) l ++;
			}
			else la --;
			if (b[l] == cnt) l ++;
			cnt ++;
		}
		writeln(cnt, '\n');
	}
	return 0;
}


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

#define rep(i, a, b) for(int i=a; i<=b; i++)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int) x.size()
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MOD = 1e9+7;

int t, n;
string s;

int main(){
  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
  cin.sync_with_stdio(0); cin.tie();
  cin.exceptions(cin.failbit);

  cin >> t;
  while(t--){
    cin >> n >> s;
    vi vec;
    int cnt=1;
    int ans=0;
    char c=s[0];
    rep(i, 1, n-1){
      if(s[i]!=c){
        vec.pb(cnt);
        c=s[i];
        cnt=1;
      }
      else cnt++;
    }
    if(cnt) vec.pb(cnt);
    vi take(n);
    for(int i=sz(vec)-1; i>=0; i--){
      take[i]=max(0, vec[i]-1)+(i==sz(vec)-1?0:take[i+1]);
    }

    int taken=0;
    int ind=sz(vec);
    rep(i, 0, sz(vec)-1){
      if(take[i]-taken==0){
        ind=i; break;
      }
      if(vec[i]==1) taken++;
    }
    cout << ind+ceil((double)(sz(vec)-ind)/2) << endl;
  }
}


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

#define rep(i, a, b) for(int i=a; i<=b; i++)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int) x.size()
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MOD = 1e9+7;

int t, n;
string s;

int main(){
  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
  cin.sync_with_stdio(0); cin.tie();
  cin.exceptions(cin.failbit);

  cin >> t;
  while(t--){
    cin >> n >> s;
    vi vec;
    int cnt=1;
    int ans=0;
    char c=s[0];
    rep(i, 1, n-1){
      if(s[i]!=c){
        vec.pb(cnt);
        c=s[i];
        cnt=1;
      }
      else cnt++;
    }
    if(cnt) vec.pb(cnt);

    int x=0;
    int ind=sz(vec);
    rep(i, 0, sz(vec)-1){
      if(vec[i]>1) continue;
      x=i+1;
      while(x<sz(vec) && vec[x]==1) x++;
      if(x==sz(vec)){
        ind=i; break;
      }
      vec[x]--;
    }

    cout << ind+ceil((double)(sz(vec)-ind)/2) << endl;
  }
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <map>
#include <set>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

typedef unsigned long long ull;

const int INF=1000000000,MAXN=333;

template <class T> T sqr(T a) {
    return a*a;
}

int a[MAXN];
bool c[MAXN][MAXN];
int n,m,k,i,j,kolE;

int main()
{
    ios_base::sync_with_stdio(0);

    cin >> n >> m >> k;

    for (i=0;i<k;i++)
        cin >> a[i];

    if (n*(n-1)/2-k>=m) {
        kolE=n*(n-1)/2;
        for (i=1;i<n;i++)
            for (j=1;j<=n;j++)
                c[i][j]=1;
        for (i=1;i<=n;i++)
            c[i][i]=0;
        kolE-=n-1;
        for (i=1;i<=n;i++)
            c[1][i]=c[i][1]=0;
        kolE+=k-1;
        for (i=0;i<k;i++) {
            j=a[i];
            if (j==1) continue;
            c[i][j]=c[j][i]=1;
        }
        for (i=1;i<=n;i++)
            for (j=1;j<=n;j++) {
                if (kolE>m && c[i][j]) {
                    c[i][j]=0;
                    kolE--;
                }
            }
        for (i=1;i<=n;i++)
            for (j=i+1;j<=n;j++)
                if (c[i][j])
                cout << i << ' ' << j << '\n';
    }
    else {
        cout << -1;
    }

    return 0;
}


#include <iostream>
#include <cstdlib>
#include <cstring>
#include <vector>

using namespace std;

int n,m,k,i,j,v,kolE,key;
vector<pair<int,int> > edges;
bool c[333][333];
int a[333];
int p[333];

void init(int n) {
    for (i=1;i<=n;i++)
        p[i]=i;
}

int get_set(int x) {
    if (p[x]==x) return x;
    return p[x]=get_set(p[x]);
}

void union_sets(int x, int y) {
    x=get_set(x);
    y=get_set(y);
    if (rand()&1) swap(x,y);
    p[x]=y;
}

void tryAddEdgeTree(int x, int y) {
    if (c[x][y]==0) return;
    if (get_set(x)==get_set(y)) return;
    union_sets(x,y);
    edges.push_back(make_pair(x,y));
    c[x][y]=c[y][x]=0;
}

void tryAddEdge(int x, int y) {
    if (c[x][y]==0) return;
    edges.push_back(make_pair(x,y));
    c[x][y]=c[y][x]=0;
}

int main()
{
    cin >> n >> m >> k;
    key=0;
    for (i=0;i<k;i++) {
        cin >> a[i];
        if (a[i]==1) key=true;
    }
    v=a[0];
    kolE=(n*(n-1))/2;
    if (kolE-(n-k)>=m) {
        memset(c,1,sizeof(c));
        for (i=1;i<=n;i++)
            c[i][i]=0;
        for (i=0;i<k;i++)
            c[v][a[i]]=c[a[i]][v]=false;
        for (i=1;i<=n;i++)
            for (j=1;j<=n;j++)
                tryAddEdgeTree(i,j);
        if ((int)edges.size()>m) {
            cout << -1;
            return 0;
        }
        for (i=1;i<=n;i++)
            for (j=1;j<=n;j++) {
                if ((int)edges.size()<m) {
                    tryAddEdge(i,j);
                }
            }
        if ((int)edges.size()!=m) {
            cout << -1;
            return 0;
        }
        else {
            for (size_t i=0;i<edges.size();i++)
                cout << edges[i].first << ' ' << edges[i].second << '\n';
        }
    }
    else {
        cout << "-1";
    }
    return 0;
}


#include <iostream>
#include <cstring>

using namespace std;

int n,m,k,i,j,v,kolE,key;
int a[333];
bool c[333][333];

int main()
{
    cin >> n >> m >> k;
    key=0;
    for (i=0;i<k;i++) {
        cin >> a[i];
        if (a[i]==1) key=true;
    }
    v=a[0];
    kolE=(n*(n-1))/2;
    if (kolE-(n-k)>=m) {
        memset(c,1,sizeof(c));
        for (i=1;i<=n;i++)
            c[i][i]=0;
        for (i=0;i<k;i++) {
            j=a[i];
            if (j==v) continue;
            kolE--;
            c[v][j]=c[j][v]=0;
        }
        for (i=1;i<=n;i++)
            for (j=1;j<=n;j++) {
                if (kolE>m && c[i][j]) c[i][j]=c[j][i]=0,kolE--;
            }
        if (kolE<m) {
            cout << "-1";
        }
        else {
            for (i=1;i<=n;i++)
                for (j=i+1;j<=n;j++)
                    if (c[i][j])
                        cout << i << ' ' << j << '\n';
        }
    }
    else {
        cout << "-1";
    }
    return 0;
}


#include <iostream>
#include <cstdlib>
#include <cstring>
#include <vector>

using namespace std;

int n,m,k,i,j,v,kolE,key;
vector<pair<int,int> > edges;
bool c[333][333];
int a[333];
int p[333];

void init(int n) {
    for (i=1;i<=n;i++)
        p[i]=i;
}

int get_set(int x) {
    if (p[x]==x) return x;
    return p[x]=get_set(p[x]);
}

void union_sets(int x, int y) {
    x=get_set(x);
    y=get_set(y);
    if (rand()&1) swap(x,y);
    p[x]=y;
}

void tryAddEdgeTree(int x, int y) {
    if (c[x][y]==0) return;
    if (get_set(x)==get_set(y)) return;
    union_sets(x,y);
    edges.push_back(make_pair(x,y));
    c[x][y]=c[y][x]=0;
}

void tryAddEdge(int x, int y) {
    if (c[x][y]==0) return;
    edges.push_back(make_pair(x,y));
    c[x][y]=c[y][x]=0;
}

int main()
{
    cin >> n >> m >> k;
    key=0;
    for (i=0;i<k;i++) {
        cin >> a[i];
        if (a[i]==1) key=true;
    }
    v=a[0];
    kolE=(n*(n-1))/2;
    if (kolE-(k-1)>=m) {
        memset(c,1,sizeof(c));
        init(n);
        for (i=1;i<=n;i++)
            c[i][i]=0;
        for (i=0;i<k;i++)
            c[v][a[i]]=c[a[i]][v]=false;
        for (i=1;i<=n;i++)
            for (j=1;j<=n;j++)
                tryAddEdgeTree(i,j);
        if ((int)edges.size()>m || (int)edges.size()!=n-1) {
            cout << -1;
            return 0;
        }
        for (i=1;i<=n;i++)
            for (j=1;j<=n;j++) {
                if ((int)edges.size()<m) {
                    tryAddEdge(i,j);
                }
            }
        if ((int)edges.size()!=m) {
            cout << -1;
            return 0;
        }
        else {
            for (size_t i=0;i<edges.size();i++)
                cout << edges[i].first << ' ' << edges[i].second << '\n';
        }
    }
    else {
        cout << "-1";
    }
    return 0;
}


#include <iostream>
#include <cstdlib>
#include <cstring>
#include <vector>

using namespace std;

int n,m,k,i,j,v,kolE,key;
vector<pair<int,int> > edges;
bool c[333][333];
int a[333];
int p[333];

void init(int n) {
    for (i=1;i<=n;i++)
        p[i]=i;
}

int get_set(int x) {
    if (p[x]==x) return x;
    return p[x]=get_set(p[x]);
}

void union_sets(int x, int y) {
    x=get_set(x);
    y=get_set(y);
    if (rand()&1) swap(x,y);
    p[x]=y;
}

void tryAddEdgeTree(int x, int y) {
    if (c[x][y]==0) return;
    if (get_set(x)==get_set(y)) return;
    union_sets(x,y);
    edges.push_back(make_pair(x,y));
    c[x][y]=c[y][x]=0;
}

void tryAddEdge(int x, int y) {
    if (c[x][y]==0) return;
    edges.push_back(make_pair(x,y));
    c[x][y]=c[y][x]=0;
}

int main()
{
    cin >> n >> m >> k;
    key=0;
    for (i=0;i<k;i++) {
        cin >> a[i];
        if (a[i]==1) key=true;
    }
    v=a[0];
    kolE=(n*(n-1))/2;
    if (kolE-(k-1)>=m) {
        memset(c,1,sizeof(c));
        init(n);
        for (i=1;i<=n;i++)
            c[i][i]=0;
        for (i=0;i<k;i++)
            c[v][a[i]]=c[a[i]][v]=false;
        for (i=1;i<=n;i++)
            for (j=1;j<=n;j++)
                tryAddEdgeTree(i,j);
        if ((int)edges.size()>m) {
            cout << -1;
            return 0;
        }
        for (i=1;i<=n;i++)
            for (j=1;j<=n;j++) {
                if ((int)edges.size()<m) {
                    tryAddEdge(i,j);
                }
            }
        if ((int)edges.size()!=m) {
            cout << -1;
            return 0;
        }
        else {
            for (size_t i=0;i<edges.size();i++)
                cout << edges[i].first << ' ' << edges[i].second << '\n';
        }
    }
    else {
        cout << "-1";
    }
    return 0;
}


#include <iostream>
#include <fstream>
#include <stdio.h>
using namespace std;

const int dim = 305;
const int OO = (1<<30)-5;

int n, m, k, nrmuc, root;
int is_in_a[dim], a[dim];
int C[dim][dim];
pair <int, int> muc[dim];

int main()
{

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

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

    for (int i = 1; i <= n; i++)
    {
        if (is_in_a[i] == 1)
        {
            root = i;
            break;
        }
    }

    for (int i = 1; i <= n; i++)
    {
        for (int j = i+1; j <= n; j++)
        {
            if (i == root && is_in_a[j])
                continue;
            muc[++nrmuc].first = i;
            muc[nrmuc].second = j;
            if (m == nrmuc)
                break;
        }
        if (m == nrmuc)
            break;
    }

    for (int i = 1; i <= nrmuc; i++)
    {
        cout << muc[i].first << ' ' << muc[i].second << '\n';
    }

    return 0;
}


#include <iostream>
#include <fstream>
#include <stdio.h>
using namespace std;

const int dim = 305;
const int OO = (1<<30)-5;

int n, m, k, nrmuc, root;
int is_in_a[dim], a[dim];
int C[dim][dim];
pair <int, int> muc[dim];

int main()
{

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

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

    for (int i = 1; i <= n; i++)
    {
        if (is_in_a[i] == 1)
        {
            root = i;
            break;
        }
    }

    for (int i = 1; i <= n; i++)
    {
        for (int j = i+1; j <= n; j++)
        {
            if (i == root && is_in_a[j])
                continue;
            muc[++nrmuc].first = i;
            muc[nrmuc].second = j;
        }
    }

    for (int i = 1; i <= nrmuc; i++)
    {
        cout << muc[i].first << ' ' << muc[i].second << '\n';
    }

    return 0;
}


#include <iostream>
#include <fstream>
#include <stdio.h>
using namespace std;

const int dim = 305;
const int OO = (1<<30)-5;

int n, m, k, nrmuc, root, marked, notmarked;
int is_in_a[dim], a[dim];
int C[dim][dim], ma[dim][dim];
pair <int, int> muc[dim];

int main()
{

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

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

    for (int i = 1; i <= n; i++)
    {
        if (is_in_a[i] == 1)
        {
            marked = i;
            break;
        }
    }
    for (int i = 1; i <= n; i++)
    {
        if (is_in_a[i] == 0)
        {
            notmarked = i;
            break;
        }
    }

    for (int i = 1; i < marked-1; i++)
    {
        muc[++nrmuc].first = i;
        muc[nrmuc].second = i+1;
        ma[i][i+1] = ma[i+1][i] = 1;
    }

    if (marked-1 >= 1 && marked+1 <= n)
    {
        muc[++nrmuc].first = marked-1;
        muc[nrmuc].second = marked+1;
        ma[marked-1][marked+1] = 1;
    }

    for (int i = marked+1; i < n; i++)
    {
        muc[++nrmuc].first = i;
        muc[nrmuc].second = i+1;
        ma[i][i+1] = ma[i+1][i] = 1;
    }

    muc[++nrmuc].first = marked;
    muc[nrmuc].second = notmarked;
    ma[marked][notmarked] = ma[notmarked][marked] = 1;

    for (int i = 1; i <= n; i++)
    {
        for (int j = i+1; j <= n; j++)
        {
            if (i == marked && is_in_a[j])
                continue;
            if (ma[i][j])
                continue;

            muc[++nrmuc].first = i;
            muc[nrmuc].second = j;
            ma[i][j] = ma[j][i] = 1;
        }
    }

    for (int i = 1; i <= m; i++)
    {
        cout << muc[i].first << ' ' << muc[i].second << '\n';
    }

    return 0;
}


#include <iostream>
#include <fstream>
#include <stdio.h>
using namespace std;

const int dim = 305;
const int OO = (1<<30)-5;

int n, m, k, nrmuc, root, marked, notmarked;
int is_in_a[dim], a[dim];
int C[dim][dim], ma[dim][dim];
pair <int, int> muc[dim*dim];

int main()
{
     cin >> n >> m >> k;
    for (int i = 1; i <= k; i++)
    {
        cin >> a[i];
        is_in_a[a[i]] = 1;
    }

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

    for (int i = 1; i <= n; i++)
    {
        if (is_in_a[i] == 1)
        {
            marked = i;
            break;
        }
    }
    for (int i = 1; i <= n; i++)
    {
        if (is_in_a[i] == 0)
        {
            notmarked = i;
            break;
        }
    }

    for (int i = 1; i < marked-1; i++)
    {
        muc[++nrmuc].first = i;
        muc[nrmuc].second = i+1;
        ma[i][i+1] = ma[i+1][i] = 1;
    }

    if (marked-1 >= 1 && marked+1 <= n)
    {
        muc[++nrmuc].first = marked-1;
        muc[nrmuc].second = marked+1;
        ma[marked-1][marked+1] = 1;
    }

    for (int i = marked+1; i < n; i++)
    {
        muc[++nrmuc].first = i;
        muc[nrmuc].second = i+1;
        ma[i][i+1] = ma[i+1][i] = 1;
    }

    muc[++nrmuc].first = marked;
    muc[nrmuc].second = notmarked;
    ma[marked][notmarked] = ma[notmarked][marked] = 1;

    for (int i = 1; i <= n; i++)
    {
        for (int j = i+1; j <= n; j++)
        {
            if (i == marked && is_in_a[j])
                continue;
            if (ma[i][j])
                continue;

            muc[++nrmuc].first = i;
            muc[nrmuc].second = j;
            ma[i][j] = ma[j][i] = 1;
        }
    }

    for (int i = 1; i <= m; i++)
    {
        cout << muc[i].first << ' ' << muc[i].second << '\n';
    }

    return 0;
}


#include <iostream>
#include <fstream>
#include <stdio.h>
using namespace std;

const int dim = 305;
const int OO = (1<<30)-5;

int n, m, k, nrmuc, root;
int is_in_a[dim], a[dim];
int C[dim][dim];
pair <int, int> muc[dim];

int main()
{
    //freopen ("350E.in", "r", stdin);
    //freopen ("350E_matrix.out", "w", stdout);

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

    if (m != n-1)
    {
        cout << "-1\n";
        return 0;
    }

    for (int i = 1; i <= n; i++)
    {
        if (is_in_a[i] == 0)
        {
            root = i;
            break;
        }
    }

    for (int i = 1; i <= n; i++)
    {
        if (i != root)
        {
            muc[++nrmuc].first = root;
            muc[nrmuc].second = i;
        }
    }

    for (int i = 1; i <= nrmuc; i++)
    {
        cout << muc[i].first << ' ' << muc[i].second << '\n';
    }

    return 0;
}


/*
Convalescent livid we succumb
Stagnation now complete
This is the new plague called
Unconsciousness
We're selfcaged in defeat
Clotted minds coagulate we are trapped
Inside the tears we obey resignate to our
Self-inflected fears

Voices calm will be never heard
In this mode who will change
Bantised in our minds so absurd
Is this the world sublime
Into pools of paranoia we're fading with
Reality drained by lies we are al inhuman
Introspective vanishing

Sterile thoughts now upraised in subhuman
Majesty bodies numb still enchained
Where am i in hell of our dreams
Wrong wrong i'm in the now the vain reality

So it seems we're dying yet content
Worship our chrysalis stage since when are
Lies devine

Since when

This is now degrade indulge
This is us servile obliging

Swallowed by our hunger for mendacity
As this dance whirls deeper into hate

We're vanishing

In down deep cold where am i caught cage
Trapped not in dreams now time has killed
Our eyes fall fade gone dead away
*/

//#pragma comment(linker, "/STACK:16777216")
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <memory.h>

#define y0 sdkfaslhagaklsldk
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash

#define  INF 100000000
#define eps 1e-8
//#define M_PI 3.141592653589793
//#define mx 1000000000000ll
#define bs 1000000007

//#define free asdfasdfsdadsg
//#define szz 400
//#define pb push_back
#define MAXN 10000
#define free afdshjioey
//#define SIZE 60
#define bsize 256

using namespace std;

long n,m,k,t,bd[2000],frend;
vector<pair<long, long> > v;
long fr1;
set<pair<long, long> > sett;
long svert;
vector<long> q;

int main(){
//freopen("firesafe.in","r",stdin);
//freopen("firesafe.out","w",stdout);
//freopen("C:/input.txt","r",stdin);
//freopen("C:/output.txt","w",stdout);
ios_base::sync_with_stdio(0);

cin>>n>>m>>k;

if (k==n)cout<<-1<<endl;
else
{
for (int i=1;i<=k;i++)
{
    cin>>t;
 bd[t]=1;
}

for (int i=1;i<=n;i++)
if (bd[i]==0)q.push_back(i);
for (int i=1;i<=n;i++)
if (bd[i]==1){q.push_back(i);if (svert==0)svert=i;}

//cout<<svert<<endl;

for (int i=0;i<q.size();i++)
 for (int j=i+1;j<q.size();j++)
 {
     if ((q[i]!=svert&&q[j]!=svert)||(bd[q[i]]+bd[q[j]]<2))
     v.push_back(make_pair(q[i],q[j]));
 }
if (v.size()<m)
cout<<-1<<endl;
else
for (int i=0;i<m;i++)
{cout<<v[i].first<<" "<<v[i].second<<endl;
}
}
cin.get();cin.get();
return 0;}


/*
Convalescent livid we succumb
Stagnation now complete
This is the new plague called
Unconsciousness
We're selfcaged in defeat
Clotted minds coagulate we are trapped
Inside the tears we obey resignate to our
Self-inflected fears

Voices calm will be never heard
In this mode who will change
Bantised in our minds so absurd
Is this the world sublime
Into pools of paranoia we're fading with
Reality drained by lies we are al inhuman
Introspective vanishing

Sterile thoughts now upraised in subhuman
Majesty bodies numb still enchained
Where am i in hell of our dreams
Wrong wrong i'm in the now the vain reality

So it seems we're dying yet content
Worship our chrysalis stage since when are
Lies devine

Since when

This is now degrade indulge
This is us servile obliging

Swallowed by our hunger for mendacity
As this dance whirls deeper into hate

We're vanishing

In down deep cold where am i caught cage
Trapped not in dreams now time has killed
Our eyes fall fade gone dead away
*/

//#pragma comment(linker, "/STACK:16777216")
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <memory.h>

#define y0 sdkfaslhagaklsldk
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash

#define  INF 100000000
#define eps 1e-8
//#define M_PI 3.141592653589793
//#define mx 1000000000000ll
#define bs 1000000007

//#define free asdfasdfsdadsg
//#define szz 400
//#define pb push_back
#define MAXN 10000
#define free afdshjioey
//#define SIZE 60
#define bsize 256

using namespace std;

long n,m,k,t,bd[2000],frend;
vector<pair<long, long> > v;

int main(){
//freopen("firesafe.in","r",stdin);
//freopen("firesafe.out","w",stdout);
//freopen("C:/input.txt","r",stdin);
//freopen("C:/output.txt","w",stdout);
ios_base::sync_with_stdio(0);

cin>>n>>m>>k;

for (int i=1;i<=k;i++)
{cin>>t;
 bd[t]=1;
 frend=t;
}

for (int i=1;i<=n;i++)
for (int j=i+1;j<=n;j++)
{
    if (bd[i]==0&&bd[j]==0)v.push_back(make_pair(i,j));
}
// cf at ll

for (int i=1;i<=n;i++)
for (int j=i+1;j<=n;j++)
if (bd[i]+bd[j]==1)v.push_back(make_pair(i,j));

//mns im

for (int i=1;i<=n;i++)
 for (int j=i+1;j<=n;j++)
  if (bd[i]+bd[j]==2&&i!=frend&&j!=frend)
  {
   v.push_back(make_pair(i,j));
  }
// /\ unm -

if (v.size()<m)cout<<-1<<endl;
else for (int i=0;i<m;i++)
cout<<v[i].first<<" "<<v[i].second<<endl;

cin.get();cin.get();
return 0;}


/*
Convalescent livid we succumb
Stagnation now complete
This is the new plague called
Unconsciousness
We're selfcaged in defeat
Clotted minds coagulate we are trapped
Inside the tears we obey resignate to our
Self-inflected fears

Voices calm will be never heard
In this mode who will change
Bantised in our minds so absurd
Is this the world sublime
Into pools of paranoia we're fading with
Reality drained by lies we are al inhuman
Introspective vanishing

Sterile thoughts now upraised in subhuman
Majesty bodies numb still enchained
Where am i in hell of our dreams
Wrong wrong i'm in the now the vain reality

So it seems we're dying yet content
Worship our chrysalis stage since when are
Lies devine

Since when

This is now degrade indulge
This is us servile obliging

Swallowed by our hunger for mendacity
As this dance whirls deeper into hate

We're vanishing

In down deep cold where am i caught cage
Trapped not in dreams now time has killed
Our eyes fall fade gone dead away
*/

//#pragma comment(linker, "/STACK:16777216")
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <memory.h>

#define y0 sdkfaslhagaklsldk
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash

#define  INF 100000000
#define eps 1e-8
//#define M_PI 3.141592653589793
//#define mx 1000000000000ll
#define bs 1000000007

//#define free asdfasdfsdadsg
//#define szz 400
//#define pb push_back
#define MAXN 10000
#define free afdshjioey
//#define SIZE 60
#define bsize 256

using namespace std;

long n,m,k,t,bd[2000],frend;
vector<pair<long, long> > v;
long fr1;

int main(){
//freopen("firesafe.in","r",stdin);
//freopen("firesafe.out","w",stdout);
//freopen("C:/input.txt","r",stdin);
//freopen("C:/output.txt","w",stdout);
ios_base::sync_with_stdio(0);

cin>>n>>m>>k;

if (k==n)cout<<-1<<endl;
else
{
for (int i=1;i<=k;i++)
{cin>>t;
 bd[t]=1;
 if (i==1)fr1=t;
 frend=t;
}

for (int i=1;i<=n;i++)
if (bd[i]==0){v.push_back(make_pair(fr1,i));v.push_back(make_pair(frend,i));}

for (int i=1;i<=n;i++)
for (int j=i+1;j<=n;j++)
{
    if (bd[i]==0&&bd[j]==0)v.push_back(make_pair(i,j));
}
// cf at ll

// g ans

for (int i=1;i<=n;i++)
for (int j=i+1;j<=n;j++)
if (bd[i]+bd[j]==1&&i!=frend&&i!=fr1&&j!=frend&&j!=fr1)v.push_back(make_pair(i,j));

//mns im

for (int i=1;i<=n;i++)
 for (int j=i+1;j<=n;j++)
  if (bd[i]+bd[j]==2&&i!=frend&&j!=frend)
  {
   v.push_back(make_pair(i,j));
  }
// /\ unm -

if (v.size()<m)cout<<-1<<endl;
else for (int i=0;i<m;i++)
cout<<v[i].first<<" "<<v[i].second<<endl;

//cout<<v.size()<<endl;
}
cin.get();cin.get();
return 0;}


/*
Convalescent livid we succumb
Stagnation now complete
This is the new plague called
Unconsciousness
We're selfcaged in defeat
Clotted minds coagulate we are trapped
Inside the tears we obey resignate to our
Self-inflected fears

Voices calm will be never heard
In this mode who will change
Bantised in our minds so absurd
Is this the world sublime
Into pools of paranoia we're fading with
Reality drained by lies we are al inhuman
Introspective vanishing

Sterile thoughts now upraised in subhuman
Majesty bodies numb still enchained
Where am i in hell of our dreams
Wrong wrong i'm in the now the vain reality

So it seems we're dying yet content
Worship our chrysalis stage since when are
Lies devine

Since when

This is now degrade indulge
This is us servile obliging

Swallowed by our hunger for mendacity
As this dance whirls deeper into hate

We're vanishing

In down deep cold where am i caught cage
Trapped not in dreams now time has killed
Our eyes fall fade gone dead away
*/

//#pragma comment(linker, "/STACK:16777216")
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <memory.h>

#define y0 sdkfaslhagaklsldk
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash

#define  INF 100000000
#define eps 1e-8
//#define M_PI 3.141592653589793
//#define mx 1000000000000ll
#define bs 1000000007

//#define free asdfasdfsdadsg
//#define szz 400
//#define pb push_back
#define MAXN 10000
#define free afdshjioey
//#define SIZE 60
#define bsize 256

using namespace std;

long n,m,k,t,bd[2000],frend;
vector<pair<long, long> > v;
long fr1;
set<pair<long, long> > sett;

int main(){
//freopen("firesafe.in","r",stdin);
//freopen("firesafe.out","w",stdout);
//freopen("C:/input.txt","r",stdin);
//freopen("C:/output.txt","w",stdout);
ios_base::sync_with_stdio(0);

cin>>n>>m>>k;

if (k==n)cout<<-1<<endl;
else
{
for (int i=1;i<=k;i++)
{cin>>t;
 bd[t]=1;
 if (i==1)fr1=t;
 frend=t;
}

for (int i=1;i<=n;i++)if (bd[i]==0)
{
 for (int j=1;j<=n;j++)if (i!=j)v.push_back(make_pair(min(i,j),max(i,j)));
 break;
}

for (int i=1;i<=n;i++)
if (bd[i]==0){v.push_back(make_pair(fr1,i));v.push_back(make_pair(frend,i));}

for (int i=1;i<=n;i++)
for (int j=i+1;j<=n;j++)
{
    if (bd[i]==0&&bd[j]==0)v.push_back(make_pair(i,j));
}
// cf at ll

// g ans

for (int i=1;i<=n;i++)
for (int j=i+1;j<=n;j++)
if (bd[i]+bd[j]==1&&i!=frend&&i!=fr1&&j!=frend&&j!=fr1)v.push_back(make_pair(i,j));

//mns im

for (int i=1;i<=n;i++)
 for (int j=i+1;j<=n;j++)
  if (bd[i]+bd[j]==2&&i!=frend&&j!=frend)
  {
   v.push_back(make_pair(i,j));
  }
// /\ unm -

long calc=0;
for (int i=0;i<v.size();i++)
if (sett.find(v[i])==sett.end())
{
 ++calc;sett.insert(v[i]);
}
sett.clear();
if (calc<m)cout<<-1<<endl;

else for (int i=0;i<v.size();i++)
if (m==0)continue;
else if (sett.find(v[i])!=sett.end())continue;
else
{cout<<v[i].first<<" "<<v[i].second<<endl;
--m;sett.insert(v[i]);
}
//cout<<v.size()<<endl;
}
cin.get();cin.get();
return 0;}


/*
Convalescent livid we succumb
Stagnation now complete
This is the new plague called
Unconsciousness
We're selfcaged in defeat
Clotted minds coagulate we are trapped
Inside the tears we obey resignate to our
Self-inflected fears

Voices calm will be never heard
In this mode who will change
Bantised in our minds so absurd
Is this the world sublime
Into pools of paranoia we're fading with
Reality drained by lies we are al inhuman
Introspective vanishing

Sterile thoughts now upraised in subhuman
Majesty bodies numb still enchained
Where am i in hell of our dreams
Wrong wrong i'm in the now the vain reality

So it seems we're dying yet content
Worship our chrysalis stage since when are
Lies devine

Since when

This is now degrade indulge
This is us servile obliging

Swallowed by our hunger for mendacity
As this dance whirls deeper into hate

We're vanishing

In down deep cold where am i caught cage
Trapped not in dreams now time has killed
Our eyes fall fade gone dead away
*/

//#pragma comment(linker, "/STACK:16777216")
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <memory.h>

#define y0 sdkfaslhagaklsldk
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash

#define  INF 100000000
#define eps 1e-8
//#define M_PI 3.141592653589793
//#define mx 1000000000000ll
#define bs 1000000007

//#define free asdfasdfsdadsg
//#define szz 400
//#define pb push_back
#define MAXN 10000
#define free afdshjioey
//#define SIZE 60
#define bsize 256

using namespace std;

long n,m,k,t,bd[2000],frend;
vector<pair<long, long> > v;
long fr1;

int main(){
//freopen("firesafe.in","r",stdin);
//freopen("firesafe.out","w",stdout);
//freopen("C:/input.txt","r",stdin);
//freopen("C:/output.txt","w",stdout);
ios_base::sync_with_stdio(0);

cin>>n>>m>>k;

if (k==n)cout<<-1<<endl;
else
{
for (int i=1;i<=k;i++)
{cin>>t;
 bd[t]=1;
 if (i==1)fr1=t;
 frend=t;
}

for (int i=1;i<=n;i++)
for (int j=i+1;j<=n;j++)
{
    if (bd[i]==0&&bd[j]==0)v.push_back(make_pair(i,j));
}
// cf at ll

for (int i=1;i<=n;i++)
if (bd[i]==0){v.push_back(make_pair(fr1,i));v.push_back(make_pair(frend,i));}

// g ans

for (int i=1;i<=n;i++)
for (int j=i+1;j<=n;j++)
if (bd[i]+bd[j]==1&&i!=frend&&i!=fr1&&j!=frend&&j!=fr1)v.push_back(make_pair(i,j));

//mns im

for (int i=1;i<=n;i++)
 for (int j=i+1;j<=n;j++)
  if (bd[i]+bd[j]==2&&i!=frend&&j!=frend)
  {
   v.push_back(make_pair(i,j));
  }
// /\ unm -

if (v.size()<m)cout<<-1<<endl;
else for (int i=0;i<m;i++)
cout<<v[i].first<<" "<<v[i].second<<endl;

//cout<<v.size()<<endl;
}
cin.get();cin.get();
return 0;}


#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>

using namespace std;

int a;

int main() {
    int n, m, k;
    cin >> n >> m >> k;
    for (int i = 0; i < k; i++)
        cin >> a;
    int u = 1;
    if (u == a)
        u = 2;
    if (m > (n - 1) * (n - 2) / 2 + 1) {
        cout << -1 << endl;
        return 0;
    }
    cout << u << " " << a << endl;
    int now = 1;
    m--;
    for (int i = 1; i <= n && m; i++) {
        if (i == u || i == a)
            continue;
        cout << i << " " << a << endl;
        m--;
    }
    while (m) {
        while (now == u || now == a)
            now++;
        for (int i = 1; i < now; i++) {
            if (i == u || i == a)
                continue;
            cout << now << " " << i << endl;
            m--;
            if (!m)
                break;
        }
        now++;
    }
    return 0;
}


#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>

using namespace std;

int a[500];
bool o[500];
bool f[500][500];

int main() {
    int n, m, k;
    cin >> n >> m >> k;
    for (int i = 0; i < k; i++) {
        cin >> a[i];
        o[a[i]] = true;
    }
    if (k == n || n * (n - 1) / 2 - k + 1 < m) {
        cout << -1 << endl;
        return 0;
    }
    int b;
    for (int i = 1; i <= n; i++)
        if (!o[i])
            b = i;

    f[a[0]][b] = f[b][a[0]] = true;
    m--;
    f[b][a[1]] = f[a[1]][b] = true;
    m--;
    for (int i = 1; i <= n && m; i++) {
        for (int j = 1; j <= n && m; j++) {
            if (f[i][j] || i == j)
                continue;
            f[i][j] = f[j][i] = true;
        }
    }
    for (int i = 1; i <= n; i++)
        for (int j = i + 1; j <= n; j++)
            if (f[i][j])
                cout << i << " " << j << endl;

    return 0;
}


#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>

using namespace std;

int a[500];
bool o[500];
bool f[500][500];

int main() {
    int n, m, k;
    cin >> n >> m >> k;
    for (int i = 0; i < k; i++) {
        cin >> a[i];
        o[a[i]] = true;
    }
    if (k == n || n * (n - 1) / 2 - k + 1 < m) {
        cout << -1 << endl;
        return 0;
    }
    int b;
    for (int i = 1; i <= n; i++)
        if (!o[i])
            b = i;

    f[a[0]][b] = f[b][a[0]] = true;
    m--;
    f[b][a[1]] = f[a[1]][b] = true;
    m--;
    for (int i = 1; i <= n && m; i++) {
        for (int j = i + 1; j <= n && m; j++) {
            if (f[i][j] || i == j || (i == a[0] && o[j]) || (o[i] && j == a[0]))
                continue;
            f[i][j] = f[j][i] = true;
        }
    }
    for (int i = 1; i <= n; i++)
        for (int j = i + 1; j <= n; j++)
            if (f[i][j])
                cout << i << " " << j << endl;

    return 0;
}


#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>

using namespace std;

bool o[500];
int a;

int main() {
    int n, m, k;
    cin >> n >> m >> k;
    for (int i = 0; i < k; i++) {
        int x;
        cin >> x;
        o[x] = true;
    }
    for (int i = 1; i <= n; i++) {
        if (o[x] == false)
            a = i;
    }
    int u = 1;
    if (u == a)
        u = 2;
    if (a == 0 || m > (n - 1) * (n - 2) / 2 + 1) {
        cout << -1 << endl;
        return 0;
    }
    cout << u << " " << a << endl;
    int now = 1;
    m--;
    for (int i = 1; i <= n && m; i++) {
        if (i == u || i == a)
            continue;
        cout << i << " " << a << endl;
        m--;
    }
    while (m) {
        while (now == u || now == a)
            now++;
        for (int i = 1; i < now; i++) {
            if (i == u || i == a)
                continue;
            cout << now << " " << i << endl;
            m--;
            if (!m)
                break;
        }
        now++;
    }
    return 0;
}


#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>

using namespace std;

int a[500];
bool o[500];
bool f[500][500];

int main() {
    int n, m, k;
    cin >> n >> m >> k;
    for (int i = 0; i < k; i++) {
        cin >> a[i];
        o[a[i]] = true;
    }
    if (k == n || n * (n - 1) / 2 - k + 1 < m) {
        cout << -1 << endl;
        return 0;
    }
    int b;
    for (int i = 1; i <= n; i++)
        if (!o[i])
            b = i;

    for (int i = 1; i <= n; i++) {
        if (i == b)
            continue;
        f[i][b] = f[b][i] = true;
        m--;
    }
    if (m < 0) {
        cout << -1 << endl;
        return 0;
    }
    for (int i = 1; i <= n && m; i++) {
        for (int j = i + 1; j <= n && m; j++) {
            if (f[i][j] || i == j || (i == a[0] && o[j]) || (o[i] && j == a[0]))
                continue;
            f[i][j] = f[j][i] = true;
            m--;
        }
    }
    for (int i = 1; i <= n; i++)
        for (int j = i + 1; j <= n; j++)
            if (f[i][j])
                cout << i << " " << j << endl;

    return 0;
}


#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>

using namespace std;

bool o[500];
int a;

int main() {
    int n, m, k;
    cin >> n >> m >> k;
    for (int i = 0; i < k; i++) {
        int x;
        cin >> x;
        o[x] = true;
    }
    for (int i = 1; i <= n; i++) {
        if (o[i] == false)
            a = i;
    }
    int u = 1;
    if (u == a)
        u = 2;
    if (a == 0 || m > (n - 1) * (n - 2) / 2 + 1) {
        cout << -1 << endl;
        return 0;
    }
    cout << u << " " << a << endl;
    int now = 1;
    m--;
    for (int i = 1; i <= n && m; i++) {
        if (i == u || i == a)
            continue;
        cout << i << " " << a << endl;
        m--;
    }
    while (m) {
        while (now == u || now == a)
            now++;
        for (int i = 1; i < now; i++) {
            if (i == u || i == a)
                continue;
            cout << now << " " << i << endl;
            m--;
            if (!m)
                break;
        }
        now++;
    }
    return 0;
}


#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>

using namespace std;

int a[500];
bool o[500];
bool f[500][500];

int main() {
    int n, m, k;
    cin >> n >> m >> k;
    for (int i = 0; i < k; i++) {
        cin >> a[i];
        o[a[i]] = true;
    }
    if (k == n || n * (n - 1) / 2 - k + 1 < m) {
        cout << -1 << endl;
        return 0;
    }
    int b;
    for (int i = 1; i <= n; i++)
        if (!o[i])
            b = i;

    f[a[0]][b] = f[b][a[0]] = true;
    m--;
    f[b][a[1]] = f[a[1]][b] = true;
    m--;
    for (int i = 1; i <= n && m; i++) {
        for (int j = i + 1; j <= n && m; j++) {
            if (f[i][j] || i == j || (i == a[0] && o[j]) || (o[i] && j == a[0]))
                continue;
            f[i][j] = f[j][i] = true;
            m--;
        }
    }
    for (int i = 1; i <= n; i++)
        for (int j = i + 1; j <= n; j++)
            if (f[i][j])
                cout << i << " " << j << endl;

    return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cstring>
#include <string>
#include <cmath>
#include <utility>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <sstream>
using namespace std;

void construct(vector <int> v, int n, int m)
{
    for (int i = 0; i < n; i++)
        for (int j = i + 1; j < n; j++)
            if (!m) break;
            else printf("%d %d\n", v[i], v[j]);
}

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

    if (k == n) puts("-1");
    else
    {
        int mid;
        for (int i = 1; i <= n; i++)
            if (!marked[i])
            {
                mid = i; break;
            }

        int n0 = (n - 1) / 2, n1 = (n - 1) - n0;
        if (n0 * (n0 - 1) / 2 + n1 * (n1 - 1) / 2 + n - 1 < m) puts("-1");
        else
        {
            int mm = min(n - 1, m);
            m -= mm;
            int m0 = min(n0 * (n0 - 1) / 2, m), m1 = m - m0;

            vector <int> v0, v1;
            for (int i = 1; i <= n; i++)
                if (i != mid)
                {
                    if (v0.size() != n0) v0.push_back(i);
                    else v1.push_back(i);
                    if (mm) cout << i << ' ' << mid << endl, mm--;
                }

            construct(v0, n0, m0);
            construct(v1, n1, m1);
        }
    }
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cstring>
#include <string>
#include <cmath>
#include <utility>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <sstream>
using namespace std;

void construct(vector <int> v, int n, int m)
{
	for (int i = 0; i < n; i++)
		for (int j = i + 1; j < n; j++)
			if (!m) break;
			else printf("%d %d\n", v[i], v[j]);
}

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

	if (k == n) puts("-1");
	else
	{
		int mid;
		for (int i = 1; i <= n; i++)
			if (!marked[i])
			{
				mid = i; break;
			}

		if ((n - 2) * (n - 3) / 2 + n - 1 + n - k - 1 < m) puts("-1");
		else
		{
			m -= (n - 1);
			int mm = min(n - k - 1, m);
			m -= mm;
			vector <int> v;
			int other = 0;

			for (int i = 1; i <= n; i++)
				if (marked[i]) other = i;

			cout << other << ' ' << mid << endl;

			for (int i = 1; i <= n; i++)
				if (i != mid && i != other)
				{
					v.push_back(i);
					cout << i << ' ' << mid << endl;
				}

			for (int i = 1; i <= n; i++)
				if (!marked[i] && i != mid && mm)
				{
					cout << other << ' ' << i << endl;
					mm--;
				}

			construct(v, n - 2, m);
		}
	}
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cstring>
#include <string>
#include <cmath>
#include <utility>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <sstream>
using namespace std;

void construct(vector <int> v, int n, int m)
{
    for (int i = 0; i < n; i++)
        for (int j = i + 1; j < n; j++)
            if (!m) break;
            else printf("%d %d\n", v[i], v[j]), m--;
}

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

    if (k == n)
    {
        puts("-1");
        return 0;
    }

    int mid;
    for (int i = 1; i <= n; i++)
        if (!marked[i])
        {
            mid = i; break;
        }

    if ((n - 2) * (n - 3) / 2 + n - 1 + n - k - 1 < m)
    {
        puts("-1");
        return 0;
    }

    m -= (n - 1);
    int mm = min(n - k - 1, m);
    m -= mm;
    vector <int> v;
    int other = 0;

    for (int i = 1; i <= n; i++)
        if (marked[i]) other = i;

    cout << other << ' ' << mid << endl;

    for (int i = 1; i <= n; i++)
        if (i != mid && i != other)
        {
            v.push_back(i);
            cout << i << ' ' << mid << endl;
        }

    for (int i = 1; i <= n; i++)
        if (!marked[i] && i != mid && mm)
        {
            cout << other << ' ' << i << endl;
            mm--;
        }

    construct(v, n - 2, m);
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cstring>
#include <string>
#include <cmath>
#include <utility>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <sstream>
using namespace std;

void construct(vector <int> v, int n, int m)
{
	for (int i = 0; i < n; i++)
		for (int j = i + 1; j < n; j++)
			if (!m) break;
			else printf("%d %d\n", v[i], v[j]);
}

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

	if (k == n) puts("-1");
	else
	{
		int mid;
		for (int i = 1; i <= n; i++)
			if (!marked[i])
			{
				mid = i; break;
			}

		int n0 = (n - 1) / 2, n1 = (n - 1) - n0;
		if (n0 * (n0 - 1) / 2 + n1 * (n1 - 1) / 2 + 2 < m) puts("-1");
		else
		{
			m -= 2;
			int m0 = min(n0 * (n0 - 1) / 2, m), m1 = m - m0;

			vector <int> v0, v1;
			for (int i = 1; i <= n; i++)
				if (i != mid)
				{
					if (v0.size() != n0) v0.push_back(i);
					else v1.push_back(i);
				}

			cout << v0[0] << ' ' << mid << endl;
			cout << v1[0] << ' ' << mid << endl;
			construct(v0, n0, m0);
			construct(v1, n1, m1);
		}
	}
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cstring>
#include <string>
#include <cmath>
#include <utility>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <sstream>
using namespace std;

void construct(vector <int> v, int n, int m)
{
    for (int i = 0; i < n; i++)
        for (int j = i + 1; j < n; j++)
            if (!m) break;
            else printf("%d %d\n", v[i], v[j]), m--;
}

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

    if (k == n)
    {
        puts("-1");
        return 0;
    }

    int mid;
    for (int i = 1; i <= n; i++)
        if (!marked[i])
        {
            mid = i; break;
        }

    if ((n - 2) * (n - 3) / 2 + n - 1 + n - 2 < m)
    {
        puts("-1");
        return 0;
    }

    m -= (n - 1);
    int mm = min(n - 2, m);
    m -= mm;
    vector <int> v;
    int other = 0;

    for (int i = 1; i <= n; i++)
        if (marked[i]) other = i;

    cout << other << ' ' << mid << endl;

    for (int i = 1; i <= n; i++)
        if (i != mid && i != other)
        {
            v.push_back(i);
            cout << i << ' ' << mid << endl;
        }

    for (int i = 1; i <= n; i++)
        if (!marked[i] && i != mid && mm)
        {
            cout << other << ' ' << i << endl;
            mm--;
        }

    construct(v, n - 2, m);
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cstring>
#include <string>
#include <cmath>
#include <utility>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <sstream>
using namespace std;

void construct(vector <int> v, int n, int m)
{
    for (int i = 0; i < n; i++)
        for (int j = i + 1; j < n; j++)
            if (!m) break;
            else printf("%d %d\n", v[i], v[j]);
}

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

    if (k == n) puts("-1");
    else
    {
        int mid;
        for (int i = 1; i <= n; i++)
            if (!marked[i])
            {
                mid = i; break;
            }

        if ((n - 2) * (n - 3) / 2 + n - 1 < m) puts("-1");
        else
        {
            int mm = min(m, n - 1);
            m -= mm;
            vector <int> v;

            for (int i = 1, started = 0; i <= n; i++)
                if (i != mid)
                {
                    if (!started) started = 1;
                    else v.push_back(i);
                    if (mm) cout << i << ' ' << mid << endl, mm--;
                }

            construct(v, n - 2, m);
        }
    }
}


#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <utility>
#include <cmath>
#include <ctype.h>
#include <deque>
#include <string>
#include <string.h>
#define INF 1000000000
#define EPS 1e-8

using namespace std;

typedef long long ll;

vector<pair<int, int> > sol;
int vis[333], a[333];

int main()
{
    int i, j, n, m, k, u, v, b, c;
    cin >> n >> m >> k;
    for(i=0; i<k; i++) cin >> a[i];
    if(k==n || 2*m==n*(n-1)) cout << -1;
    else
    {
        u=a[0], v=a[1];
        for(i=0; i<k; i++) vis[a[i]]=1;
        for(i=1; i<=n; i++) if(!vis[i])
        {
            b=i;
            break;
        }
        sol.push_back(make_pair(u, b));
        sol.push_back(make_pair(v, b));
        m-=2;
        if(m)
        {
            for(i=1; i<=n; i++) if(i!=u && i!=v && i!=b)
            {
                sol.push_back(make_pair(b, i));
                m--;
                if(!m) break;
            }
            if(m)
            for(i=1; i<=n; i++)
            {
                if(i!=u && i!=v && i!=b)
                for(j=i+1; j<=n; j++)
                {
                    if(j!=u && j!=v && j!=b)
                    {
                        sol.push_back(make_pair(i, j));
                        m--;
                    }
                    if(!m) break;
                }
                if(!m) break;
            }
            if(m)
            for(i=1; i<=n; i++) if(i!=u && i!=v && i!=b)
            {
                sol.push_back(make_pair(i, a[0]));
                m--;
                if(!m) break;
            }
            if(m)
            for(i=1; i<=n; i++) if(i!=b && !vis[i])
            {
                sol.push_back(make_pair(i, a[1]));
                m--;
                if(!m) break;
            }
        }
        if(m) cout << -1;
        else for(i=0; i<sol.size(); i++) cout << sol[i].first << " " << sol[i].second << endl;
    }
    return 0;
}


#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <utility>
#include <cmath>
#include <ctype.h>
#include <deque>
#include <string>
#include <string.h>
#define INF 1000000000
#define EPS 1e-8

using namespace std;

typedef long long ll;

vector<pair<int, int> > sol;

int main()
{
    int i, j, n, m, k, u, v, vis[333], a[333], b, c;
    cin >> n >> m >> k;
    for(i=0; i<k; i++) cin >> a[i];
    if(k==n || 2*m==n*(n-1)) cout << -1;
    else
    {
        u=a[0], v=a[1];
        for(i=0; i<k; i++) vis[a[i]]=1;
        for(i=1; i<=n; i++) if(!vis[i])
        {
            b=i;
            break;
        }
        sol.push_back(make_pair(u, b));
        sol.push_back(make_pair(v, b));
        m-=2;
        if(m)
        {
            if(k>2) c=a[2];
            else
            {
                for(i=1; i<=n; i++) if(i!=u && i!=v && i!=b)
                {
                    c=i;
                    break;
                }
            }
            sol.push_back(make_pair(b, c));
            m--;
            if(m)
            {
                for(i=1; i<=n; i++) if(i!=u && i!=v && i!=b && i!=c)
                {
                    sol.push_back(make_pair(c, i));
                    m--;
                    if(!m) break;
                }
                if(m)
                for(i=1; i<=n; i++)
                {
                    for(j=i+1; j<=n; j++)
                    {
                        if(i!=u && i!=v && i!=b && i!=c && j!=u && j!=v && j!=b)
                        {
                            sol.push_back(make_pair(i, j));
                            m--;
                        }
                        if(!m) break;
                    }
                    if(!m) break;
                }
                if(m)
                for(i=1; i<=n; i++) if(i!=u && i!=v && i!=b)
                {
                    sol.push_back(make_pair(i, a[1]));
                    m--;
                    if(!m) break;
                }
            }
        }
        if(m) cout << -1;
        else for(i=0; i<sol.size(); i++) cout << sol[i].first << " " << sol[i].second << endl;
    }
    return 0;
}


#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <utility>
#include <cmath>
#include <ctype.h>
#include <deque>
#include <string>
#include <string.h>
#define INF 1000000000
#define EPS 1e-8

using namespace std;

typedef long long ll;

vector<pair<int, int> > sol;
int vis[333], a[333];

int main()
{
    int i, j, n, m, k, u, v, b, c;
    cin >> n >> m >> k;
    for(i=0; i<k; i++) cin >> a[i];
    if(k==n || 2*m==n*(n-1)) cout << -1;
    else
    {
        u=a[0], v=a[1];
        for(i=0; i<k; i++) vis[a[i]]=1;
        for(i=1; i<=n; i++) if(!vis[i])
        {
            b=i;
            break;
        }
        sol.push_back(make_pair(u, b));
        sol.push_back(make_pair(v, b));
        m-=2;
        if(m)
        {
            for(i=1; i<=n; i++) if(i!=u && i!=v && i!=b)
            {
                sol.push_back(make_pair(b, i));
                m--;
                if(!m) break;
            }
            for(i=1; i<=n; i++)
            {
                if(i!=u && i!=v && i!=b)
                for(j=i+1; j<=n; j++)
                {
                    if(j!=u && j!=v && j!=b)
                    {
                        sol.push_back(make_pair(i, j));
                        m--;
                    }
                    if(!m) break;
                }
                if(!m) break;
            }
            for(i=1; i<=n; i++) if(i!=u && i!=v && i!=b)
            {
                sol.push_back(make_pair(i, a[0]));
                m--;
                if(!m) break;
            }
        }
        if(m) cout << -1;
        else for(i=0; i<sol.size(); i++) cout << sol[i].first << " " << sol[i].second << endl;
    }
    system("pause");
    return 0;
}


#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <utility>
#include <cmath>
#include <ctype.h>
#include <deque>
#include <string>
#include <string.h>
#define INF 1000000000
#define EPS 1e-8

using namespace std;

typedef long long ll;

vector<pair<int, int> > sol;
int vis[333], a[333];

int main()
{
    int i, j, n, m, k, u, v, b, c;
    cin >> n >> m >> k;
    for(i=0; i<k; i++) cin >> a[i];
    if(k==n || 2*m==n*(n-1)) cout << -1;
    else
    {
        u=a[0], v=a[1];
        for(i=0; i<k; i++) vis[a[i]]=1;
        for(i=1; i<=n; i++) if(!vis[i])
        {
            b=i;
            break;
        }
        sol.push_back(make_pair(u, b));
        sol.push_back(make_pair(v, b));
        m-=2;
        if(m)
        {
            for(i=1; i<=n; i++) if(i!=u && i!=v && i!=b)
            {
                sol.push_back(make_pair(b, i));
                m--;
                if(!m) break;
            }
            for(i=1; i<=n; i++)
            {
                if(i!=u && i!=v && i!=b)
                for(j=i+1; j<=n; j++)
                {
                    if(j!=u && j!=v && j!=b)
                    {
                        sol.push_back(make_pair(i, j));
                        m--;
                    }
                    if(!m) break;
                }
                if(!m) break;
            }
            for(i=1; i<=n; i++) if(i!=u && i!=v && i!=b)
            {
                sol.push_back(make_pair(i, a[0]));
                m--;
                if(!m) break;
            }
        }
        if(m) cout << -1;
        else for(i=0; i<sol.size(); i++) cout << sol[i].first << " " << sol[i].second << endl;
    }
    return 0;
}


#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <utility>
#include <cmath>
#include <ctype.h>
#include <deque>
#include <string>
#include <string.h>
#define INF 1000000000
#define EPS 1e-8

using namespace std;

typedef long long ll;

vector<pair<int, int> > sol;
int vis[333], a[333];

int main()
{
    int i, j, n, m, k, u, v, b, c;
    cin >> n >> m >> k;
    for(i=0; i<k; i++) cin >> a[i];
    if(k==n || 2*m==n*(n-1)) cout << -1;
    else
    {
        u=a[0], v=a[1];
        for(i=0; i<k; i++) vis[a[i]]=1;
        for(i=1; i<=n; i++) if(!vis[i])
        {
            b=i;
            break;
        }
        sol.push_back(make_pair(u, b));
        sol.push_back(make_pair(v, b));
        m-=2;
        if(m)
        {
            for(i=1; i<=n; i++) if(i!=u && i!=v && i!=b)
            {
                sol.push_back(make_pair(b, i));
                m--;
                if(!m) break;
            }
            if(m)
            for(i=1; i<=n; i++)
            {
                if(i!=u && i!=v && i!=b)
                for(j=i+1; j<=n; j++)
                {
                    if(j!=u && j!=v && j!=b)
                    {
                        sol.push_back(make_pair(i, j));
                        m--;
                    }
                    if(!m) break;
                }
                if(!m) break;
            }
            if(m)
            for(i=1; i<=n; i++) if(i!=u && i!=v && i!=b)
            {
                sol.push_back(make_pair(i, a[0]));
                m--;
                if(!m) break;
            }
        }
        if(m) cout << -1;
        else for(i=0; i<sol.size(); i++) cout << sol[i].first << " " << sol[i].second << endl;
    }
    return 0;
}


#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <cstring>
#include <stdio.h>
#include <sstream>
#include <time.h>
using namespace std;
typedef long long ll;
typedef double db;
#define tr 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define se second
ll max1,i,j,x,n,y,m,k,k1,k2,ost,ur,marked[100500],a[100500],used[100500],pos;
vector <pair <ll,ll> > f,g;
int main()
{
cin >> n >> m >> k;
for (i = 0; i < k; i++)
{
    cin >> k1;
    a[i] = k1;
    marked[k1]=1;
}
if (m > (n*(n-1))/2 - ( (k*(k-1))/2 - ( (k-1)*(k-2) )/2) || n == k)
   {
    cout << -1 << endl;
    return 0;
   }
ll free_v;
for (i = 1; i <= n; i++)
if (!marked[i])
   {
   for (j = 1; j <= n; j++)
       if (i != j)
          f.pb(mp(i,j));
   free_v = i;
   }
for (i = 1; i < k; i++)
    for (j = 1; j < k; j++)
        if (i != j)
           f.pb(mp(a[i],a[j]));
for (i = 0; i < m; i++)
    cout << f[i].fi << " " << f[i].se << endl;
return 0;
}


#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <cstring>
#include <stdio.h>
#include <sstream>
#include <time.h>
using namespace std;
typedef long long ll;
typedef double db;
#define tr 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define se second
ll max1,i,j,x,n,y,m,k,k1,k2,ost,ur,marked[100500],b[400][400],a[100500],used[100500],pos;
vector <pair <ll,ll> > f,g;
int main()
{
cin >> n >> m >> k;
for (i = 0; i < k; i++)
{
    cin >> k1;
    a[i] = k1;
    marked[k1]=1;
}
for (i = 1; i <= n; i++)
if (!marked[i])
   {
   for (j = 1 ; j <= n; j++)
       if (i != j && !b[i][j])
          {
              f.pb(mp(i,j));
              b[i][j]=1;
              b[j][i]=1;
          }
   }
for (i = 1; i < k; i++)
    for (j = 1; j < k; j++)
    if (i != j && !b[a[i]][a[j]])
          {
              f.pb(mp(a[i],a[j]));
              b[a[i]][a[j]]=1;
              b[a[j]][a[i]]=1;
          }
        if (i != j)

if (m > f.size())
   cout << -1 << endl;
else
for (i = 0; i < m; i++)
    cout << f[i].fi << " " << f[i].se << endl;
return 0;
}


#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <cstring>
#include <stdio.h>
#include <sstream>
#include <time.h>
using namespace std;
typedef long long ll;
typedef double db;
#define tr 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define se second
ll max1,i,j,x,n,y,m,k,k1,k2,ost,ur,marked[100500],a[100500],used[100500],pos;
vector <pair <ll,ll> > f,g;
int main()
{
cin >> n >> m >> k;
for (i = 0; i < k; i++)
{
    cin >> k1;
    a[i] = k1;
    marked[k1]=1;
}
if (m > (n*(n-1))/2 - ( (k*(k-1))/2 - ( (k-1)*(k-2) )/2) || n == k)
   {
    cout << -1 << endl;
    return 0;
   }
ll free_v;
for (i = 1; i <= n; i++)
if (!marked[i])
   {
   for (j = 1; j <= n; j++)
       if (i != j)
          f.pb(mp(i,j));
   free_v = i;
   }
for (i = 0; i < k - 1; i++)
    for (j = 0; j < k - 1; j++)
        if (i != j)
           f.pb(mp(a[i],a[j]));
for (i = 0; i < m; i++)
    cout << f[i].fi << " " << f[i].se << endl;
return 0;
}


#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <cstring>
#include <stdio.h>
#include <sstream>
#include <time.h>
using namespace std;
typedef long long ll;
typedef double db;
#define tr 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define se second
ll max1,i,j,x,n,y,m,k,k1,k2,ost,ur,marked[100500],a[100500],used[100500],pos;
vector <pair <ll,ll> > f,g;
int main()
{
cin >> n >> m >> k;
for (i = 0; i < k; i++)
{
    cin >> k1;
    a[i] = k1;
    marked[k1]=1;
}
for (i = 1; i <= n; i++)
if (!marked[i])
   {
   for (j = i + 1 ; j <= n; j++)
       if (i != j)
          f.pb(mp(i,j));
   }
for (i = 1; i < k; i++)
    for (j = i + 1; j < k; j++)
        if (i != j)
           f.pb(mp(a[i],a[j]));
if (m > f.size())
   cout << -1 << endl;
else
for (i = 0; i < m; i++)
    cout << f[i].fi << " " << f[i].se << endl;
return 0;
}


#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <cstring>
#include <stdio.h>
#include <sstream>
#include <time.h>
using namespace std;
typedef long long ll;
typedef double db;
#define tr 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define se second
ll max1,i,j,x,n,y,m,k,k1,k2,ost,ur,marked[100500],a[100500],used[100500],pos;
vector <pair <ll,ll> > f,g;
int main()
{
cin >> n >> m >> k;
for (i = 0; i < k; i++)
{
    cin >> k1;
    a[i] = k1;
    marked[k1]=1;
}
if (m > (n*(n-1))/2 - ( (k*(k-1))/2 - ( (k-1)*(k-2) )/2) || n == k)
   {
    cout << -1 << endl;
    return 0;
   }
ll free_v;
for (i = 1; i <= n; i++)
if (!marked[i])
   {
   for (j = 1; j <= n; j++)
       if (i != j)
          f.pb(mp(i,j));
   free_v = i;
   }
for (i = 1; i < k; i++)
    for (j = i + 1; j < k; j++)
            f.pb(mp(a[i],a[j]));
for (i = 0; i < m; i++)
    cout << f[i].fi << " " << f[i].se << endl;
return 0;
}


#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <cstring>
#include <stdio.h>
#include <sstream>
#include <time.h>
using namespace std;
typedef long long ll;
typedef double db;
#define tr 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define se second
ll max1,i,j,x,n,y,m,k,k1,k2,ost,ur,marked[100500],b[400][400],a[100500],used[100500],pos;
vector <pair <ll,ll> > f,g;
int main()
{
cin >> n >> m >> k;
for (i = 0; i < k; i++)
{
    cin >> k1;
    a[i] = k1;
    marked[k1]=1;
}
for (i = 1; i <= n; i++)
if (!marked[i])
   {
   for (j = 1 ; j <= n; j++)
       if (i != j && !b[i][j])
          {
              f.pb(mp(i,j));
              b[i][j]=1;
              b[j][i]=1;
          }
   }
for (i = 1; i < k; i++)
    for (j = 1; j < k; j++)
    if (i != j && !b[a[i]][a[j]])
          {
              f.pb(mp(a[i],a[j]));
              b[a[i]][a[j]]=1;
              b[a[j]][a[i]]=1;
          }

if (m > f.size())
   cout << -1 << endl;
else
for (i = 0; i < m; i++)
    cout << f[i].fi << " " << f[i].se << endl;
return 0;
}


#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <cstring>
#include <stdio.h>
#include <sstream>
#include <time.h>
using namespace std;
typedef long long ll;
typedef double db;
#define tr 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define se second
ll max1,i,j,x,n,y,m,k,k1,k2,ost,ur,marked[100500],a[100500],used[100500],pos;
vector <pair <ll,ll> > f,g;
int main()
{
cin >> n >> m >> k;
for (i = 0; i < k; i++)
{
    cin >> k1;
    a[i] = k1;
    marked[k1]=1;
}
for (i = 1; i <= n; i++)
if (!marked[i])
   {
   for (j = 1; j <= n; j++)
       if (i != j)
          f.pb(mp(i,j));
   }
for (i = 1; i < k; i++)
    for (j = 1; j < k; j++)
        if (i != j)
           f.pb(mp(a[i],a[j]));
if (m > f.size())
   cout << -1 << endl;
else
for (i = 0; i < m; i++)
    cout << f[i].fi << " " << f[i].se << endl;
return 0;
}


#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <cstring>
#include <stdio.h>
#include <sstream>
#include <time.h>
using namespace std;
typedef long long ll;
typedef double db;
#define tr 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define se second
ll max1,i,j,x,n,y,m,k,k1,k2,ost,ur,marked[100500],b[400][400],a[100500],used[100500],pos;
vector <pair <ll,ll> > f,g;
int main()
{
cin >> n >> m >> k;
for (i = 0; i < k; i++)
{
    cin >> k1;
    a[i] = k1;
    marked[k1]=1;
}
for (i = 1; i <= n; i++)
if (!marked[i])
   {
   for (j = 1 ; j <= n; j++)
       if (i != j && !b[i][j])
          {
              f.pb(mp(i,j));
              b[i][j]=1;
              b[j][i]=1;
          }
   }
for (i = 1; i < k; i++)
    for (j = 1; j < k; j++)
    if (i != j && !b[a[i]][a[j]])
          {
              f.pb(mp(a[i],a[j]));
              b[a[i]][a[j]]=1;
              b[a[j]][a[i]]=1;
          }

if (m > f.size() || n == k)
   cout << -1 << endl;
else
for (i = 0; i < m; i++)
    cout << f[i].fi << " " << f[i].se << endl;
return 0;
}


//Solution by Zhusupov Nurlan
#include <iostream>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <ctime>

using namespace std;

typedef long long LL;
typedef map<string , int> MSI;
typedef vector<int> VI;

#define pb(x) push_back(x)
#define sqr(x) ((x) * (x))
#define F first
#define S second
#define SZ(t) ((int) t.size())
#define len(t) ((int) t.length())
#define base 10
#define fname ""
#define sz 1000 * 1000
#define EPS (1e-8)
#define INF ((int)1e9 + 9)
#define write(xx) printf("%d" , xx);
#define readln(xx) getline(cin , xx)
#define read(xx) scanf("%d" , &xx)
#define for(xx1 , yy1 , zz1) for(int zz1 = xx1 ; zz1 <= yy1 ; zz1++)
#define mp make_pair
const double PI  = acos(-1.0);

int n, m, k, a[sz], t, x[sz], y[sz], d[sz], v, l, r;
bool was[500][500];

void add(int l, int r)
{
	if (!m || was[l][r] || l == r)
		return ;
	x[m] = l;
	y[m] = r;
	m--;
	was[l][r] = was[r][l] = 1;
}

int main(){
	//freopen(fname"in", "w", stdout);
	cin >> n >> m >> k;
	t = m;

	for (1, k, i)
	{
		read(a[i]);
   		d[a[i]] = 1;
   	}
   	if (k == n)
   	{
   		assert(!"BLIA");
   		cout << -1;
   		return 0;
   	}
   	{
   		for (1, n, i)
   			if (!d[i])
   				v = i;
   		for (1, n, i)
   			if (d[i])
   			{
   				if (l)
   					r = i;
   				else
   					l = i;
   			}

  	 	add(l, v);
   		add(v, r);
   		was[l][r] = was[r][l] = 1;

   		for (1, n, i)
   			if (i != l && i != r && i != v && m)
   				add(l, i);

   		for (1, n, i)
   			if (i != l && i != r && i != v && !d[i])
   				add(i, r);

   		for (1, n, i)
   			for (i + 1, n, j)
   				if (m && i != l && i != r && j != l && j != r)
   					add(i, j);
   	}
   		if (m)
  	 		cout << -1;
   		else
   			for (1, t, i)
   				printf("%d %d\n", x[i], y[i]);

    return 0;
}


//Solution by Zhusupov Nurlan
#include <iostream>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <ctime>

using namespace std;

typedef long long LL;
typedef map<string , int> MSI;
typedef vector<int> VI;

#define pb(x) push_back(x)
#define sqr(x) ((x) * (x))
#define F first
#define S second
#define SZ(t) ((int) t.size())
#define len(t) ((int) t.length())
#define base 10
#define fname ""
#define sz 1000 * 1000
#define EPS (1e-8)
#define INF ((int)1e9 + 9)
#define write(xx) printf("%d" , xx);
#define readln(xx) getline(cin , xx)
#define read(xx) scanf("%d" , &xx)
#define for(xx1 , yy1 , zz1) for(int zz1 = xx1 ; zz1 <= yy1 ; zz1++)
#define mp make_pair
const double PI  = acos(-1.0);

int n, m, k, a[sz], t, x[sz], y[sz], d[sz], v, l, r;

void add(int l, int r)
{
	x[m] = l;
	y[m] = r;
	m--;
}

int main(){
	//freopen(fname"in", "r", stdin);
	cin >> n >> m >> k;
	t = m;

	for (1, k, i)
	{
		read(a[i]);
   		d[a[i]] = 1;
   	}
   	if (k == n)
   	{
   		cout << -1;
   		return 0;
   	}
   	if (k < n - 1)
   	{
   		l = 0;
   		for (1, n, i)
   			if (!d[i])
   				a[++l] = i;

   		add(a[1], a[2]);
   		for (1, n, i)
   			for (i + 1, n, j)
   				if (mp(i, j) != mp(a[1], a[2]) && mp(i, j) != mp(a[2], a[1]) && m)
   					add(i, j);

   	}
   	else
   	{
   		for (1, n, i)
   			if (!d[i])
   				v = i;
   		l = 1;
   		if (v == l)
   			l = 2;
   		r = l + 1;
   		if (v == r)
   			r++;

  	 	add(l, v);
   		add(v, r);

   		for (1, n, i)
   			if (i != l && i != r && i != v && m)
   				add(l, i);
   		for (1, n, i)
   			for (i + 1, n, j)
   				if (m && i != l && i != r && j != l && j != r && j != v)
   					add(i, j);
   	}
   		if (m)
  	 		cout << -1;
   		else
   			for (1, t, i)
   				printf("%d %d\n", x[i], y[i]);

    return 0;
}


//Solution by Zhusupov Nurlan
#include <iostream>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <ctime>

using namespace std;

typedef long long LL;
typedef map<string , int> MSI;
typedef vector<int> VI;

#define pb(x) push_back(x)
#define sqr(x) ((x) * (x))
#define F first
#define S second
#define SZ(t) ((int) t.size())
#define len(t) ((int) t.length())
#define base 10
#define fname ""
#define sz 1000 * 1000
#define EPS (1e-8)
#define INF ((int)1e9 + 9)
#define write(xx) printf("%d" , xx);
#define readln(xx) getline(cin , xx)
#define read(xx) scanf("%d" , &xx)
#define for(xx1 , yy1 , zz1) for(int zz1 = xx1 ; zz1 <= yy1 ; zz1++)
#define mp make_pair
const double PI  = acos(-1.0);

int n, m, k, a[sz], t, x[sz], y[sz], d[sz], v, l, r;

void add(int l, int r)
{
	x[m] = l;
	y[m] = r;
	m--;
}

int main(){
	//freopen(fname"in", "r", stdin);
	cin >> n >> m >> k;
	t = m;

	for (1, k, i)
	{
		read(a[i]);
   		d[a[i]] = 1;
   	}
   	if (k == n)
   	{
   		cout << -1;
   		return 0;
   	}
   	if (k < -n - 1)
   	{
   	}
   	else
   	{
   		for (1, n, i)
   			if (!d[i])
   				v = i;
   		l = 1;
   		if (v == l)
   			l = 2;
   		r = l + 1;
   		if (v == r)
   			r++;

  	 	add(l, v);
   		add(v, r);

   		for (1, n, i)
   			if (i != l && i != r && i != v && m)
   				add(l, i);
   		for (1, n, i)
   			for (i + 1, n, j)
   				if (m && i != l && i != r && j != l && j != r && j != v)
   					add(i, j);
   	}
   		if (m)
  	 		cout << -1;
   		else
   			for (1, t, i)
   				printf("%d %d\n", x[i], y[i]);

    return 0;
}


//Solution by Zhusupov Nurlan
#include <iostream>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <ctime>

using namespace std;

typedef long long LL;
typedef map<string , int> MSI;
typedef vector<int> VI;

#define pb(x) push_back(x)
#define sqr(x) ((x) * (x))
#define F first
#define S second
#define SZ(t) ((int) t.size())
#define len(t) ((int) t.length())
#define base 10
#define fname ""
#define sz 1000 * 1000
#define EPS (1e-8)
#define INF ((int)1e9 + 9)
#define write(xx) printf("%d" , xx);
#define readln(xx) getline(cin , xx)
#define read(xx) scanf("%d" , &xx)
#define for(xx1 , yy1 , zz1) for(int zz1 = xx1 ; zz1 <= yy1 ; zz1++)
#define mp make_pair
const double PI  = acos(-1.0);

int n, m, k, a[sz], t, x[sz], y[sz], d[sz], v, l, r;
bool was[500][500];

void add(int l, int r)
{
	if (!m || was[l][r] || l == r)
		return ;
	x[m] = l;
	y[m] = r;
	m--;
	was[l][r] = was[r][l] = 1;
}

int main(){
	//freopen(fname"in", "w", stdout);
	cin >> n >> m >> k;
	t = m;

	for (1, k, i)
	{
		read(a[i]);
   		d[a[i]] = 1;
   	}
   	if (k == n)
   	{
   		cout << -1;
   		return 0;
   	}
   	{
   		for (1, n, i)
   			if (!d[i])
   				v = i;
   		for (1, n, i)
   			if (d[i])
   			{
   				if (l)
   					r = i;
   				else
   					l = i;
   			}

  	 	add(l, v);
   		add(v, r);
   		was[l][r] = was[r][l] = 1;

   		for (1, n, i)
   			if (i != l && i != r && i != v && m)
   				add(l, i);

   		for (1, n, i)
   			if (i != l && i != r && i != v && !d[i])
   				add(i, r);

   		for (1, n, i)
   			for (i + 1, n, j)
   				if (m && i != l && i != r && j != l && j != r)
   					add(i, j);
   	}
   		if (m)
  	 		cout << -1;
   		else
   			for (1, t, i)
   				printf("%d %d\n", x[i], y[i]);

    return 0;
}


//Solution by Zhusupov Nurlan
#include <iostream>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <ctime>

using namespace std;

typedef long long LL;
typedef map<string , int> MSI;
typedef vector<int> VI;

#define pb(x) push_back(x)
#define sqr(x) ((x) * (x))
#define F first
#define S second
#define SZ(t) ((int) t.size())
#define len(t) ((int) t.length())
#define base 10
#define fname ""
#define sz 1000 * 1000
#define EPS (1e-8)
#define INF ((int)1e9 + 9)
#define write(xx) printf("%d" , xx);
#define readln(xx) getline(cin , xx)
#define read(xx) scanf("%d" , &xx)
#define for(xx1 , yy1 , zz1) for(int zz1 = xx1 ; zz1 <= yy1 ; zz1++)
#define mp make_pair
const double PI  = acos(-1.0);

int n, m, k, a[sz], t, x[sz], y[sz], d[sz], v, l, r;
bool was[500][500];

void add(int l, int r)
{
	if (was[l][r])
		return ;
	x[m] = l;
	y[m] = r;
	m--;
	was[l][r] = 1;
}

int main(){
	//freopen(fname"in", "r", stdin);
	cin >> n >> m >> k;
	t = m;

	for (1, k, i)
	{
		read(a[i]);
   		d[a[i]] = 1;
   	}
   	if (k == n)
   	{
   		cout << -1;
   		return 0;
   	}
   	if (k < -n - 1)
   	{
   	}
   	else
   	{
   		for (1, n, i)
   			if (!d[i])
   				v = i;
   		l = 1;
   		if (v == l)
   			l = 2;
   		r = l + 1;
   		if (v == r)
   			r++;

  	 	add(l, v);
   		add(v, r);

   		for (1, n, i)
   			if (i != l && i != r && i != v && m)
   				add(l, i);
   		for (1, n, i)
   			for (i + 1, n, j)
   				if (m && i != l && i != r && j != l && j != r && j != v)
   					add(i, j);
   	}
   		if (m)
  	 		cout << -1;
   		else
   			for (1, t, i)
   				printf("%d %d\n", x[i], y[i]);

    return 0;
}


//Solution by Zhusupov Nurlan
#include <iostream>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <ctime>

using namespace std;

typedef long long LL;
typedef map<string , int> MSI;
typedef vector<int> VI;

#define pb(x) push_back(x)
#define sqr(x) ((x) * (x))
#define F first
#define S second
#define SZ(t) ((int) t.size())
#define len(t) ((int) t.length())
#define base 10
#define fname ""
#define sz 1000 * 1000
#define EPS (1e-8)
#define INF ((int)1e9 + 9)
#define write(xx) printf("%d" , xx);
#define readln(xx) getline(cin , xx)
#define read(xx) scanf("%d" , &xx)
#define for(xx1 , yy1 , zz1) for(int zz1 = xx1 ; zz1 <= yy1 ; zz1++)
#define mp make_pair
const double PI  = acos(-1.0);

int n, m, k, a[sz], t, x[sz], y[sz], d[sz], v, l, r;

void add(int l, int r)
{
	x[m] = l;
	y[m] = r;
	m--;
}

int main(){
	//freopen(fname"in", "r", stdin);
	cin >> n >> m >> k;
	t = m;

	for (1, k, i)
	{
		read(a[i]);
   		d[a[i]] = 1;
   	}
   	if (k == n)
   	{
   		cout << -1;
   		return 0;
   	}
   	if (k < n - 1)
   	{
   		l = 0;
   		for (1, n, i)
   			if (!d[i])
   				a[++l] = i;

   		add(a[1], a[2]);
   		for (1, n, i)
   			for (i + 1, n, j)
   				if (mp(i, j) != mp(a[1], a[2]) && mp(i, j) != mp(a[2], a[1]) && m)
   					add(i, j);

   	}
   	else
   	{
   		for (1, n, i)
   			if (!d[i])
   				v = i;
   		l = 1;
   		if (v == l)
   			l = 2;
   		r = l + 1;
   		if (v == r)
   			r++;

  	 	add(l, v);
   		add(v, r);

   		for (1, n, i)
   			if (i != l && i != r && i != v && m)
   				add(l, i);
   		for (1, n, i)
   			for (i + 1, n, j)
   				if (m && i != l && i != r && j != l && j != r && j != v)
   					add(i, j);
   		if (m)
  	 		cout << -1;
   		else
   			for (1, t, i)
   				printf("%d %d\n", x[i], y[i]);
    }
    return 0;
}


//Solution by Zhusupov Nurlan
#include <iostream>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <ctime>

using namespace std;

typedef long long LL;
typedef map<string , int> MSI;
typedef vector<int> VI;

#define pb(x) push_back(x)
#define sqr(x) ((x) * (x))
#define F first
#define S second
#define SZ(t) ((int) t.size())
#define len(t) ((int) t.length())
#define base 10
#define fname ""
#define sz 1000 * 1000
#define EPS (1e-8)
#define INF ((int)1e9 + 9)
#define write(xx) printf("%d" , xx);
#define readln(xx) getline(cin , xx)
#define read(xx) scanf("%d" , &xx)
#define for(xx1 , yy1 , zz1) for(int zz1 = xx1 ; zz1 <= yy1 ; zz1++)
#define mp make_pair
const double PI  = acos(-1.0);

int n, m, k, a[sz], t, x[sz], y[sz], d[sz], v, l, r;
bool was[500][500];

void add(int l, int r)
{
	if (!m || was[l][r] || l == r)
		return ;
	x[m] = l;
	y[m] = r;
	m--;
	was[l][r] = 1;
}

int main(){
	//freopen(fname"in", "r", stdin);
	cin >> n >> m >> k;
	t = m;

	for (1, k, i)
	{
		read(a[i]);
   		d[a[i]] = 1;
   	}
   	if (k == n)
   	{
   		cout << -1;
   		return 0;
   	}
   	if (k < -n - 1)
   	{
   	}
   	else
   	{
   		for (1, n, i)
   			if (!d[i])
   				v = i;
   		l = 1;
   		if (v == l)
   			l = 2;
   		r = l + 1;
   		if (v == r)
   			r++;

  	 	add(l, v);
   		add(v, r);

   		for (1, n, i)
   			if (i != l && i != r && i != v && m)
   				add(l, i);
   		for (1, n, i)
   			if (i != l && i != r && i != v && !d[i])
   				add(i, r);
   		for (1, n, i)
   			for (i + 1, n, j)
   				if (m && i != l && i != r && j != l && j != r && j != v)
   					add(i, j);
   	}
   		if (m)
  	 		cout << -1;
   		else
   			for (1, t, i)
   				printf("%d %d\n", x[i], y[i]);

    return 0;
}


//Solution by Zhusupov Nurlan
#include <iostream>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <ctime>

using namespace std;

typedef long long LL;
typedef map<string , int> MSI;
typedef vector<int> VI;

#define pb(x) push_back(x)
#define sqr(x) ((x) * (x))
#define F first
#define S second
#define SZ(t) ((int) t.size())
#define len(t) ((int) t.length())
#define base 10
#define fname ""
#define sz 1000 * 1000
#define EPS (1e-8)
#define INF ((int)1e9 + 9)
#define write(xx) printf("%d" , xx);
#define readln(xx) getline(cin , xx)
#define read(xx) scanf("%d" , &xx)
#define for(xx1 , yy1 , zz1) for(int zz1 = xx1 ; zz1 <= yy1 ; zz1++)
#define mp make_pair
const double PI  = acos(-1.0);

int n, m, k, a[sz], t, x[sz], y[sz], d[sz], v, l, r;
bool was[500][500];

void add(int l, int r)
{
	if (!m || was[l][r] || l == r)
		return ;
	x[m] = l;
	y[m] = r;
	m--;
	was[l][r] = was[r][l] = 1;
}

int main(){
	//freopen(fname"in", "r", stdin);
	cin >> n >> m >> k;
	t = m;

	for (1, k, i)
	{
		read(a[i]);
   		d[a[i]] = 1;
   	}
   	if (k == n)
   	{
   		assert(!"BRIA");
   		cout << -1;
   		return 0;
   	}
   	if (k < -n - 1)
   	{
   	}
   	else
   	{
   		for (1, n, i)
   			if (!d[i])
   				v = i;
   		l = 1;
   		if (v == l)
   			l = 2;
   		r = l + 1;
   		if (v == r)
   			r++;

  	 	add(l, v);
   		add(v, r);
   		was[l][r] = was[r][l] = 1;

   		for (1, n, i)
   			if (i != l && i != r && i != v && m)
   				add(l, i);
   		for (1, n, i)
   			if (i != l && i != r && i != v && !d[i])
   				add(i, r);
   		for (1, n, i)
   			for (i + 1, n, j)
   				if (m && i != l && i != r && j != l && j != r && j != v)
   					add(i, j);
   	}
   		if (m)
  	 		cout << -1;
   		else
   			for (1, t, i)
   				printf("%d %d\n", x[i], y[i]);

    return 0;
}


//Solution by Zhusupov Nurlan
#include <iostream>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <ctime>

using namespace std;

typedef long long LL;
typedef map<string , int> MSI;
typedef vector<int> VI;

#define pb(x) push_back(x)
#define sqr(x) ((x) * (x))
#define F first
#define S second
#define SZ(t) ((int) t.size())
#define len(t) ((int) t.length())
#define base 10
#define fname ""
#define sz 1000 * 1000
#define EPS (1e-8)
#define INF ((int)1e9 + 9)
#define write(xx) printf("%d" , xx);
#define readln(xx) getline(cin , xx)
#define read(xx) scanf("%d" , &xx)
#define for(xx1 , yy1 , zz1) for(int zz1 = xx1 ; zz1 <= yy1 ; zz1++)
#define mp make_pair
const double PI  = acos(-1.0);

int n, m, k, a[sz], t, x[sz], y[sz], d[sz], v, l, r;
bool was[500][500];

void add(int l, int r)
{
	if (!m || was[l][r] || l == r)
		return ;
	x[m] = l;
	y[m] = r;
	m--;
	was[l][r] = was[r][l] = 1;
}

int main(){
	//freopen(fname"in", "r", stdin);
	cin >> n >> m >> k;
	t = m;

	for (1, k, i)
	{
		read(a[i]);
   		d[a[i]] = 1;
   	}
   	if (k == n)
   	{
   		assert(!"BLIA");
   		cout << -1;
   		return 0;
   	}
   	{
   		for (1, n, i)
   			if (!d[i])
   				v = i;
   		for (1, n, i)
   			if (d[i])
   			{
   				if (l)
   					r = i;
   				else
   					l = i;
   			}

  	 	add(l, v);
   		add(v, r);
   		was[l][r] = was[r][l] = 1;

   		for (1, n, i)
   			if (i != l && i != r && i != v && m)
   				add(l, i);

   		for (1, n, i)
   			if (i != l && i != r && i != v && !d[i])
   				add(i, r);

   		for (1, n, i)
   			for (i + 1, n, j)
   				if (m && i != l && i != r && j != l && j != r && j != v)
   					add(i, j);
   	}
   		if (m)
  	 		cout << -1;
   		else
   			for (1, t, i)
   				printf("%d %d\n", x[i], y[i]);

    return 0;
}


#include<cstdio>
#include<algorithm>
#include<map>
#include<cstring>
#include<vector>
#include<cmath>
#include<string>
#define N 1000010
#define M 1010
#define P 1000000007
using namespace std;
int n,m,k,i,j,a,b,v,r;
int dis[M][M],u[M],vis[M][M],f[N];
int main()
{
    scanf("%d%d%d",&n,&m,&k);
    for (i=1;i<=k;i++)
    {
        scanf("%d",&u[i]);
        f[u[i]]=1;
    }
    if (k==n)
    {
        printf("-1");
        return 0;
    }
        m=m-n+1;
        for (i=1;i<=n;i++)
        if (f[i]) break;a=i;
        for (i=1;i<=n;i++)
        if (f[i]==0)
        {
            vis[a][i]=1;
            vis[i][a]=1;
        }
        for (i=1;i<=n;i++)
        if (f[i]==0) break; b=i;
        for (i=1;i<=n;i++)
        if ((f[i])&&(i!=a))
        {
            vis[i][b]=1;
            vis[b][i]=1;
        }

        for (i=1;i<=n;i++)
        for (j=i+1;j<=n;j++)
        if ((vis[i][j]==0)&&m&&(j!=a))
        if ((i!=a)||((i==a)&&(f[j]!=1)))
        {
            m--;
            vis[i][j]=1;vis[j][i]=1;
        }
        if (m)
        {
            printf("-1");
            return 0;
        }
        else
        for (i=1;i<=n;i++)
        for (j=i+1;j<=n;j++)
        if (vis[i][j])
        printf("%d %d\n",i,j);

}


#include<cstdio>
#include<algorithm>
#include<map>
#include<cstring>
#include<vector>
#include<cmath>
#include<string>
#define N 1000010
#define M 1010
#define P 1000000007
using namespace std;
int n,m,k,i,j,a,b,v,r;
int dis[M][M],u[M],vis[M][M],f[N];
int main()
{
    scanf("%d%d%d",&n,&m,&k);
    for (i=1;i<=k;i++)
    {
        scanf("%d",&u[i]);
        f[u[i]]=1;
    }
    if (m>n*(n-1)/2-(k-1))
    printf("-1");
    else
    {
        m=m-n+1;
        for (i=1;i<=n;i++)
        if (f[i]) break;a=i;
        for (i=1;i<=n;i++)
        if (f[i]==0)
        {
            printf("%d %d\n",a,i);
            vis[a][i]=1;
            vis[i][a]=1;
        }
        for (i=1;i<=n;i++)
        if (f[i]==0) break; b=i;
        for (i=1;i<=n;i++)
        if ((f[i])&&(i!=a))
        {
            printf("%d %d\n",i,b);
            vis[i][b]=1;
            vis[b][i]=1;
        }
        for (i=1;i<=n;i++)
        for (j=1;j<=n;j++)
        if (j!=a)
        if ((vis[i][j]==0)&&m)
        if ((i!=a)||(i==a)&&(f[j]!=1))
        {
            m--;
            printf("%d %d\n",i,j);
            vis[i][j]=1;vis[j][i]=1;
        }

    }

}


#include<cstdio>
#include<algorithm>
#include<map>
#include<cstring>
#include<vector>
#include<cmath>
#include<string>
#define N 1000010
#define M 1010
#define P 1000000007
using namespace std;
int n,m,k,i,j,a,b,v,r;
int dis[M][M],u[M],vis[M][M],f[N];
int main()
{
    scanf("%d%d%d",&n,&m,&k);
    for (i=1;i<=k;i++)
    {
        scanf("%d",&u[i]);
        f[u[i]]=1;
    }

        m=m-n+1;
        for (i=1;i<=n;i++)
        if (f[i]) break;a=i;
        for (i=1;i<=n;i++)
        if (f[i]==0)
        {
            vis[a][i]=1;
            vis[i][a]=1;
        }
        for (i=1;i<=n;i++)
        if (f[i]==0) break; b=i;
        for (i=1;i<=n;i++)
        if ((f[i])&&(i!=a))
        {
            vis[i][b]=1;
            vis[b][i]=1;
        }
        for (i=1;i<=n;i++)
        for (j=1;j<=n;j++)
        if (j!=a)
        if ((vis[i][j]==0)&&m)
        if ((i!=a)||(i==a)&&(f[j]!=1))
        {
            m--;
            vis[i][j]=1;vis[j][i]=1;
        }

        if (m)
        printf("-1");
        else
        for (i=1;i<=n;i++)
        for (j=i+1;j<=n;j++)
        if (vis[i][j])
        printf("%d %d\n",i,j);

}


#include<cstdio>
#include<algorithm>
#include<map>
#include<cstring>
#include<vector>
#include<cmath>
#include<string>
#define N 1000010
#define M 1010
#define P 1000000007
using namespace std;
int n,m,k,i,j,a,b,v,r;
int dis[M][M],u[M],vis[M][M],f[N];
int main()
{
    scanf("%d%d%d",&n,&m,&k);
    for (i=1;i<=k;i++)
    {
        scanf("%d",&u[i]);
        f[u[i]]=1;
    }
    if (m>(n-k)*k)
    printf("-1");
    else
    {
        m=m-n+1;
        for (i=1;i<=n;i++)
        if (f[i]) break;a=i;
        for (i=1;i<=n;i++)
        if (f[i]==0)
        {
            printf("%d %d\n",a,i);
            vis[a][i]=1;
            vis[i][a]=1;
        }
        for (i=1;i<=n;i++)
        if (f[i]==0) break; b=i;
        for (i=1;i<=n;i++)
        if ((f[i])&&(i!=a))
        {
            printf("%d %d\n",i,b);
            vis[i][b]=1;
            vis[b][i]=1;
        }
        for (i=1;i<=n;i++)
        for (j=1;j<=n;j++)
        if ((f[i]+f[j]==1)&&(vis[i][j]==0)&&m)
        {
            m--;
            printf("%d %d\n",i,j);
            vis[i][j]=1;vis[j][i]=1;
        }

    }

}


#include<cstdio>
#include<algorithm>
#include<map>
#include<cstring>
#include<vector>
#include<cmath>
#include<string>
#define N 1000010
#define M 1010
#define P 1000000007
using namespace std;
int n,m,k,i,j,a,b,v,r;
int dis[M][M],u[M],vis[M][M],f[N];
int main()
{
    scanf("%d%d%d",&n,&m,&k);
    for (i=1;i<=k;i++)
    {
        scanf("%d",&u[i]);
        f[u[i]]=1;
    }

        m=m-n+1;
        for (i=1;i<=n;i++)
        if (f[i]) break;a=i;
        for (i=1;i<=n;i++)
        if (f[i]==0)
        {
            vis[a][i]=1;
            vis[i][a]=1;
        }
        for (i=1;i<=n;i++)
        if (f[i]==0) break; b=i;
        for (i=1;i<=n;i++)
        if ((f[i])&&(i!=a))
        {
            vis[i][b]=1;
            vis[b][i]=1;
        }

        for (i=1;i<=n;i++)
        for (j=i+1;j<=n;j++)
        if ((vis[i][j]==0)&&m&&(j!=a))
        if ((i!=a)||((i==a)&&(f[j]!=1)))
        {
            m--;
            vis[i][j]=1;vis[j][i]=1;
        }

        if (m)
        {
            printf("-1");
            return 0;
        }
        else
        for (i=1;i<=n;i++)
        for (j=i+1;j<=n;j++)
        if (vis[i][j])
        printf("%d %d\n",i,j);

}


#include <stdio.h>
#include <algorithm>
using namespace std;
int mark[310]={0},n,m,k,t,g[310][310]={0};
int main(){
#ifndef ONLINE_JUDGE
	freopen("prob.in","r",stdin);
#endif
	scanf("%d%d%d",&n,&m,&k);
	if(m>n*(n-1)/2-k+1||k>=n){
		printf("-1");
		return 0;
	}
	for(int i=1; i<=k; i++){
		scanf("%d",&t);
		mark[t]=1;
	}
	for(int i=1; i<=n; i++)
		if(mark[i]){
			for(int j=1; j<=n&&m; j++){
				if(!mark[j]){
					printf("%d %d\n",i,j);
					g[i][j]=g[j][i]=1;
					m--;
					for(int k=1; k<=n&&m; k++)
						if(k!=i&&k!=j&&!g[k][j]){
							printf("%d %d\n",k,j);
							g[k][j]=g[j][k]=1;
							m--;
						}
					for(int k=1; k<=n&&m; k++)
						for(int l=1; l<=n&&m; l++)
							if(k!=i&&l!=i&&!g[k][l]&&l!=k){
							printf("%d %d\n",k,l);
								m--;
								g[k][l]=g[l][k]=1;
							}
				}
			}
			break;
		}
	//printf("%d",m);
	return 0;
}


#include <stdio.h>
#include <algorithm>
using namespace std;
int mark[310]={0},n,m,k,t;
int main(){
#ifndef ONLINE_JUDGE
	freopen("prob.in","r",stdin);
#endif
	scanf("%d%d%d",&n,&m,&k);
	if(m>=n||k>=n){
		printf("-1");
		return 0;
	}
	for(int i=1; i<=k; i++){
		scanf("%d",&t);
		mark[t]=1;
	}
	for(int i=1; i<=n; i++)
		if(!mark[i]){
			for(int j=1; j<=n; j++)
				if(j!=i)
					printf("%d %d\n",i,j);
			return 0;
		}
	return 0;
}


#include <stdio.h>
#include <algorithm>
using namespace std;
int mark[310]={0},n,m,k,t,g[310][310]={0};
int main(){
#ifndef ONLINE_JUDGE
	freopen("prob.in","r",stdin);
#endif
	scanf("%d%d%d",&n,&m,&k);
	if(m>n*(n-1)/2-k+1||k>=n){
		printf("-1");
		return 0;
	}
	for(int i=1; i<=k; i++){
		scanf("%d",&t);
		mark[t]=1;
	}
	for(int i=1; i<=n; i++)
		if(mark[i]){
			for(int j=1; j<=n; j++){
				if(!mark[j]){
					printf("%d %d\n",i,j);
					g[i][j]=g[j][i]=1;
					m--;
					for(int k=1; k<=n; k++)
						if(k!=i&&k!=j){
							printf("%d %d\n",k,j);
							g[k][j]=g[j][k]=1;
							m--;
						}
					for(int k=1; k<=n&&m; k++)
						for(int l=1; l<=n&&m; l++)
							if(k!=i&&l!=i&&!g[k][l]&&l!=k){
								printf("%d %d\n",k,l);
								m--;
								g[k][l]=g[l][k]=1;
							}
					break;
				}
			}
			break;
		}
	//printf("%d",m);
	return 0;
}