#include<bits/stdc++.h>
using namespace std;
//#define int ll
#define ll long long
#define db double
#define rep(i,be,en) for(int i=be;i<=en;i++)
const int INF = 0x3f3f3f3f;
const ll inf=0x3f3f3f3f3f3f3f3f;
//const double pi=acos(-1);
const int mod=1e9+7;
const double eps = 1e-8;
using namespace std;
const int N=1e5+7;
const int M=1e6+7;

inline int read(){
    char c=getchar();int x=0,f=1;
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}

int T,n,m,fl,ans;
int a[N],b[N],c[N];
vector<int> g[N];

void dfs(int u,int fa){
	if(c[a[u]]==0){
		c[a[u]]=1;
		b[u]=1;
		for(int v:g[u]){
			if(v==fa) continue;
			dfs(v,u);
		}
		c[a[u]]=0;
	}else{
		for(int v:g[u]){
			if(v==fa) continue;
			dfs(v,u);
		}
	}
	return ;
}

signed main(){
	n=read();
	rep(i,1,n){
		a[i]=read();
	}
	rep(i,2,n){
		int u=read(),v=read();
		g[u].push_back(v);
		g[v].push_back(u);
	}
	dfs(1,-1);
	rep(i,1,n){
		if(b[i]) printf("%d\n",i);
	}
	
}

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

#define watch(x) cerr << (#x) << ": " << (x) << endl

typedef long long LL;

const int N = 200009;
int n,m;

void nope() {
    cout << -1 << endl;
    exit(0);
}

void pr(int a,int b) {
    cout << a << ' ' << b << '\n';
}

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n >> m;

    if(n == 1) {
        if(m == 0) {
            pr(1, 2);
            return 0;
        } else {
            nope();
        }
    }

    int tp = n-m-2;

    if(m < 0 || tp < 0) {
        nope();
    }

    for(int i = 0; i < n; ++i) {
        if(i < tp) {
            pr(2*i+1, 2*i+2);
        } else if (i < n-1) {
            pr(2*i+2, 2*i+3);
        } else {
            pr(2*tp+1, 2*n);
        }
    }

    return 0;
}
