#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define vec vector<ll>
#define mat vector<vector<ll> >
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
typedef long double ld;
typedef complex<double> Complex;
const ll INF=1e9+7;
const ll inf=INF*INF;
const ll MAX=110;

vector<ll>ans(MAX*MAX,-1);
vector<vector<ll> >G(MAX);
vector<vector<ll> >idx(MAX,vector<ll>(MAX));
vector<vector<ll> >re(MAX,vector<ll>(MAX,0));
vector<ll>used(MAX,0);
void dfs(ll v,ll p){
    if(p>=0&&ans[idx[p][v]]==-1){
        ans[idx[p][v]]=re[p][v];
    }
    if(used[v])return;
    used[v]=1;
    for(auto e:G[v]){
        if(e==p)continue;
        dfs(e,v);
    }
}

signed main(){
    ll n,m;cin>>n>>m;
    vector<ll>a(m),b(m),c(n);
    rep(i,m)cin>>a[i]>>b[i];
    rep(i,n)cin>>c[i];
    rep(i,m){
        a[i]--;b[i]--;
        re[b[i]][a[i]]=1;
        idx[a[i]][b[i]]=i;
        idx[b[i]][a[i]]=i;
        if(c[a[i]]>c[b[i]])ans[i]=0;
        else if(c[a[i]]<c[b[i]])ans[i]=1;
        else{
            G[a[i]].pb(b[i]);
            G[b[i]].pb(a[i]);
        }
    }
    rep(i,n){
        if(G[i].size()==0)continue;
        if(used[i])continue;
        dfs(i,-1);
    }
    rep(i,m){
        cout<<(ans[i]?"<-":"->")<<endl;
    }
}
#line 2 "/home/defineprogram/Desktop/Library/template/template.cpp"
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define REP(i,n) for(ll i=1;i<n;i++)
#define rev(i,n) for(ll i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<ll,ll>
#define len(s) (ll)s.size()
 
template<class T> inline bool chmin(T &a, T b){
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b){
	if(a<b){a=b;return true;}
	return false;
}
constexpr ll inf = 3e18;
#line 3 "/home/defineprogram/Desktop/Library/structure/UnionFind.cpp"

class UnionFind{
	using size_type=int32_t;
	size_type N;
	vector<size_type>par,siz;
public:
	size_type find(size_type x){
		assert(x<N);
		return (par[x]==x?x:par[x]=find(par[x]));
	}
	void merge(size_type x,size_type y){
		assert(x<N&&y<N);
		x=find(x);y=find(y);
		if(x==y)return;
		if(siz[x]>siz[y])swap(x,y);
		par[x]=y;siz[y]+=siz[x];
	}
	bool same(size_type x,size_type y){
		return find(x)==find(y);
	}
	size_type size(size_type x){
		return siz[find(x)];
	}
	UnionFind(size_type N):N(N),siz(N,1),par(N){
		iota(all(par),0);
	}
};

/*
@brief Union Find
@docs docs/UnionFind.md
*/
#line 3 "main.cpp"


int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll N,M;cin>>N>>M;
    if(N<=2){
        if(M==0){
            rep(i,N)cout<<i*2+1<<" "<<i*2+2<<endl;
        }else {
            cout<<"-1\n";
        }
    }else {
        if(M<0||M>N-2)cout<<"-1\n";
        else {
            cout<<1<<" "<<10000000<<endl;
            rep(i,M+1)cout<<2+i*2<<" "<<3+i*2<<endl;
            rep(i,N-M-2)cout<<100000000+i*2<<" "<<100000000+i*2+1<<endl;
        }
    }
}
