#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//__builtin_popcount(n);
//-std=c++11
#define IOS ios::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define RI register int
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
const int INF = 0x3f3f3f3f;
const int SZ = 5e5 + 10;
int n,m;
int a,b,fist[SZ];
int t[SZ],temp;
bool vis[SZ];
struct zt
{
	int v,nxt;
}line[SZ << 1];

inline void build(int x,int y)
{
	line[++ temp] = (zt){y,fist[x]};
	fist[x] = temp;
}

inline bool dfs(int u,int far)
{
	vis[u] = 1;
	for(int i = fist[u];i != -1;i = line[i].nxt)
	{
		int v = line[i].v;
		if(v == far || vis[v] == 1) continue;
		if(t[v] == t[u])
		{
			return 0;
		}
		if(!dfs(v,u)) return 0;
	}
	return 1;
}

int main()
{
	memset(fist,-1,sizeof(fist));
	scanf("%d%d",&n,&m);
	for(int i = 1;i <= m;i ++)
	{
		scanf("%d%d",&a,&b);
		build(a,b);
		build(b,a);
	}
	for(int i = 1;i <= n;i ++) scanf("%d",&t[i]);
	if(dfs(1,1))
	{
		for(int i = 1;i <= n;i ++) printf("%d ",i);
		printf("\n");
	}
	else printf("-1\n");
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//__builtin_popcount(n);
//-std=c++11
#define IOS ios::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define RI register int
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
const int INF = 0x3f3f3f3f;
const int SZ = 1e6 + 10;
int n,m;
int a,b,fist[SZ];
int temp;
struct tt
{
	int t;
	int id;
}A[SZ];
bool vis[SZ];
bool cmp(tt a,tt b)
{
	if(a.t != b.t) return a.t < b.t;
	else return a.id < b.id;
}
struct zt
{
	int v,nxt;
}line[SZ << 1];

inline void build(int x,int y)
{
	line[++ temp] = (zt){y,fist[x]};
	fist[x] = temp;
}

inline bool dfs(int u)
{
	vis[u] = 1;
	for(int i = fist[u];i != -1;i = line[i].nxt)
	{
		int v = line[i].v;
		if(vis[v] == 1) continue;
		if(A[v].t == A[u].t)
		{
			return 0;
		}
		if(!dfs(v)) return 0;
	}
	return 1;
}

int main()
{
	memset(vis,0,sizeof(vis));
	memset(fist,-1,sizeof(fist));
	scanf("%d%d",&n,&m);
	for(int i = 1;i <= m;i ++)
	{
		scanf("%d%d",&a,&b);
		build(a,b);
		build(b,a);
	}
	for(int i = 1;i <= n;i ++)
	{
		scanf("%d",&A[i].t);
		A[i].id = i;
	}
	int flag = 1;
	for(int i = 1;i <= n;i ++)
	{
		if(vis[i] == 0)
		if(dfs(i) == 0)
		{
			flag = 0;
			break;
		}
	}
	if(flag == 1)
	{
		sort(A + 1,A + n + 1,cmp);
		for(int i = 1;i <= n;i ++) printf("%d ",A[i].id);
		printf("\n");
	}
	else printf("-1\n");
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//__builtin_popcount(n);
//-std=c++11
#define IOS ios::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define RI register int
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
const int INF = 0x3f3f3f3f;
const int SZ = 1e6 + 10;
int n,m;
int a,b,fist[SZ];
int temp;
struct tt
{
	int t;
	int id;
}A[SZ];
map<int,int> mp;
bool cmp(tt a,tt b)
{
	if(a.t != b.t) return a.t < b.t;
	else return a.id < b.id;
}
struct zt
{
	int v,nxt;
}line[SZ << 1];

inline void build(int x,int y)
{
	line[++ temp] = (zt){y,fist[x]};
	fist[x] = temp;
}

inline bool dfs(int u)
{
	map<int,int >vis;
	for(int i = fist[u];i != -1;i = line[i].nxt)
	{
		int v = line[i].v;
		if(mp[v] <= mp[u])
		vis[mp[v]] = 1;
	}
	for(int i = 1;i <= mp[u] - 1;i ++)
	if(vis[i] == 0) return 0;
	if(vis[mp[u]] == 1) return 0;
	return 1;
}

int main()
{
	memset(fist,-1,sizeof(fist));
	scanf("%d%d",&n,&m);
	for(int i = 1;i <= m;i ++)
	{
		scanf("%d%d",&a,&b);
		build(a,b);
		build(b,a);
	}
	for(int i = 1;i <= n;i ++)
	{
		scanf("%d",&A[i].t);
		mp[i] = A[i].t;
		A[i].id = i;
	}
	sort(A + 1,A + n + 1,cmp);
	int flag = 1;
	for(int i = 1;i <= n;i ++)
	{
		if(dfs(A[i].id) == 0)
		{
			flag = 0;
			break;
		}
	}
	if(flag == 1)
	{
		for(int i = 1;i <= n;i ++)
		printf("%d ",A[i].id);
		printf("\n");
	}
	else printf("-1\n");
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//__builtin_popcount(n);
//-std=c++11
#define IOS ios::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define RI register int
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
const int INF = 0x3f3f3f3f;
const int SZ = 1e6 + 10;
int n,m;
int a,b,fist[SZ];
int temp;
struct tt
{
	int t;
	int id;
}A[SZ];
map<int,int> mp;
bool vis[SZ];
bool cmp(tt a,tt b)
{
	if(a.t != b.t) return a.t < b.t;
	else return a.id < b.id;
}
struct zt
{
	int v,nxt;
}line[SZ << 1];

inline void build(int x,int y)
{
	line[++ temp] = (zt){y,fist[x]};
	fist[x] = temp;
}

inline bool dfs(int u)
{
	for(int i = fist[u];i != -1;i = line[i].nxt)
	{
		int v = line[i].v;
		vis[mp[v]] = 1;
	}
	for(int i = 1;i <= mp[u] - 1;i ++)
	{
		if(vis[i] == 0) return 0;
		vis[i] = 0;
	}
	if(vis[mp[u]] == 1)
	{
		vis[mp[u]] = 0;
		 return 0;
	}
	for(int i = mp[u] + 1;i <= n;i ++) vis[i] = 0;
	return 1;
}

int main()
{
	memset(vis,0,sizeof(vis));
	memset(fist,-1,sizeof(fist));
	scanf("%d%d",&n,&m);
	for(int i = 1;i <= m;i ++)
	{
		scanf("%d%d",&a,&b);
		build(a,b);
		build(b,a);
	}
	for(int i = 1;i <= n;i ++)
	{
		scanf("%d",&A[i].t);
		mp[i] = A[i].t;
		A[i].id = i;
	}
	sort(A + 1,A + n + 1,cmp);
	int flag = 1;
	for(int i = 1;i <= n;i ++)
	{
		if(dfs(A[i].id) == 0)
		{
			flag = 0;
			break;
		}
	}
	if(flag == 1)
	{
		for(int i = 1;i <= n;i ++)
		printf("%d ",A[i].id);
		printf("\n");
	}
	else printf("-1\n");
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//__builtin_popcount(n);
//-std=c++11
#define IOS ios::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define RI register int
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
const int INF = 0x3f3f3f3f;
const int SZ = 1e6 + 10;
int n,m;
int a,b,fist[SZ];
int temp;
struct tt
{
	int t;
	int id;
}A[SZ];
map<int,int> mp;
bool cmp(tt a,tt b)
{
	if(a.t != b.t) return a.t < b.t;
	else return a.id < b.id;
}
struct zt
{
	int v,nxt;
}line[SZ << 1];

inline void build(int x,int y)
{
	line[++ temp] = (zt){y,fist[x]};
	fist[x] = temp;
}

inline bool dfs(int u)
{
	int vis[mp[u] + 5];
	for(int i = fist[u];i != -1;i = line[i].nxt)
	{
		int v = line[i].v;
		if(mp[v] <= mp[u])
		vis[mp[v]] = 1;
	}
	for(int i = 1;i <= mp[u] - 1;i ++)
	if(vis[i] == 0) return 0;
	if(vis[mp[u]] == 1) return 0;
	return 1;
}

int main()
{
	memset(fist,-1,sizeof(fist));
	scanf("%d%d",&n,&m);
	for(int i = 1;i <= m;i ++)
	{
		scanf("%d%d",&a,&b);
		build(a,b);
		build(b,a);
	}
	for(int i = 1;i <= n;i ++)
	{
		scanf("%d",&A[i].t);
		mp[i] = A[i].t;
		A[i].id = i;
	}
	sort(A + 1,A + n + 1,cmp);
	int flag = 1;
	for(int i = 1;i <= n;i ++)
	{
		if(dfs(A[i].id) == 0)
		{
			flag = 0;
			break;
		}
	}
	if(flag == 1)
	{
		for(int i = 1;i <= n;i ++)
		printf("%d ",A[i].id);
		printf("\n");
	}
	else printf("-1\n");
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//__builtin_popcount(n);
//-std=c++11
#define IOS ios::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define RI register int
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
const int INF = 0x3f3f3f3f;
const int SZ = 1e6 + 10;
int n,m;
int a,b,fist[SZ];
int temp;
struct tt
{
	int t;
	int id;
}A[SZ];
map<int,int> mp;
bool vis[SZ];
bool cmp(tt a,tt b)
{
	if(a.t != b.t) return a.t < b.t;
	else return a.id < b.id;
}
struct zt
{
	int v,nxt;
}line[SZ << 1];

inline void build(int x,int y)
{
	line[++ temp] = (zt){y,fist[x]};
	fist[x] = temp;
}

inline bool dfs(int u)
{
	for(int i = fist[u];i != -1;i = line[i].nxt)
	{
		int v = line[i].v;
		vis[mp[v]] = 1;
	}
	for(int i = 1;i <= mp[u] - 1;i ++)
	{
		if(vis[i] == 0) return 0;
		vis[i] = 1;
	}
	if(vis[mp[u]] == 1) return 0;
	return 1;
}

int main()
{
	memset(vis,0,sizeof(vis));
	memset(fist,-1,sizeof(fist));
	scanf("%d%d",&n,&m);
	for(int i = 1;i <= m;i ++)
	{
		scanf("%d%d",&a,&b);
		build(a,b);
		build(b,a);
	}
	for(int i = 1;i <= n;i ++)
	{
		scanf("%d",&A[i].t);
		mp[i] = A[i].t;
		A[i].id = i;
	}
	sort(A + 1,A + n + 1,cmp);
	int flag = 1;
	for(int i = 1;i <= n;i ++)
	{
		if(dfs(A[i].id) == 0)
		{
			flag = 0;
			break;
		}
	}
	if(flag == 1)
	{
		for(int i = 1;i <= n;i ++)
		printf("%d ",A[i].id);
		printf("\n");
	}
	else printf("-1\n");
	return 0;
}


#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;

#define ll long long int
#define filecode ifstream in;ofstream out;in.open("input.txt");out.open("output.txt");
#define modN 1000000007

int main()
{
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n,m;
    cin>>n>>m;
    pair <int, int> adj[n];
    for(int i=0;i<m;i++)
        cin>>adj[i].first>>adj[i].second;
    pair <int, int> t[n];
    for(int i=0;i<n;i++)
    {
        cin>>t[i].first;
        t[i].second = i;
    }
    for(int i=0;i<m;i++)
    {
        if(t[adj[i].first-1].first==t[adj[i].second-1].first)
        {
            cout<<
            cout<<-1<<endl;
            return 0;
        }
    }
    sort(t,t+n);
    for(int i=0;i<n;i++)
        cout<<t[i].second+1<<" ";
    cout<<endl;

	return 0;
}


#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;

#define ll long long int
#define filecode ifstream in;ofstream out;in.open("input.txt");out.open("output.txt");
#define modN 1000000007

int main()
{
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    ll n,m;
    cin>>n>>m;
    pair <ll, ll> adj[m];
    vector <ll> e[n];
    for(ll i=0;i<m;i++)
    {
        int u,v;
        cin>>u>>v;
        e[u-1].push_back(v-1);
        e[v-1].push_back(u-1);
    }
    int t[n];
    for(ll i=0;i<n;i++)
    {
        cin>>t[i];
        t[i]--;
    }
    vector <int> p(n);
    iota(p.begin(), p.end(), 0);
    sort(p.begin(), p.end(), [&](int i, int j) {return t[i] < t[j];});
    for(int i=0;i<n;i++)
    {
        vector <int> vec(e[p[i]].size()+1,0);
        for(int j=0;j<e[p[i]].size();j++)
        {
            ll v = e[p[i]][j];
            if(t[p[i]]==t[v])
            {
                cout<<-1<<endl;
                return 0;
            }
            else if (t[p[i]]>t[v])
            {
                if(t[v]<=int(e[p[i]].size()))
                    vec[t[v]] = 1;
            }
        }
        int k = 0;
        while(vec[k])
            ++k;
        if(k!=t[p[i]])
        {
            cout<<-1<<endl;
            return 0;
        }
    }
    for(ll i=0;i<n;i++)
        cout<<p[i]+1<<" ";
    cout<<endl;

	return 0;
}


#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;

#define ll long long int
#define filecode ifstream in;ofstream out;in.open("input.txt");out.open("output.txt");
#define modN 1000000007

int main()
{
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n,m;
    cin>>n>>m;
    pair <int, int> adj[n];
    for(int i=0;i<m;i++)
        cin>>adj[i].first>>adj[i].second;
    pair <int, int> t[n];
    for(int i=0;i<n;i++)
    {
        cin>>t[i].first;
        t[i].second = i;
    }
    for(int i=0;i<m;i++)
    {
        if(t[adj[i].first-1].first==t[adj[i].second-1].first)
        {

            cout<<-1<<endl;
            return 0;
        }
    }
    sort(t,t+n);
    for(int i=0;i<n;i++)
        cout<<t[i].second+1<<" ";
    cout<<endl;

	return 0;
}


#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;

#define ll long long int
#define filecode ifstream in;ofstream out;in.open("input.txt");out.open("output.txt");
#define modN 1000000007

int main()
{
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    ll n,m;
    cin>>n>>m;
    pair <ll, ll> adj[m];
    for(ll i=0;i<m;i++)
        cin>>adj[i].first>>adj[i].second;
    pair <ll, ll> t[n];
    for(ll i=0;i<n;i++)
    {
        cin>>t[i].first;
        t[i].second = i;
    }
    for(ll i=0;i<m;i++)
    {
        if(t[adj[i].first-1].first==t[adj[i].second-1].first)
        {
            cout<<-1<<endl;
            return 0;
        }
    }
    sort(t,t+n);
    for(ll i=0;i<n;i++)
        cout<<t[i].second+1<<" ";
    cout<<endl;

	return 0;
}


#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;

#define ll long long int
#define filecode ifstream in;ofstream out;in.open("input.txt");out.open("output.txt");
#define modN 1000000007

int main()
{
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    ll n,m;
    cin>>n>>m;
    pair <ll, ll> adj[n];
    for(ll i=0;i<m;i++)
        cin>>adj[i].first>>adj[i].second;
    pair <ll, ll> t[n];
    for(ll i=0;i<n;i++)
    {
        cin>>t[i].first;
        t[i].second = i;
    }
    for(ll i=0;i<m;i++)
    {
        if(t[adj[i].first-1].first==t[adj[i].second-1].first)
        {

            cout<<-1<<endl;
            return 0;
        }
    }
    sort(t,t+n);
    for(ll i=0;i<n;i++)
        cout<<t[i].second+1<<" ";
    cout<<endl;

	return 0;
}


#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;

#define ll long long int
#define filecode ifstream in;ofstream out;in.open("input.txt");out.open("output.txt");
#define modN 1000000007

int main()
{
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    ll n,m;
    cin>>n>>m;
    pair <ll, ll> adj[m];
    vector <ll> e[n];
    for(ll i=0;i<m;i++)
    {
        int u,v;
        cin>>u>>v;
        e[u-1].push_back(v-1);
        e[v-1].push_back(u-1);
    }
    pair <ll, ll> t[n];
    for(ll i=0;i<n;i++)
    {
        int c;
        cin>>c;
        t[i].first = c-1;
        t[i].second = i;
    }
    /*for(ll i=0;i<m;i++)
    {
        if(t[adj[i].first-1].first==t[adj[i].second-1].first)
        {
            cout<<-1<<endl;
            return 0;
        }
    }*/
    sort(t,t+n);
    for(int i=0;i<n;i++)
    {
        vector<int> v(e[t[i].second].size()+1,0);
        for(int j=0;j<e[t[i].second].size();j++)
        {
            if(t[t[i].second].first==t[e[t[i].second][j]].first)
            {
                cout<<-1<<endl;
                return 0;
            }
            else if (t[t[i].second].first>t[e[t[i].second][j]].first)
            {
                if(t[e[t[i].second][j]].first<=int(e[t[i].second].size()))
                    v[t[e[t[i].second][j]].first] = 1;
            }
        }
        int k = 0;
        while(v[k])
            ++k;
        if(k!=t[t[i].second].first)
        {
            cout<<-1<<endl;
            return 0;
        }
    }
    for(ll i=0;i<n;i++)
        cout<<t[i].second+1<<" ";
    cout<<endl;

	return 0;
}


#include<iostream>
#include<string>
#include<string.h>
#include<set>
#include<vector>
#include<queue>
#include<map>

using namespace std;

vector<int> ed[555555];
int expColor[555555];

void solve(){
    int n,m;
    cin>>n>>m;

    priority_queue<pair<int,int> > pq;

    for(int i=0;i<m;i++){
        int t,f;
        cin>>t>>f;
        ed[f].push_back(t);
        ed[t].push_back(f);
    }

    for(int i=0;i<n;i++){
        int t;
        cin>>t;
        expColor[i+1]=t;
        pq.push(make_pair(-t,i+1));
    }

    for(int i=1;i<=n;i++){
        set<int> eds;
        for(auto e:ed[i]){
            if(expColor[i]==expColor[e]){
                cout<<-1;
                return;
            }
            if(expColor[e]<expColor[i]){
                eds.insert(expColor[e]);
            }
        }
        if(eds.size()+1!=expColor[i]){
            cout<<-1;
            return;
        }
    }

    vector<int> ans;

    //cout<<"hc";

    while(!pq.empty()){
        auto p = pq.top();
        pq.pop();

        int nd=p.second;
        int topic = -p.first;
        ans.push_back(nd);
        color[nd]=true;
    }
    for(auto a: ans){
        cout<<a<<" ";
    }

}

int main(){
    int testcase;

    testcase=1;
    ios_base::sync_with_stdio(0);

    while(testcase--){
        solve();
    }

}


#include<iostream>
#include<string>
#include<set>
#include<vector>
#include<queue>
#include<map>

using namespace std;

vector<int> ed[5111111];

void solve(){
    int n,m;
    cin>>n>>m;

    priority_queue<pair<int,int> > pq;

    for(int i=0;i<m;i++){
        int t,f;
        cin>>t>>f;
        ed[f].push_back(t);
        ed[t].push_back(f);
    }
    map<int,int> expColor;
    for(int i=0;i<n;i++){
        int t;
        cin>>t;
        expColor[i+1]=t;
        pq.push(make_pair(-t,i+1));
    }

    vector<int> ans;
    map<int,bool> color;

    //cout<<"hc";

    while(!pq.empty()){
        auto p = pq.top();
        pq.pop();

        int nd=p.second;
        int topic = -p.first;
        set<int> eds;
        for(auto e:ed[nd]){
            if(color.find(e)!=color.end()){
                if(expColor[e]==topic){
                    cout<<-1<<endl;
                    return;
                }
                if(expColor[e]<topic){
                    eds.insert(expColor[e]);
                }
            }
        }
        if(eds.size()+1!=topic){
            cout<<-1<<endl;
            return;
        }
        ans.push_back(nd);
        color[nd]=true;
    }
    for(auto a: ans){
        cout<<a<<" ";
    }

}

int main(){
    int testcase;

    testcase=1;

    while(testcase--){
        solve();
    }

}


#include<iostream>
#include<string>
#include<string.h>
#include<set>
#include<vector>
#include<queue>
#include<map>

using namespace std;

vector<int> ed[555555];
int expColor[555555];
bool color[555555];

void solve(){
    int n,m;
    cin>>n>>m;

    priority_queue<pair<int,int> > pq;
    memset(color,0,sizeof(color));

    for(int i=0;i<m;i++){
        int t,f;
        cin>>t>>f;
        ed[f].push_back(t);
        ed[t].push_back(f);
    }

    for(int i=0;i<n;i++){
        int t;
        cin>>t;
        expColor[i+1]=t;
        pq.push(make_pair(-t,i+1));
    }

    vector<int> ans;

    //cout<<"hc";

    while(!pq.empty()){
        auto p = pq.top();
        pq.pop();

        int nd=p.second;
        int topic = -p.first;
        int eds=0;
        for(auto e:ed[nd]){
            if(color[e]){
                if(expColor[e]==topic){
                    cout<<-1<<endl;
                    return;
                }
                if(expColor[e]<topic){
                    eds++;
                }
            }
        }
        if(eds+1!=topic){
            cout<<-1<<endl;
            return;
        }
        ans.push_back(nd);
        color[nd]=true;
    }
    for(auto a: ans){
        cout<<a<<" ";
    }

}

int main(){
    int testcase;

    testcase=1;

    while(testcase--){
        solve();
    }

}


#include<iostream>
#include<string>
#include<string.h>
#include<set>
#include<vector>
#include<queue>
#include<map>

using namespace std;

vector<int> ed[555555];
int expColor[555555];
int color[555555];

void solve(){
    int n,m;
    cin>>n>>m;

    priority_queue<pair<int,int> > pq;
    memset(color,0,sizeof(color));

    for(int i=0;i<m;i++){
        int t,f;
        cin>>t>>f;
        ed[f].push_back(t);
        ed[t].push_back(f);
    }

    for(int i=0;i<n;i++){
        int t;
        cin>>t;
        expColor[i+1]=t;
        pq.push(make_pair(-t,i+1));
    }

    for(int i=1;i<=n;i++){
        set<int> eds;
        for(auto e:ed[i]){
            if(expColor[i]==expColor[e]){
                cout<<-1;
                return;
            }
            if(expColor[e]<expColor[i]){
                eds.insert(expColor[e]);
            }
        }
        if(eds.size()+1!=expColor[i]){
            cout<<-1;
            return;
        }
    }

    vector<int> ans;

    //cout<<"hc";

    while(!pq.empty()){
        auto p = pq.top();
        pq.pop();

        int nd=p.second;
        int topic = -p.first;
        // set<int> eds;
        // for(auto e:ed[nd]){
        //     if(color[e]){
        //         if(expColor[e]==topic){
        //             cout<<-1<<endl;
        //             return;
        //         }
        //         if(expColor[e]<topic){
        //             eds.insert(expColor[e]);
        //         }
        //     }
        // }
        // if(eds.size()+1!=topic){
        //     cout<<-1<<endl;
        //     return;
        // }
        ans.push_back(nd);
        color[nd]=true;
    }
    for(auto a: ans){
        cout<<a<<" ";
    }

}

int main(){
    int testcase;

    testcase=1;

    while(testcase--){
        solve();
    }

}


#include<iostream>
#include<string>
#include<string.h>
#include<set>
#include<vector>
#include<queue>
#include<map>

using namespace std;

vector<int> ed[555555];
int expColor[555555];
int color[555555];

void solve(){
    int n,m;
    cin>>n>>m;

    priority_queue<pair<int,int> > pq;
    memset(color,0,sizeof(color));

    for(int i=0;i<m;i++){
        int t,f;
        cin>>t>>f;
        ed[f].push_back(t);
        ed[t].push_back(f);
    }

    for(int i=0;i<n;i++){
        int t;
        cin>>t;
        expColor[i+1]=t;
        pq.push(make_pair(-t,i+1));
    }

    vector<int> ans;

    //cout<<"hc";

    while(!pq.empty()){
        auto p = pq.top();
        pq.pop();

        int nd=p.second;
        int topic = -p.first;
        set<int> eds;
        for(auto e:ed[nd]){
            if(color[e]){
                if(expColor[e]==topic){
                    cout<<-1<<endl;
                    return;
                }
                if(expColor[e]<topic){
                    eds.insert(expColor[e]);
                }
            }
        }
        if(eds.size()+1!=topic){
            cout<<-1<<endl;
            return;
        }
        ans.push_back(nd);
        color[nd]=true;
    }
    for(auto a: ans){
        cout<<a<<" ";
    }

}

int main(){
    int testcase;

    testcase=1;

    while(testcase--){
        solve();
    }

}


#include<iostream>
#include<string>
#include<string.h>
#include<set>
#include<vector>
#include<queue>
#include<map>

using namespace std;

vector<int> ed[555555];
int expColor[555555];

void solve(){
    int n,m;
    cin>>n>>m;

    priority_queue<pair<int,int> > pq;

    for(int i=0;i<m;i++){
        int t,f;
        cin>>t>>f;
        ed[f].push_back(t);
        ed[t].push_back(f);
    }

    for(int i=0;i<n;i++){
        int t;
        cin>>t;
        expColor[i+1]=t;
        pq.push(make_pair(-t,i+1));
    }

    for(int i=1;i<=n;i++){
        set<int> eds;
        for(auto e:ed[i]){
            if(expColor[i]==expColor[e]){
                cout<<-1;
                return;
            }
            if(expColor[e]<expColor[i]){
                eds.insert(expColor[e]);
            }
        }
        if(eds.size()+1!=expColor[i]){
            cout<<-1;
            return;
        }
    }

    vector<int> ans;

    //cout<<"hc";

    while(!pq.empty()){
        auto p = pq.top();
        pq.pop();

        int nd=p.second;
        int topic = -p.first;
        ans.push_back(nd);
    }
    for(auto a: ans){
        cout<<a<<" ";
    }

}

int main(){
    int testcase;

    testcase=1;
    ios_base::sync_with_stdio(0);

    while(testcase--){
        solve();
    }

}


#include<iostream>
#include<string>
#include<string.h>
#include<set>
#include<vector>
#include<queue>
#include<map>

using namespace std;

vector<int> ed[555555];
int expColor[555555];
int color[555555];

void solve(){
    int n,m;
    cin>>n>>m;

    priority_queue<pair<int,int> > pq;
    memset(color,0,sizeof(color));

    for(int i=0;i<m;i++){
        int t,f;
        cin>>t>>f;
        ed[f].push_back(t);
        ed[t].push_back(f);
    }

    for(int i=0;i<n;i++){
        int t;
        cin>>t;
        expColor[i+1]=t;
        pq.push(make_pair(-t,i+1));
    }

    vector<int> ans;

    //cout<<"hc";

    while(!pq.empty()){
        auto p = pq.top();
        pq.pop();

        int nd=p.second;
        int topic = -p.first;
        set<int> eds;
        for(auto e:ed[nd]){
            if(color[e]){
                if(expColor[e]==topic){
                    cout<<-1<<endl;
                    return;
                }
                if(expColor[e]<topic){
                    eds.insert(e);
                }
            }
        }
        if(eds.size()+1!=topic){
            cout<<-1<<endl;
            return;
        }
        ans.push_back(nd);
        color[nd]=true;
    }
    for(auto a: ans){
        cout<<a<<" ";
    }

}

int main(){
    int testcase;

    testcase=1;

    while(testcase--){
        solve();
    }

}


#include <iostream>
#include <vector>
#include <unordered_set>
#include <algorithm>

using namespace std;

typedef pair <int, int> ii;

const int N = 5e5 + 3;

int to[N], mark[N];
vector <int> a[N], ans;
ii topic[N];

int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int u, v;
    cin >> u >> v;
    a[u].push_back(v);
    a[v].push_back(u);
  }
  for (int i = 1; i <= n; i++) {
    cin >> to[i];
    topic[i].first = to[i];
    topic[i].second = i;
  }
  sort(topic + 1, topic + 1 + n);
  bool ok = true;
  for (int i = 1; i <= n && ok; i++) {
    int u = topic[i].second, cnt = to[u] - 1;
    unordered_set <int> ht;
    for (int j = 0; j < a[u].size(); j++) {
      int v = a[u][j];
      if (topic[i].first == to[v]) {
        ok = false;
        break;
      }
      if (ht.find(to[v]) == ht.end() && to[v] < to[u]) {
        cnt--;
        ht.insert(to[v]);
      }
    }
    if (cnt != 0) ok = false;
    ans.push_back(u);
  }
  if (!ok) cout << -1;
  else {
    for (int i = 0; i < ans.size(); i++) cout << ans[i] << " ";
  }
  return 0;
}


#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

typedef pair <int, int> ii;

const int N = 5e5 + 3;

int to[N];
vector <int> a[N], ans;
ii topic[N];

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int u, v;
    cin >> u >> v;
    a[u].push_back(v);
    a[v].push_back(u);
  }
  for (int i = 1; i <= n; i++) {
    cin >> topic[i].first;
    topic[i].second = i;
  }
  sort(topic + 1, topic + 1 + n);
  bool ok = true;
  for (int i = 1; i <= n && ok; i++) {
    int u = topic[i].second;
    priority_queue < int, vector <int>, greater <int> > heap;
    for (int j = 0; j < a[u].size(); j++) {
      int v = a[u][j];
      if (topic[i].first == to[v]) {
        ok = false;
        break;
      }
      if (to[v] != 0) heap.push(to[v]);
    }
    int pre = 0;
    while (!heap.empty() && pre + 1 == heap.top()) {
      pre = heap.top();
      while (!heap.empty() && pre == heap.top()) heap.pop();
    }
    pre++;
    if (pre != topic[i].first) {
      ok = false;
      break;
    }
    to[u] = pre;
    ans.push_back(u);
  }
  if (!ok) cout << -1;
  else {
    for (int i = 0; i < ans.size(); i++) cout << ans[i] << " ";
  }
  return 0;
}


#include <iostream>
#include <vector>
#include <queue>

using namespace std;

typedef pair <int, int> ii;

const int N = 5e5 + 3;

int to[N];
vector <int> a[N], ans;
ii topic[N];

int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int u, v;
    cin >> u >> v;
    a[u].push_back(v);
    a[v].push_back(u);
  }
  for (int i = 1; i <= n; i++) {
    cin >> topic[i].first;
    topic[i].second = i;
  }
  sort(topic + 1, topic + 1 + n);
  bool ok = true;
  for (int i = 1; i <= n && ok; i++) {
    int u = topic[i].second;
    priority_queue < int, vector <int>, greater <int> > heap;
    for (int j = 0; j < a[u].size(); j++) {
      int v = a[u][j];
      if (topic[i].first == to[v]) {
        ok = false;
        break;
      }
      if (to[v] != 0) heap.push(to[v]);
    }
    int pre = 0;
    while (!heap.empty() && pre + 1 == heap.top()) {
      pre = heap.top();
      while (!heap.empty() && pre == heap.top()) heap.pop();
    }
    pre++;
    if (pre != topic[i].first) {
      ok = false;
      break;
    }
    to[u] = pre;
    ans.push_back(u);
  }
  if (!ok) cout << -1;
  else {
    for (int i = 0; i < ans.size(); i++) cout << ans[i] << " ";
  }
  return 0;
}


#include <iostream>
#include <vector>
#include <unordered_set>
#include <algorithm>

using namespace std;

typedef pair <int, int> ii;

const int N = 5e5 + 3;

int to[N], mark[N];
vector <int> a[N], ans;
ii topic[N];

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int u, v;
    cin >> u >> v;
    a[u].push_back(v);
    a[v].push_back(u);
  }
  for (int i = 1; i <= n; i++) {
    cin >> to[i];
    topic[i].first = to[i];
    topic[i].second = i;
  }
  sort(topic + 1, topic + 1 + n);
  bool ok = true;
  for (int i = 1; i <= n && ok; i++) {
    int u = topic[i].second, cnt = to[u] - 1;
    unordered_set <int> ht;
    for (int j = 0; j < a[u].size(); j++) {
      int v = a[u][j];
      if (topic[i].first == to[v]) {
        ok = false;
        break;
      }
      if (ht.find(to[v]) == ht.end() && to[v] < to[u]) {
        cnt--;
        ht.insert(to[v]);
      }
    }
    if (cnt != 0) ok = false;
    ans.push_back(u);
  }
  if (!ok) cout << -1;
  else {
    for (int i = 0; i < ans.size(); i++) cout << ans[i] << " ";
  }
  return 0;
}


#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

typedef pair <int, int> ii;

const int N = 5e5 + 3;

int to[N];
vector <int> a[N], ans;
ii topic[N];

int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int u, v;
    cin >> u >> v;
    a[u].push_back(v);
    a[v].push_back(u);
  }
  for (int i = 1; i <= n; i++) {
    cin >> topic[i].first;
    topic[i].second = i;
  }
  sort(topic + 1, topic + 1 + n);
  bool ok = true;
  for (int i = 1; i <= n && ok; i++) {
    int u = topic[i].second;
    priority_queue < int, vector <int>, greater <int> > heap;
    for (int j = 0; j < a[u].size(); j++) {
      int v = a[u][j];
      if (topic[i].first == to[v]) {
        ok = false;
        break;
      }
      if (to[v] != 0) heap.push(to[v]);
    }
    int pre = 0;
    while (!heap.empty() && pre + 1 == heap.top()) {
      pre = heap.top();
      while (!heap.empty() && pre == heap.top()) heap.pop();
    }
    pre++;
    if (pre != topic[i].first) {
      ok = false;
      break;
    }
    to[u] = pre;
    ans.push_back(u);
  }
  if (!ok) cout << -1;
  else {
    for (int i = 0; i < ans.size(); i++) cout << ans[i] << " ";
  }
  return 0;
}


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

int main()
{
	int n,m; cin >> n >> m;
	vector<int> v[n+1];
	for(int i = 0; i < m; i++){
		int x, y; cin >> x >> y;
		if(x < y) v[x].push_back(y);
			else v[y].push_back(x);
	}
	vector<pair<int,int>> a(n+1);
	for(int i = 1; i <= n; i++){
		int x; cin >> x;
		a[i] = make_pair(x,i);
	}
	int flag = 0;
	for(int i = 1; i < n+1; i++){
		if(v[i].size() > 0){
			int minc = a[i].first;
			unordered_map<int,int> up;
			for(int j = 0; j < v[i].size(); j++){
					if(a[i].first == a[v[i][j]].first) { flag = 1; break; }
					if(a[v[i][j]].first < minc)
					up[a[v[i][j]].first]++;
			}
			//if(up.size() != minc-1) { flag = 1; break; }
		}
		if(flag == 1) break;
	}
	sort(a.begin(),a.end());
	if(flag == 1) { cout << "-1" << endl; }
	else{
	for(int i = 1; i <= n; i++) cout << a[i].second << " ";
	cout << endl; }
    return 0;
}


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

int main()
{
	int n,m; cin >> n >> m;
	vector<int> v[n+1];
	for(int i = 0; i < m; i++){
		int x, y; cin >> x >> y;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	vector<pair<int,int>> a(n+1);
	int flag = 0;
	for(int i = 1; i <= n; i++){
		int x; cin >> x;
		if(x > n) { flag = 1; }
		a[i] = make_pair(x,i);
	}
	vector<int> ans[n+1];
	if(flag == 0) {
	for(int i = 1; i < n+1; i++){
		if(v[i].size() > 0){
			int minc = a[i].first;
			unordered_map<int,int> up;
			for(int j = 0; j < v[i].size(); j++){
					if(a[i].first == a[v[i][j]].first) { flag = 1; break; }
					if(a[v[i][j]].first < minc)
					up[a[v[i][j]].first]++;
			}
			if(up.size() != minc-1) { flag = 1; break; }
			ans[minc].push_back(i);
		}
		if(flag == 1) break;
	}
	}
	if(flag == 1) { cout << "-1" << endl; }
	else{

	for(int i = 1; i <= n; i++){
		for(int j = 0; j < ans[i].size(); j++) cout << ans[i][j] << " ";
	}
	cout << endl; }
    return 0;
}


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

int main()
{
	int n,m; cin >> n >> m;
	vector<int> v[n+1];
	for(int i = 0; i < m; i++){
		int x, y; cin >> x >> y;
		if(x < y) v[x].push_back(y);
			else v[y].push_back(x);
	}
	vector<pair<int,int>> a(n+1);
	for(int i = 1; i <= n; i++){
		int x; cin >> x;
		a[i] = make_pair(x,i);
	}
	int flag = 0;
	for(int i = 1; i < n+1; i++){
		if(v[i].size() > 0){
			for(int j = 0; j < v[i].size(); j++){
					if(a[i].first == a[v[i][j]].first) { flag = 1; break; }
			}
		}
		if(flag == 1) break;
	}
	sort(a.begin(),a.end());
	if(flag == 1) { cout << "-1" << endl; }
	else{
	for(int i = 1; i <= n; i++) cout << a[i].second << " ";
	cout << endl; }
    return 0;
}


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

int main()
{
	int n,m; cin >> n >> m;
	vector<int> v[n+1];
	for(int i = 0; i < m; i++){
		int x, y; cin >> x >> y;
		if(x < y) v[x].push_back(y);
			else v[y].push_back(x);
	}
	vector<pair<int,int>> a(n+1);
	for(int i = 1; i <= n; i++){
		int x; cin >> x;
		a[i] = make_pair(x,i);
	}
	int flag = 0;
	for(int i = 1; i < n+1; i++){
		if(v[i].size() > 0){
			int minc = a[i].first;
			unordered_map<int,int> up;
			for(int j = 0; j < v[i].size(); j++){
					if(a[i].first == a[v[i][j]].first) { flag = 1; break; }
					if(a[v[i][j]].first < minc)
					up[a[v[i][j]].first]++;
			}
			if(up.size() != minc-1) { flag = 1; break; }
		}
		if(flag == 1) break;
	}
	sort(a.begin(),a.end());
	if(flag == 1) { cout << "-1" << endl; }
	else{
	for(int i = 1; i <= n; i++) cout << a[i].second << " ";
	cout << endl; }
    return 0;
}


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

int main()
{
	int n,m; cin >> n >> m;
	vector<int> v[n+1];
	for(int i = 0; i < m; i++){
		int x, y; cin >> x >> y;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	vector<pair<int,int>> a(n+1);
	for(int i = 1; i <= n; i++){
		int x; cin >> x;
		a[i] = make_pair(x,i);
	}
	int flag = 0;
	for(int i = 1; i < n+1; i++){
		if(v[i].size() > 0){
			int minc = a[i].first;
			unordered_map<int,int> up;
			for(int j = 0; j < v[i].size(); j++){
					if(a[i].first == a[v[i][j]].first) { flag = 1; break; }
					if(a[v[i][j]].first < minc)
					up[a[v[i][j]].first]++;
			}
			if(up.size() != minc-1) { flag = 1; break; }
		}
		if(flag == 1) break;
	}
	if(flag == 1) { cout << "-1" << endl; }
	else{
	sort(a.begin(),a.end());
	for(int i = 1; i <= n; i++) cout << a[i].second << " ";
	cout << endl; }
    return 0;
}


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

int main()
{
	int n,m; cin >> n >> m;
	vector<int> v[n+1];
	for(int i = 0; i < m; i++){
		int x, y; cin >> x >> y;
		if(x < y) v[x].push_back(y);
			else v[y].push_back(x);
	}
	vector<pair<int,int>> a(n+1);
	int mincol = 99999;
	for(int i = 1; i <= n; i++){
		int x; cin >> x;
		if(x < mincol) mincol = x;
		a[i] = make_pair(x,i);
	}
	int flag = 0;
	for(int i = 1; i < n+1; i++){
		if(v[i].size() > 0){
			int minc = a[i].first;
			for(int j = 0; j < v[i].size(); j++){
					if(a[i].first == a[v[i][j]].first) { flag = 1; break; }
					minc = min(minc, a[v[i][j]].first);
			}
			if(minc != mincol) { flag = 1; break; }
		}
		if(flag == 1) break;
	}
	sort(a.begin(),a.end());
	if(flag == 1) { cout << "-1" << endl; }
	else{
	for(int i = 1; i <= n; i++) cout << a[i].second << " ";
	cout << endl; }
    return 0;
}


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

int main()
{
	int n,m; cin >> n >> m;
	vector<int> v[n+1];
	for(int i = 0; i < m; i++){
		int x, y; cin >> x >> y;
		if(x < y) v[x].push_back(y);
			else v[y].push_back(x);
	}
	vector<pair<int,int>> a(n+1);
	for(int i = 1; i <= n; i++){
		int x; cin >> x;
		a[i] = make_pair(x,i);
	}
	int flag = 0;
	for(int i = 1; i < n+1; i++){
		if(v[i].size() > 0){
			int minc = a[i].first;
			for(int j = 0; j < v[i].size(); j++){
					if(a[i].first == a[v[i][j]].first) { flag = 1; break; }
					minc = min(minc, a[v[i][j]].first);
			}
			if(minc != 1) { flag = 1; break; }
		}
		if(flag == 1) break;
	}
	sort(a.begin(),a.end());
	if(flag == 1) { cout << "-1" << endl; }
	else{
	for(int i = 1; i <= n; i++) cout << a[i].second << " ";
	cout << endl; }
    return 0;
}


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

int main()
{
	int n,m; cin >> n >> m;
	vector<int> v[n+1];
	for(int i = 0; i < m; i++){
		int x, y; scanf("%d %d", &x, &y);
		v[x].push_back(y);
		v[y].push_back(x);
	}
	vector<pair<int,int>> a(n+1);
	int flag = 0;
	for(int i = 1; i <= n; i++){
		int x; scanf("%d", &x);
		if(x > n) { flag = 1; }
		a[i] = make_pair(x,i);
	}
	vector<int> ans[n+1];
	if(flag == 0) {
	for(int i = 1; i < n+1; i++){
			int minc = a[i].first;
			unordered_map<int,int> up;
			for(int j = 0; j < v[i].size(); j++){
					if(a[i].first == a[v[i][j]].first) { flag = 1; break; }
					if(a[v[i][j]].first < minc)
					up[a[v[i][j]].first]++;
			}
			if(up.size() != minc-1) { flag = 1; break; }
			ans[minc].push_back(i);
		if(flag == 1) break;
	}
	}
	if(flag == 1) { cout << "-1" << endl; }
	else{
	for(int i = 1; i <= n; i++){
		for(int j = 0; j < ans[i].size(); j++) printf("%d%c",ans[i][j],' ');
	}
	printf("%c", '\n'); }
	system("pause");
    return 0;
}
*/

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

int main()
{
	int n,m; cin >> n >> m;
	vector<int> v[n+1];
	for(int i = 0; i < m; i++){
		int x, y; scanf("%d %d", &x, &y);
		v[x].push_back(y);
		v[y].push_back(x);
	}
	vector<pair<int,int>> a(n+1);
	int flag = 0;
	for(int i = 1; i <= n; i++){
		int x; scanf("%d", &x);
		if(x > n) { flag = 1; }
		a[i] = make_pair(x,i);
	}
	if(flag == 0) {
	for(int i = 1; i < n+1; i++){
		if(v[i].size() > 0){
			int minc = a[i].first;
			unordered_map<int,int> up;
			for(int j = 0; j < v[i].size(); j++){
					if(a[i].first == a[v[i][j]].first) { flag = 1; break; }
					if(a[v[i][j]].first < minc)
					up[a[v[i][j]].first]++;
			}
			if(up.size() != minc-1) { flag = 1; break; }
		}
		if(flag == 1) break;
	}
	}
	if(flag == 1) { cout << "-1" << endl; }
	else{
	sort(a.begin(),a.end());
	for(int i = 1; i <= n; i++) printf("%d%c",a[i].second, ' ');
	cout << endl; }
    return 0;
}


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

int main()
{
	int n,m; cin >> n >> m;
	vector<int> v[n+1];
	for(int i = 0; i < m; i++){
		int x, y; scanf("%d %d", &x, &y);
		v[x].push_back(y);
		v[y].push_back(x);
	}
	vector<pair<int,int>> a(n+1);
	int flag = 0;
	for(int i = 1; i <= n; i++){
		int x; scanf("%d", &x);
		if(x > n) { flag = 1; }
		a[i] = make_pair(x,i);
	}
	vector<int> ans[n+1];
	if(flag == 0) {
	for(int i = 1; i < n+1; i++){
			int minc = a[i].first;
			unordered_map<int,int> up;
			for(int j = 0; j < v[i].size(); j++){
					if(a[i].first == a[v[i][j]].first) { flag = 1; break; }
					if(a[v[i][j]].first < minc)
					up[a[v[i][j]].first]++;
			}
			if(up.size() != minc-1) { flag = 1; break; }
			ans[minc].push_back(i);
		if(flag == 1) break;
	}
	}
	if(flag == 1) { cout << "-1" << endl; }
	else{
	for(int i = 1; i <= n; i++){
		for(int j = 0; j < ans[i].size(); j++) printf("%d%c",ans[i][j],' ');
	}
	printf("%c", '\n'); }
	system("pause");
    return 0;
}
*/

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

int main()
{
	int n,m; cin >> n >> m;
	vector<int> v[n+1];
	for(int i = 0; i < m; i++){
		int x, y; scanf("%d %d", &x, &y);
		v[x].push_back(y);
		v[y].push_back(x);
	}
	vector<pair<int,int>> a(n+1);
	int flag = 0;
	for(int i = 1; i <= n; i++){
		int x; scanf("%d", &x);
		if(x > n) { flag = 1; }
		a[i] = make_pair(x,i);
	}
	if(flag == 0) {
	for(int i = 1; i < n+1; i++){
			int minc = a[i].first;
			unordered_map<int,int> up;
			for(int j = 0; j < v[i].size(); j++){
					if(a[i].first == a[v[i][j]].first) { flag = 1; break; }
					if(a[v[i][j]].first < minc)
					up[a[v[i][j]].first]++;
			}
			if(up.size() != minc-1) { flag = 1; break; }
		if(flag == 1) break;
	}
	}
	if(flag == 1) { cout << "-1" << endl; }
	else{
	sort(a.begin(),a.end());
	for(int i = 1; i <= n; i++) printf("%d%c",a[i].second, ' ');
	cout << endl; }
    return 0;
}


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

int main()
{
	int n,m; cin >> n >> m;
	vector<int> v[n+1];
	for(int i = 0; i < m; i++){
		int x, y; cin >> x >> y;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	vector<pair<int,int>> a(n+1);
	for(int i = 1; i <= n; i++){
		int x; cin >> x;
		a[i] = make_pair(x,i);
	}
	int flag = 0;
	for(int i = 1; i < n+1; i++){
		if(v[i].size() > 0){
			int minc = a[i].first;
			unordered_map<int,int> up;
			for(int j = 0; j < v[i].size(); j++){
					if(a[i].first == a[v[i][j]].first) { flag = 1; break; }
					if(a[v[i][j]].first < minc)
					up[a[v[i][j]].first]++;
			}
			if(up.size() != minc-1) { flag = 1; break; }
		}
		if(flag == 1) break;
	}
	sort(a.begin(),a.end());
	if(flag == 1) { cout << "-1" << endl; }
	else{
	for(int i = 1; i <= n; i++) cout << a[i].second << " ";
	cout << endl; }
    return 0;
}


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

int main()
{
	int n,m; cin >> n >> m;
	vector<int> v[n+1];
	for(int i = 0; i < m; i++){
		int x, y; scanf("%d %d", &x, &y);
		v[x].push_back(y);
		v[y].push_back(x);
	}
	vector<pair<int,int>> a(n+1);
	int flag = 0;
	for(int i = 1; i <= n; i++){
		int x; scanf("%d", &x);
		if(x > n) { flag = 1; }
		a[i] = make_pair(x,i);
	}
	vector<int> ans[n+1];
	if(flag == 0) {
	for(int i = 1; i < n+1; i++){
			int minc = a[i].first;
			unordered_map<int,int> up;
			for(int j = 0; j < v[i].size(); j++){
					if(a[i].first == a[v[i][j]].first) { flag = 1; break; }
					if(a[v[i][j]].first < minc)
					up[a[v[i][j]].first]++;
			}
			if(up.size() != minc-1) { flag = 1; break; }
			ans[minc].push_back(i);
		if(flag == 1) break;
	}
	}
	if(flag == 1) { cout << "-1" << endl; }
	else{
	for(int i = 1; i <= n; i++){
		for(int j = 0; j < ans[i].size(); j++) printf("%d%c",ans[i][j],' ');
	}
	printf("%c", '\n'); }
    return 0;
}


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

int main()
{
	int n,m; cin >> n >> m;
	vector<int> v[n+1];
	for(int i = 0; i < m; i++){
		int x, y; cin >> x >> y;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	vector<pair<int,int>> a(n+1);
	int flag = 0;
	for(int i = 1; i <= n; i++){
		int x; cin >> x;
		if(x > n) { flag = 1; }
		a[i] = make_pair(x,i);
	}
	if(flag == 0) {
	for(int i = 1; i < n+1; i++){
		if(v[i].size() > 0){
			int minc = a[i].first;
			unordered_map<int,int> up;
			for(int j = 0; j < v[i].size(); j++){
					if(a[i].first == a[v[i][j]].first) { flag = 1; break; }
					if(a[v[i][j]].first < minc)
					up[a[v[i][j]].first]++;
			}
			if(up.size() != minc-1) { flag = 1; break; }
		}
		if(flag == 1) break;
	}
	}
	if(flag == 1) { cout << "-1" << endl; }
	else{
	sort(a.begin(),a.end());
	for(int i = 1; i <= n; i++) cout << a[i].second << " ";
	cout << endl; }
    return 0;
}


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

int main()
{
	int n,m; cin >> n >> m;
	vector<int> v[n+1];
	for(int i = 0; i < m; i++){
		int x, y; cin >> x >> y;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	vector<pair<int,int>> a(n+1);
	int flag = 0;
	for(int i = 1; i <= n; i++){
		int x; cin >> x;
		if(x > n) { flag = 1; }
		a[i] = make_pair(x,i);
	}
	vector<int> ans[n+1];
	if(flag == 0) {
	for(int i = 1; i < n+1; i++){
			int minc = a[i].first;
			unordered_map<int,int> up;
			for(int j = 0; j < v[i].size(); j++){
					if(a[i].first == a[v[i][j]].first) { flag = 1; break; }
					if(a[v[i][j]].first < minc)
					up[a[v[i][j]].first]++;
			}
			if(up.size() != minc-1) { flag = 1; break; }
			ans[minc].push_back(i);
		if(flag == 1) break;
	}
	}
	if(flag == 1) { cout << "-1" << endl; }
	else{

	for(int i = 1; i <= n; i++){
		for(int j = 0; j < ans[i].size(); j++) cout << ans[i][j] << " ";
	}
	cout << endl; }
    return 0;
}


#include<bits/stdc++.h>
#define mes(a, b)  memset(a, b, sizeof a)
#define pb push_back
typedef unsigned long long int ull;
typedef long long int ll;
const int    maxn = 5e5 + 20;
const int    maxm = 1e5 + 10;
const ll     mod  = 998244353;
const ll     INF  = 1e18 + 100;
const int    inf  = 0x3f3f3f3f;
const double pi   = acos(-1.0);
const double eps  = 1e-9;
using namespace std;
int ans[maxn],vis[maxn],rk[maxn];
set<int>mp[maxn];
struct node{
	int sum,id;
	bool operator<(const node &a)const{
		return sum < a.sum;
	}
}a[maxn];
int main(){
	int n,m;scanf("%d %d",&n,&m);
	for(int i = 1;i <= m;i++) {
		int u,v;scanf("%d %d",&u,&v);
		mp[u].insert(v);mp[v].insert(u);
	}
	for(int i = 1;i <= n;i++) scanf("%d",&a[i].sum),a[i].id = i;
	int tot = 0;
	int flag = 0;
	for(int i = 1;i <= n;i++){
		for(auto it:mp[i]){
			if(a[it].sum == a[i].sum) flag = 1;
		}
	}
	if(flag == 1){
		puts("-1");
		return 0;
	}
	sort(a + 1,a + 1 + n);
	for(int i = 1;i <= n;i++) rk[a[i].sum] = a[i].id;
	queue<int>q;
	for(int i = 1;i <= n;i++){
		if(vis[a[i].id]) continue;
		q.push(a[i].id);ans[++tot] = a[i].id;vis[a[i].id] = 1;
		while(!q.empty()){
			int u = q.front();q.pop();
			std::vector<int> v;
			for(auto it : mp[u]){
				if(vis[a[it].id]) continue;
				if(a[rk[it]].sum == a[rk[u]].sum + 1) {
					ans[++tot] = a[rk[it]].id;vis[a[rk[it]].id] = 1;
					q.push(it);
					v.push_back(it);
				}
			}
			for(auto it : v) mp[it].erase(u),mp[u].erase(it);
		}
	}
	if(tot != n) puts("-1");
	else for(int i = 1;i <= n;i++) printf("%d ",ans[i]);
}


#include<bits/stdc++.h>
#define mes(a, b)  memset(a, b, sizeof a)
#define pb push_back
typedef unsigned long long int ull;
typedef long long int ll;
const int    maxn = 1e5 + 20;
const int    maxm = 1e5 + 10;
const ll     mod  = 998244353;
const ll     INF  = 1e18 + 100;
const int    inf  = 0x3f3f3f3f;
const double pi   = acos(-1.0);
const double eps  = 1e-9;
using namespace std;
int ans[maxn],vis[maxn];
std::vector<int> mp[maxn];
int a[maxn];
int main(){
	int n,m;scanf("%d %d",&n,&m);
	for(int i = 1;i <= m;i++) {
		int u,v;scanf("%d %d",&u,&v);
		mp[u].push_back(v);mp[v].push_back(u);
	}
	for(int i = 1;i <= n;i++) scanf("%d",&a[i]);
	int tot = 0;
	int flag = 0;
	for(int i = 1;i <= n;i++){
		for(auto it:mp[i]){
			if(a[it] == a[i]) flag = 1;
		}
	}
	if(flag == 1){
		puts("-1");
		return 0;
	}
	priority_queue<int, vector<int>, greater<int> > q;
	for(int i = 1;i <= n;i++){
		if(vis[i]) continue;
		ans[++tot] = i;vis[i] = a[i];
		q.push(i);
		while(!q.empty()){
			int u = q.top();q.pop();
			for(auto it : mp[u]){
				if(vis[it]) continue;
				if(a[it] > a[u]) ans[++tot] = it,vis[it] = a[it],q.push(it);
			}
		}
	}
	for(int i = 1;i <= n;i++) if(ans[i]  == 0 ){puts("-1");return 0;}
	for(int i = 1;i <= tot;i++) printf("%d ",ans[i]);

}


#include<bits/stdc++.h>
#define mes(a, b)  memset(a, b, sizeof a)
#define pb push_back
typedef unsigned long long int ull;
typedef long long int ll;
const int    maxn = 1e6 + 20;
const int    maxm = 1e5 + 10;
const ll     mod  = 998244353;
const ll     INF  = 1e18 + 100;
const int    inf  = 0x3f3f3f3f;
const double pi   = acos(-1.0);
const double eps  = 1e-9;
using namespace std;
int ans[maxn],vis[maxn];
std::vector<int> mp[maxn];
struct node{
	int sum,id;
	bool operator<(const node &a)const{
		return sum < a.sum;
	}
}a[maxn];
int main(){
	int n,m;scanf("%d %d",&n,&m);
	for(int i = 1;i <= m;i++) {
		int u,v;scanf("%d %d",&u,&v);
		mp[u].push_back(v);mp[v].push_back(u);
	}
	for(int i = 1;i <= n;i++) scanf("%d",&a[i].sum),a[i].id = i;
	int tot = 0;
	int flag = 0;
	for(int i = 1;i <= n;i++){
		for(auto it:mp[i]){
			if(a[it].sum == a[i].sum) flag = 1;
		}
	}
	if(flag == 1){
		puts("-1");
		return 0;
	}
	sort(a + 1,a + 1 + n);
	queue<int>q;
	for(int i = 1;i <= n;i++){
		if(vis[a[i].id]) continue;
		q.push(a[i].id);ans[++tot] = a[i].id;vis[a[i].id] = 1;
		while(!q.empty()){
			int u = q.front();q.pop();
			for(auto it : mp[u]){
				if(vis[a[it].id]) continue;
		//		printf("sum = %d %d\n",a[a[it].id].sum,a[a[u].id].sum);
				if(a[a[it].id].sum == a[a[u].id].sum + 1) ans[++tot] = a[it].id,vis[a[it].id] = 1,q.push(a[it].id);
			}
		}
	}
	if(tot != n) puts("-1");
	else for(int i = 1;i <= n;i++) printf("%d ",ans[i]);
}


#include<bits/stdc++.h>
#define mes(a, b)  memset(a, b, sizeof a)
#define pb push_back
typedef unsigned long long int ull;
typedef long long int ll;
const int    maxn = 1e5 + 20;
const int    maxm = 1e5 + 10;
const ll     mod  = 998244353;
const ll     INF  = 1e18 + 100;
const int    inf  = 0x3f3f3f3f;
const double pi   = acos(-1.0);
const double eps  = 1e-9;
using namespace std;
int ans[maxn],vis[maxn];
std::vector<int> mp[maxn];
int a[maxn];
int main(){
	int n,m;scanf("%d %d",&n,&m);
	for(int i = 1;i <= m;i++) {
		int u,v;scanf("%d %d",&u,&v);
		mp[u].push_back(v);mp[v].push_back(u);
	}
	for(int i = 1;i <= n;i++) scanf("%d",&a[i]);
	int tot = 0;
	int flag = 0;
	for(int i = 1;i <= n;i++){
		for(auto it:mp[i]){
			if(a[it] == a[i]) flag = 1;
		}
	}
	if(flag == 1){
		puts("-1");
		return 0;
	}
	priority_queue<int, vector<int>, greater<int> > q;
	for(int i = 1;i <= n;i++){
		if(a[i]== 1){
			ans[++tot] = i;vis[i] = a[i];
			q.push(i);
		}
	}
	while(!q.empty()){
		int u = q.top();q.pop();
		for(auto it : mp[u]){
			if(vis[it]) continue;
			if(a[it] > a[u]) ans[++tot] = it,vis[it] = a[it],q.push(it);
		}
	}
	for(int i = 1;i <= n;i++) if(ans[i]  == 0 ){puts("-1");return 0;}
	for(int i = 1;i <= tot;i++) printf("%d ",ans[i]);

}


#include<bits/stdc++.h>
#define mes(a, b)  memset(a, b, sizeof a)
#define pb push_back
typedef unsigned long long int ull;
typedef long long int ll;
const int    maxn = 1e6 + 20;
const int    maxm = 1e5 + 10;
const ll     mod  = 998244353;
const ll     INF  = 1e18 + 100;
const int    inf  = 0x3f3f3f3f;
const double pi   = acos(-1.0);
const double eps  = 1e-9;
using namespace std;
int ans[maxn],vis[maxn];
std::vector<int> mp[maxn];
int a[maxn];
int main(){
	int n,m;scanf("%d %d",&n,&m);
	for(int i = 1;i <= m;i++) {
		int u,v;scanf("%d %d",&u,&v);
		mp[u].push_back(v);mp[v].push_back(u);
	}
	for(int i = 1;i <= n;i++) scanf("%d",&a[i]);
	int tot = 0;
	int flag = 0;
	for(int i = 1;i <= n;i++){
		for(auto it:mp[i]){
			if(a[it] == a[i]) flag = 1;
		}
	}
	if(flag == 1){
		puts("-1");
		return 0;
	}
	priority_queue<int, vector<int>, greater<int> > q;
	for(int i = 1;i <= n;i++){
		if(a[i]== 1){
			ans[++tot] = i;vis[i] = 1;
			q.push(i);
		}
	}
	while(!q.empty()){
		int u = q.top();q.pop();
		for(auto it : mp[u]){
			if(vis[it]) continue;
			if(a[it] == a[u] + 1) ans[++tot] = it,vis[it] = 1,q.push(it);
		}
	}
	if(tot != n) puts("-1");
	else for(int i = 1;i <= n;i++) printf("%d ",ans[i]);

}


#include<bits/stdc++.h>
#define mes(a, b)  memset(a, b, sizeof a)
#define pb push_back
typedef unsigned long long int ull;
typedef long long int ll;
const int    maxn = 1e6 + 20;
const int    maxm = 1e5 + 10;
const ll     mod  = 998244353;
const ll     INF  = 1e18 + 100;
const int    inf  = 0x3f3f3f3f;
const double pi   = acos(-1.0);
const double eps  = 1e-9;
using namespace std;
int ans[maxn],vis[maxn];
std::vector<int> mp[maxn];
struct node{
	int sum,id;
	bool operator<(const node &a)const{
		return sum < a.sum;
	}
}a[maxn];
int main(){
	int n,m;scanf("%d %d",&n,&m);
	for(int i = 1;i <= m;i++) {
		int u,v;scanf("%d %d",&u,&v);
		mp[u].push_back(v);mp[v].push_back(u);
	}
	for(int i = 1;i <= n;i++) scanf("%d",&a[i].sum),a[i].id = i;
	int tot = 0;
	int flag = 0;
	for(int i = 1;i <= n;i++){
		for(auto it:mp[i]){
			if(a[it].sum == a[i].sum) flag = 1;
		}
	}
	if(flag == 1){
		puts("-1");
		return 0;
	}
	sort(a + 1,a + 1 + n);
	queue<int>q;
	for(int i = 1;i <= n;i++){
		if(vis[a[i].id]) continue;
		q.push(a[i].id);ans[++tot] = a[i].id;vis[a[i].id] = 1;
		while(!q.empty()){
			int u = q.front();q.pop();
			for(auto it : mp[u]){
				if(vis[a[it].id]) continue;
		//		printf("sum = %d %d\n",a[a[it].id].sum,a[a[u].id].sum);
				if(a[a[it].id].sum == a[a[u].id].sum + 1) ans[++tot] = a[a[it].id].id,vis[a[a[it].id].id] = 1,q.push(a[a[it].id].id);
			}
		}
	}
	if(tot != n) puts("-1");
	else for(int i = 1;i <= n;i++) printf("%d ",ans[i]);
}


#include<bits/stdc++.h>
#define mes(a, b)  memset(a, b, sizeof a)
#define pb push_back
typedef unsigned long long int ull;
typedef long long int ll;
const int    maxn = 1e6 + 20;
const int    maxm = 1e5 + 10;
const ll     mod  = 998244353;
const ll     INF  = 1e18 + 100;
const int    inf  = 0x3f3f3f3f;
const double pi   = acos(-1.0);
const double eps  = 1e-9;
using namespace std;
int ans[maxn],vis[maxn];
std::vector<int> mp[maxn];
struct node{
	int sum,id;
	bool operator<(const node &a)const{
		return sum < a.sum;
	}
}a[maxn];
int main(){
	int n,m;scanf("%d %d",&n,&m);
	for(int i = 1;i <= m;i++) {
		int u,v;scanf("%d %d",&u,&v);
		mp[u].push_back(v);mp[v].push_back(u);
	}
	for(int i = 1;i <= n;i++) scanf("%d",&a[i].sum),a[i].id = i;
	int tot = 0;
	int flag = 0;
	for(int i = 1;i <= n;i++){
		for(auto it:mp[i]){
			if(a[it].sum == a[i].sum) flag = 1;
		}
	}
	if(flag == 1){
		puts("-1");
		return 0;
	}
	sort(a + 1,a + 1 + n);
	queue<int>q;
	for(int i = 1;i <= n;i++){
		if(vis[a[i].id]) continue;
		q.push(a[i].id);ans[++tot] = a[i].id;vis[a[i].id] = 1;
		while(!q.empty()){
			int u = q.front();q.pop();
			for(auto it : mp[u]){
				if(vis[a[it].id]) continue;
		//		printf("sum = %d %d\n",a[a[it].id].sum,a[a[u].id].sum);
				if(a[a[it].id].sum == a[u].sum + 1) ans[++tot] = a[a[it].id].id,vis[a[a[it].id].id] = 1,q.push(a[a[it].id].id);
			}
		}
	}
	if(tot != n) puts("-1");
	else for(int i = 1;i <= n;i++) printf("%d ",ans[i]);
}


#include<bits/stdc++.h>
#define mes(a, b)  memset(a, b, sizeof a)
#define pb push_back
typedef unsigned long long int ull;
typedef long long int ll;
const int    maxn = 5e5 + 20;
const int    maxm = 1e5 + 10;
const ll     mod  = 998244353;
const ll     INF  = 1e18 + 100;
const int    inf  = 0x3f3f3f3f;
const double pi   = acos(-1.0);
const double eps  = 1e-9;
using namespace std;
std::vector<int> mp[maxn];
int w[maxn],s[maxn],vis[maxn];
std::vector<int> ans;
int main(){
	int n,m;scanf("%d %d",&n,&m);
	for(int i = 1;i <= m;i++){
		int u,v;scanf("%d %d",&u,&v);
		mp[u].push_back(v);mp[v].push_back(u);
	}
	for(int i = 1;i <= n;i++){
		scanf("%d",&w[i]);s[i] = 1;
	}
	int flag = 0;
	for(int i = 1;i <= n;i++){
		for(auto it:mp[i]){
			if(w[it] == w[i] && w[i] == 1) flag = 1;
		}
	}
	if(flag == 1){
		puts("-1");
		return 0;
	}
	queue<int>q;while(!q.empty()) q.pop();
	for(int i = 1;i <= n;i++){
		if(w[i] == s[i]) q.push(i),vis[i] = 1;
	}
	while(!q.empty()){
		int u = q.front();q.pop();ans.push_back(u);
		for(auto it : mp[u]){
			if(vis[it]) continue;
			if(s[it] < s[u] + 1) s[it] = s[u] + 1;
			if(w[it] == s[it]) vis[it] = 1,q.push(it);
		}
	}
	if((int)ans.size() == n){
		for(auto it :ans) printf("%d ",it);
	}
	else puts("-1");
}


#include<bits/stdc++.h>
#define mes(a, b)  memset(a, b, sizeof a)
#define pb push_back
typedef unsigned long long int ull;
typedef long long int ll;
const int    maxn = 5e5 + 20;
const int    maxm = 1e5 + 10;
const ll     mod  = 998244353;
const ll     INF  = 1e18 + 100;
const int    inf  = 0x3f3f3f3f;
const double pi   = acos(-1.0);
const double eps  = 1e-9;
using namespace std;
int ans[maxn],vis[maxn],rk[maxn];
set<int>mp[maxn];
struct node{
	int sum,id;
	bool operator<(const node &a)const{
		return sum < a.sum;
	}
}a[maxn];
int main(){
	int n,m;scanf("%d %d",&n,&m);
	for(int i = 1;i <= m;i++) {
		int u,v;scanf("%d %d",&u,&v);
		mp[u].insert(v);mp[v].insert(u);
	}
	for(int i = 1;i <= n;i++) scanf("%d",&a[i].sum),a[i].id = i;
	int tot = 0;
	int flag = 0;
	for(int i = 1;i <= n;i++){
		for(auto it:mp[i]){
			if(a[it].sum == a[i].sum) flag = 1;
		}
	}
	if(flag == 1){
		puts("-1");
		return 0;
	}
	sort(a + 1,a + 1 + n);
	for(int i = 1;i <= n;i++) rk[a[i].sum] = a[i].id;
	queue<int>q;
	for(int i = 1;i <= n;i++){
		if(vis[a[i].id]) continue;
		q.push(a[i].id);ans[++tot] = a[i].id;vis[a[i].id] = 1;
		while(!q.empty()){
			int u = q.front();q.pop();
			std::vector<int> v;
			for(auto it : mp[u]){
				if(vis[a[it].id]) continue;
				if(a[rk[it]].sum == a[rk[u]].sum + 1) {
					ans[++tot] = a[rk[it]].id;vis[a[rk[it]].id] = 1;
					q.push(a[rk[it]].id);
					v.push_back(it);
				}
			}
			for(auto it : v) mp[it].erase(u),mp[u].erase(it);
		}
	}
	if(tot != n) puts("-1");
	else for(int i = 1;i <= n;i++) printf("%d ",ans[i]);
}


#include<bits/stdc++.h>
#define mes(a, b)  memset(a, b, sizeof a)
#define pb push_back
typedef unsigned long long int ull;
typedef long long int ll;
const int    maxn = 5e5 + 20;
const int    maxm = 1e5 + 10;
const ll     mod  = 998244353;
const ll     INF  = 1e18 + 100;
const int    inf  = 0x3f3f3f3f;
const double pi   = acos(-1.0);
const double eps  = 1e-9;
using namespace std;
std::vector<int> mp[maxn];
int w[maxn],s[maxn],vis[maxn],has[maxn];
set<int>ss[maxn];
std::vector<int> ans;
int main(){
	int n,m;scanf("%d %d",&n,&m);
	for(int i = 1;i <= m;i++){
		int u,v;scanf("%d %d",&u,&v);
		mp[u].push_back(v);mp[v].push_back(u);
	}
	for(int i = 1;i <= n;i++){
		scanf("%d",&w[i]);s[i] = 1;
	}
	for(int i = 1;i <= n;i++){
		for(auto it : mp[i]){
			if(w[it] < w[i]) ss[i].insert(w[it]);else ss[it].insert(w[i]);
			if(w[it] == w[i]) {puts("-1");return 0;}
		}
	}
	for(int i = 1;i <= n;i++) {
		if((int)ss[i].size() + 1 < w[i]){
			puts("-1");
			return 0;
		}
	}
	queue<int>q;while(!q.empty()) q.pop();
	for(int i = 1;i <= n;i++){
		if(w[i] == s[i]) q.push(i),vis[i] = 1;
	}
	while(!q.empty()){
		int u = q.front();q.pop();ans.push_back(u);
		for(auto it : mp[u]){
			if(vis[it]) continue;
			if(s[it] < s[u] + 1) s[it] = s[u] + 1;
			if(w[it] == s[it]) vis[it] = 1,q.push(it);
		}
	}
	if((int)ans.size() == n){
		for(auto it :ans) printf("%d ",it);
	}
	else puts("-1");
}


#include<bits/stdc++.h>
#define mes(a, b)  memset(a, b, sizeof a)
#define pb push_back
typedef unsigned long long int ull;
typedef long long int ll;
const int    maxn = 5e5 + 20;
const int    maxm = 1e5 + 10;
const ll     mod  = 998244353;
const ll     INF  = 1e18 + 100;
const int    inf  = 0x3f3f3f3f;
const double pi   = acos(-1.0);
const double eps  = 1e-9;
using namespace std;
std::vector<int> mp[maxn];
int w[maxn],s[maxn],vis[maxn],has[maxn];
std::vector<int> ans;
int main(){
	int n,m;scanf("%d %d",&n,&m);
	for(int i = 1;i <= m;i++){
		int u,v;scanf("%d %d",&u,&v);
		mp[u].push_back(v);mp[v].push_back(u);
	}
	for(int i = 1;i <= n;i++){
		scanf("%d",&w[i]);s[i] = 1;
	}
	for(int i = 1;i <= n;i++){
		for(auto it : mp[i]){
			if(w[it] < w[i]) has[i]++;else has[it]++;
			if(w[it] == w[i]) {puts("-1");return 0;}
		}
	}
	for(int i = 1;i <= n;i++) {
		has[i] /= 2;
		if(has[i] + 1 < w[i]){
			puts("-1");
			return 0;
		}
	}
	queue<int>q;while(!q.empty()) q.pop();
	for(int i = 1;i <= n;i++){
		if(w[i] == s[i]) q.push(i),vis[i] = 1;
	}
	while(!q.empty()){
		int u = q.front();q.pop();ans.push_back(u);
		for(auto it : mp[u]){
			if(vis[it]) continue;
			if(s[it] < s[u] + 1) s[it] = s[u] + 1;
			if(w[it] == s[it]) vis[it] = 1,q.push(it);
		}
	}
	if((int)ans.size() == n){
		for(auto it :ans) printf("%d ",it);
	}
	else puts("-1");
}


#include<bits/stdc++.h>
#define mes(a, b)  memset(a, b, sizeof a)
#define pb push_back
typedef unsigned long long int ull;
typedef long long int ll;
const int    maxn = 1e5 + 20;
const int    maxm = 1e5 + 10;
const ll     mod  = 998244353;
const ll     INF  = 1e18 + 100;
const int    inf  = 0x3f3f3f3f;
const double pi   = acos(-1.0);
const double eps  = 1e-9;
using namespace std;
int ans[maxn],vis[maxn];
std::vector<int> mp[maxn];
int a[maxn];
int main(){
	int n,m;scanf("%d %d",&n,&m);
	for(int i = 1;i <= m;i++) {
		int u,v;scanf("%d %d",&u,&v);
		mp[u].push_back(v);mp[v].push_back(u);
	}
	for(int i = 1;i <= n;i++) scanf("%d",&a[i]);
	int tot = 0;
	int flag = 0;
	for(int i = 1;i <= n;i++){
		for(auto it:mp[i]){
			if(a[it] == a[i]) flag = 1;
		}
	}
	if(flag == 1){
		puts("-1");
		return 0;
	}
	priority_queue<int, vector<int>, greater<int> > q;
	for(int i = 1;i <= n;i++){
		if(a[i]== 1){
			ans[++tot] = i;vis[i] = a[i];
			q.push(i);
		}
	}
	while(!q.empty()){
		int u = q.top();q.pop();
		for(auto it : mp[u]){
			if(vis[it]) continue;
			if(a[it] == a[u] + 1) ans[++tot] = it,vis[it] = a[it],q.push(it);
		}
	}
	for(int i = 1;i <= n;i++) if(ans[i]  == 0 ){puts("-1");return 0;}
	for(int i = 1;i <= tot;i++) printf("%d ",ans[i]);

}


#include<bits/stdc++.h>
#define mes(a, b)  memset(a, b, sizeof a)
#define pb push_back
typedef unsigned long long int ull;
typedef long long int ll;
const int    maxn = 1e6 + 20;
const int    maxm = 1e5 + 10;
const ll     mod  = 998244353;
const ll     INF  = 1e18 + 100;
const int    inf  = 0x3f3f3f3f;
const double pi   = acos(-1.0);
const double eps  = 1e-9;
using namespace std;
int ans[maxn],vis[maxn];
std::vector<int> mp[maxn];
int a[maxn];
int main(){
	int n,m;scanf("%d %d",&n,&m);
	for(int i = 1;i <= m;i++) {
		int u,v;scanf("%d %d",&u,&v);
		mp[u].push_back(v);mp[v].push_back(u);
	}
	for(int i = 1;i <= n;i++) scanf("%d",&a[i]);
	int tot = 0;
	int flag = 0;
	for(int i = 1;i <= n;i++){
		for(auto it:mp[i]){
			if(a[it] == a[i]) flag = 1;
		}
	}
	if(flag == 1){
		puts("-1");
		return 0;
	}
	priority_queue<int, vector<int>, greater<int> > q;
	for(int i = 1;i <= n;i++){
		if(a[i]== 1){
			ans[++tot] = i;vis[i] = 1;
			q.push(i);
		}
	}
	while(!q.empty()){
		int u = q.top();q.pop();
		for(auto it : mp[u]){
			if(vis[it]) continue;
			if(a[it] == a[u] + 1) ans[++tot] = it,vis[it] = 1,q.push(a[it]);
		}
	}
	if(tot != n) puts("-1");
	else for(int i = 1;i <= n;i++) printf("%d ",ans[i]);

}


#include<bits/stdc++.h>
#define mes(a, b)  memset(a, b, sizeof a)
#define pb push_back
typedef unsigned long long int ull;
typedef long long int ll;
const int    maxn = 5e5 + 20;
const int    maxm = 1e5 + 10;
const ll     mod  = 998244353;
const ll     INF  = 1e18 + 100;
const int    inf  = 0x3f3f3f3f;
const double pi   = acos(-1.0);
const double eps  = 1e-9;
using namespace std;
std::vector<int> mp[maxn];
int w[maxn],s[maxn],vis[maxn];
std::vector<int> ans;
int main(){
	int n,m;scanf("%d %d",&n,&m);
	for(int i = 1;i <= m;i++){
		int u,v;scanf("%d %d",&u,&v);
		mp[u].push_back(v);mp[v].push_back(u);
	}
	for(int i = 1;i <= n;i++){
		scanf("%d",&w[i]);s[i] = 1;
	}
	int flag = 0;
	for(int i = 1;i <= n;i++){
		for(auto it:mp[i]){
			if(w[it] == w[i]) flag = 1;
		}
	}
	if(flag == 1){
		puts("-1");
		return 0;
	}
	queue<int>q;while(!q.empty()) q.pop();
	for(int i = 1;i <= n;i++){
		if(w[i] == s[i]) q.push(i),vis[i] = 1;
	}
	while(!q.empty()){
		int u = q.front();q.pop();ans.push_back(u);
		for(auto it : mp[u]){
			if(vis[it]) continue;
			if(s[it] < s[u] + 1) s[it] = s[u] + 1;
			if(w[it] == s[it]) vis[it] = 1,q.push(it);
		}
	}
	if((int)ans.size() == n){
		for(auto it :ans) printf("%d ",it);
	}
	else puts("-1");
}


#include<bits/stdc++.h>
#define mes(a, b)  memset(a, b, sizeof a)
#define pb push_back
typedef unsigned long long int ull;
typedef long long int ll;
const int    maxn = 5e5 + 20;
const int    maxm = 1e5 + 10;
const ll     mod  = 998244353;
const ll     INF  = 1e18 + 100;
const int    inf  = 0x3f3f3f3f;
const double pi   = acos(-1.0);
const double eps  = 1e-9;
using namespace std;
std::vector<int> mp[maxn];
int w[maxn],s[maxn],vis[maxn],has[maxn];
std::vector<int> ans;
int main(){
	int n,m;scanf("%d %d",&n,&m);
	for(int i = 1;i <= m;i++){
		int u,v;scanf("%d %d",&u,&v);
		mp[u].push_back(v);mp[v].push_back(u);
	}
	for(int i = 1;i <= n;i++){
		scanf("%d",&w[i]);s[i] = 1;
	}
	for(int i = 1;i <= n;i++){
		for(auto it : mp[i]){
			if(w[it] < w[i]) has[i]++;else has[it]++;
			if(w[it] == w[i]) {puts("-1");return 0;}
		}
	}
	for(int i = 1;i <= n;i++) {
		has[i] /= 2;
		if(has[i] + 1 != w[i]){
			puts("-1");
			return 0;
		}
	}
	queue<int>q;while(!q.empty()) q.pop();
	for(int i = 1;i <= n;i++){
		if(w[i] == s[i]) q.push(i),vis[i] = 1;
	}
	while(!q.empty()){
		int u = q.front();q.pop();ans.push_back(u);
		for(auto it : mp[u]){
			if(vis[it]) continue;
			if(s[it] < s[u] + 1) s[it] = s[u] + 1;
			if(w[it] == s[it]) vis[it] = 1,q.push(it);
		}
	}
	if((int)ans.size() == n){
		for(auto it :ans) printf("%d ",it);
	}
	else puts("-1");
}


#include<bits/stdc++.h>
#define mes(a, b)  memset(a, b, sizeof a)
#define pb push_back
typedef unsigned long long int ull;
typedef long long int ll;
const int    maxn = 5e5 + 20;
const int    maxm = 1e5 + 10;
const ll     mod  = 998244353;
const ll     INF  = 1e18 + 100;
const int    inf  = 0x3f3f3f3f;
const double pi   = acos(-1.0);
const double eps  = 1e-9;
using namespace std;
std::vector<int> mp[maxn];
int w[maxn],s[maxn],vis[maxn],has[maxn];
std::vector<int> ans;
int main(){
	int n,m;scanf("%d %d",&n,&m);
	for(int i = 1;i <= m;i++){
		int u,v;scanf("%d %d",&u,&v);
		mp[u].push_back(v);mp[v].push_back(u);
	}
	for(int i = 1;i <= n;i++){
		scanf("%d",&w[i]);s[i] = 1;
	}
	for(int i = 1;i <= n;i++){
		for(auto it : mp[i]){
			if(w[it] < w[i]) has[i]++;else has[it]++;
		}
	}
	for(int i = 1;i <= n;i++) {
		has[i] /= 2;
		if(has[i] + 1 != w[i]){
			puts("-1");
			return 0;
		}
	}
	queue<int>q;while(!q.empty()) q.pop();
	for(int i = 1;i <= n;i++){
		if(w[i] == s[i]) q.push(i),vis[i] = 1;
	}
	while(!q.empty()){
		int u = q.front();q.pop();ans.push_back(u);
		for(auto it : mp[u]){
			if(vis[it]) continue;
			if(s[it] < s[u] + 1) s[it] = s[u] + 1;
			if(w[it] == s[it]) vis[it] = 1,q.push(it);
		}
	}
	if((int)ans.size() == n){
		for(auto it :ans) printf("%d ",it);
	}
	else puts("-1");
}


#include<bits/stdc++.h>
#define mes(a, b)  memset(a, b, sizeof a)
#define pb push_back
typedef unsigned long long int ull;
typedef long long int ll;
const int    maxn = 1e6 + 20;
const int    maxm = 1e5 + 10;
const ll     mod  = 998244353;
const ll     INF  = 1e18 + 100;
const int    inf  = 0x3f3f3f3f;
const double pi   = acos(-1.0);
const double eps  = 1e-9;
using namespace std;
int ans[maxn],vis[maxn],rk[maxn];
std::vector<int> mp[maxn];
struct node{
	int sum,id;
	bool operator<(const node &a)const{
		return sum < a.sum;
	}
}a[maxn];
int main(){
	int n,m;scanf("%d %d",&n,&m);
	for(int i = 1;i <= m;i++) {
		int u,v;scanf("%d %d",&u,&v);
		mp[u].push_back(v);mp[v].push_back(u);
	}
	for(int i = 1;i <= n;i++) scanf("%d",&a[i].sum),a[i].id = i;
	int tot = 0;
	int flag = 0;
	for(int i = 1;i <= n;i++){
		for(auto it:mp[i]){
			if(a[it].sum == a[i].sum) flag = 1;
		}
	}
	if(flag == 1){
		puts("-1");
		return 0;
	}
	sort(a + 1,a + 1 + n);
	for(int i = 1;i <= n;i++) rk[a[i].id] = a[i].sum;
	queue<int>q;
	for(int i = 1;i <= n;i++){
		if(vis[a[i].id]) continue;
		q.push(a[i].id);ans[++tot] = a[i].id;vis[a[i].id] = 1;
		while(!q.empty()){
			int u = q.front();q.pop();
			for(auto it : mp[u]){
				if(vis[a[it].id]) continue;
			//	printf("sum = %d %d\n",a[rk[it]].sum,a[rk[u]].sum);
				if(a[rk[it]].sum == a[rk[u]].sum + 1) ans[++tot] = a[rk[it]].id,vis[a[rk[it]].id] = 1,q.push(a[rk[it]].id);
			}
		}
	}
	if(tot != n) puts("-1");
	else for(int i = 1;i <= n;i++) printf("%d ",ans[i]);
}


#include<bits/stdc++.h>
#define mes(a, b)  memset(a, b, sizeof a)
#define pb push_back
typedef unsigned long long int ull;
typedef long long int ll;
const int    maxn = 1e6 + 20;
const int    maxm = 1e5 + 10;
const ll     mod  = 998244353;
const ll     INF  = 1e18 + 100;
const int    inf  = 0x3f3f3f3f;
const double pi   = acos(-1.0);
const double eps  = 1e-9;
using namespace std;
int ans[maxn],vis[maxn],rk[maxn];
std::vector<int> mp[maxn];
struct node{
	int sum,id;
	bool operator<(const node &a)const{
		return sum < a.sum;
	}
}a[maxn];
int main(){
	int n,m;scanf("%d %d",&n,&m);
	for(int i = 1;i <= m;i++) {
		int u,v;scanf("%d %d",&u,&v);
		mp[u].push_back(v);mp[v].push_back(u);
	}
	for(int i = 1;i <= n;i++) scanf("%d",&a[i].sum),a[i].id = i;
	int tot = 0;
	int flag = 0;
	for(int i = 1;i <= n;i++){
		for(auto it:mp[i]){
			if(a[it].sum == a[i].sum) flag = 1;
		}
	}
	if(flag == 1){
		puts("-1");
		return 0;
	}
	sort(a + 1,a + 1 + n);
	for(int i = 1;i <= n;i++) rk[a[i].sum] = a[i].id;
	queue<int>q;
	for(int i = 1;i <= n;i++){
		if(vis[a[i].id]) continue;
		q.push(a[i].id);ans[++tot] = a[i].id;vis[a[i].id] = 1;
		while(!q.empty()){
			int u = q.front();q.pop();
			for(auto it : mp[u]){
				if(vis[a[it].id]) continue;
			//	printf("sum = %d %d\n",a[rk[it]].sum,a[rk[u]].sum);
				if(a[rk[it]].sum == a[rk[u]].sum + 1) ans[++tot] = a[rk[it]].id,vis[a[rk[it]].id] = 1,q.push(a[rk[it]].id);
			}
		}
	}
	if(tot != n) puts("-1");
	else for(int i = 1;i <= n;i++) printf("%d ",ans[i]);
}


#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <ctime>
#include <bitset>
#include <cmath>
#include <sstream>
#include <iostream>
#include <unordered_map>

#define ll long long
#define ull unsigned long long
#define ls nod<<1
#define rs (nod<<1)+1
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define INF 0x3f3f3f3f3f3f3f3f
#define max(a, b) (a>b?a:b)
#define min(a, b) (a<b?a:b)

const double eps = 1e-10;
const int maxn = 5e5 + 10;
const ll MOD = 99999999999999;

int sgn(double a) { return a < -eps ? -1 : a < eps ? 0 : 1; }

using namespace std;

int vis[maxn];
struct node {
    int v;
    int id;
}t[maxn];

int p[maxn];
vector<int> g[maxn];
int tag[maxn];

bool cmp(node a,node b) {
    return a.v < b.v;
}

int main() {
    ios::sync_with_stdio(false);
    int n,m;
    cin >> n >> m;
    for (int i = 1;i <= m;i++) {
        int u,v;
        cin >> u >> v;
        g[u].pb(v);
        g[v].pb(u);
    }
    for (int i = 1;i <= n;i++) {
        cin >> t[i].v;
        t[i].id = i;
    }
    sort(t+1,t+1+n,cmp);
    int cnt = 0;
    bool fl = true;
    for (int i = 1;i <= n;i++) {
        int u = t[i].id;
        set<int> st;
        for (int j = 0;j < g[u].size();j++) {
            int v = g[u][j];
            st.insert(vis[v]);
        }
        int x = 1;
        while (st.count(x)) {
            x++;
        }
        if (x != t[i].v) {
            fl = false;
            cout << -1 << endl;
            break;
        }
        p[++cnt] = u;
        vis[u] = x;
    }
    if (fl) {
        for (int i = 1;i <= cnt;i++)
            cout << p[i] << " ";
        cout << endl;
    }
    return 0;
}


#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <ctime>
#include <bitset>
#include <cmath>
#include <sstream>
#include <iostream>
#include <unordered_map>

#define ll long long
#define ull unsigned long long
#define ls nod<<1
#define rs (nod<<1)+1
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define INF 0x3f3f3f3f3f3f3f3f
#define max(a, b) (a>b?a:b)
#define min(a, b) (a<b?a:b)

const double eps = 1e-10;
const int maxn = 5e5 + 10;
const ll MOD = 99999999999999;

int sgn(double a) { return a < -eps ? -1 : a < eps ? 0 : 1; }

using namespace std;

int vis[maxn];
struct node {
    int v;
    int id;
}t[maxn];

int p[maxn];
vector<int> g[maxn];
int tag[maxn];

bool cmp(node a,node b) {
    return a.v < b.v;
}

int main() {
    ios::sync_with_stdio(false);
    int n,m;
    cin >> n >> m;
    for (int i = 1;i <= m;i++) {
        int u,v;
        cin >> u >> v;
        g[u].pb(v);
        g[v].pb(u);
    }
    for (int i = 1;i <= n;i++) {
        cin >> t[i].v;
        t[i].id = i;
    }
    sort(t+1,t+1+n,cmp);
    int cnt = 0;
    bool fl = true;
    for (int i = 1;i <= n;i++) {
        int u = t[i].id;
        int Max = 0;
        for (int j = 0;j < g[u].size();j++) {
            int v = g[u][j];
            tag[vis[v]] = 1;
            Max = max(Max,vis[v]);
        }
        int Min = Max;
        for (int j = 1;j <= Max + 1;j++) {
            if (tag[j])
                tag[j] = 0;
            else
                Min = min(Min,j);
        }
        if (Min + 1 != t[i].v) {
            fl = false;
            cout << -1 << endl;
            break;
        }
        p[++cnt] = u;
        vis[u] = Min + 1;
    }
    if (fl) {
        for (int i = 1;i <= cnt;i++)
            cout << p[i] << " ";
        cout << endl;
    }
    return 0;
}


#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <ctime>
#include <bitset>
#include <cmath>
#include <sstream>
#include <iostream>
#include <unordered_map>

#define ll long long
#define ull unsigned long long
#define ls nod<<1
#define rs (nod<<1)+1
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define INF 0x3f3f3f3f3f3f3f3f
#define max(a, b) (a>b?a:b)
#define min(a, b) (a<b?a:b)

const double eps = 1e-10;
const int maxn = 5e5 + 10;
const ll MOD = 99999999999999;

int sgn(double a) { return a < -eps ? -1 : a < eps ? 0 : 1; }

using namespace std;

int vis[maxn];
struct node {
    int v;
    int id;
}t[maxn];

int p[maxn];
vector<int> g[maxn];
int tag[maxn];

bool cmp(node a,node b) {
    return a.v < b.v;
}

int main() {
    ios::sync_with_stdio(false);
    int n,m;
    cin >> n >> m;
    for (int i = 1;i <= m;i++) {
        int u,v;
        cin >> u >> v;
        g[u].pb(v);
        g[v].pb(u);
    }
    for (int i = 1;i <= n;i++) {
        cin >> t[i].v;
        t[i].id = i;
    }
    sort(t+1,t+1+n,cmp);
    int cnt = 0;
    bool fl = true;
    for (int i = 1;i <= n;i++) {
        int u = t[i].id;
        int Max = 0;
        for (int j = 0;j < g[u].size();j++) {
            int v = g[u][j];
            tag[vis[v]] = 1;
            Max = max(Max,vis[v]);
        }
        int Min = Max;
        for (int j = 1;j <= Max;j++) {
            if (tag[j])
                tag[j] = 0;
            else
                Min = min(Min,j);
        }
        if (Min + 1 != t[i].v) {
            fl = false;
            cout << -1 << endl;
            break;
        }
        p[++cnt] = u;
        vis[u] = Min + 1;
    }
    if (fl) {
        for (int i = 1;i <= cnt;i++)
            cout << p[i] << " ";
        cout << endl;
    }
    return 0;
}


#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <ctime>
#include <bitset>
#include <cmath>
#include <sstream>
#include <iostream>
#include <unordered_map>

#define ll long long
#define ull unsigned long long
#define ls nod<<1
#define rs (nod<<1)+1
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define INF 0x3f3f3f3f3f3f3f3f
#define max(a, b) (a>b?a:b)
#define min(a, b) (a<b?a:b)

const double eps = 1e-10;
const int maxn = 5e5 + 10;
const ll MOD = 99999999999999;

int sgn(double a) { return a < -eps ? -1 : a < eps ? 0 : 1; }

using namespace std;

int vis[maxn];
struct node {
    int v;
    int id;
}t[maxn];

int p[maxn];
vector<int> g[maxn];
int tag[maxn];

bool cmp(node a,node b) {
    return a.v < b.v;
}

int main() {
    ios::sync_with_stdio(false);
    int n,m;
    cin >> n >> m;
    for (int i = 1;i <= m;i++) {
        int u,v;
        cin >> u >> v;
        g[u].pb(v);
        g[v].pb(u);
    }
    for (int i = 1;i <= n;i++) {
        cin >> t[i].v;
        t[i].id = i;
    }
    sort(t+1,t+1+n,cmp);
    int cnt = 0;
    bool fl = true;
    for (int i = 1;i <= n;i++) {
        int u = t[i].id;
        int Max = 0;
        for (int j = 0;j < g[u].size();j++) {
            int v = g[u][j];
            tag[vis[v]] = 1;
            Max = max(Max,vis[v]);
        }
        int Min = Max;
        for (int j = 1;j <= Max;j++) {
            if (tag[j])
                tag[j] = 0;
            else
                Min = min(Min,j);
        }
        if (Min + 1 != t[i].v) {
            fl = false;
            cout << -1 << endl;
            break;
        }
        p[++cnt] = u;
        vis[u] = Max + 1;
    }
    if (fl) {
        for (int i = 1;i <= cnt;i++)
            cout << p[i] << " ";
        cout << endl;
    }
    return 0;
}


#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <ctime>
#include <bitset>
#include <cmath>
#include <sstream>
#include <iostream>
#include <unordered_map>

#define ll long long
#define ull unsigned long long
#define ls nod<<1
#define rs (nod<<1)+1
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define INF 0x3f3f3f3f3f3f3f3f
#define max(a, b) (a>b?a:b)
#define min(a, b) (a<b?a:b)

const double eps = 1e-10;
const int maxn = 5e5 + 10;
const ll MOD = 99999999999999;

int sgn(double a) { return a < -eps ? -1 : a < eps ? 0 : 1; }

using namespace std;

int vis[maxn];
struct node {
    int v;
    int id;
}t[maxn];

int p[maxn];
vector<int> g[maxn];

bool cmp(node a,node b) {
    return a.v < b.v;
}

int main() {
    ios::sync_with_stdio(false);
    int n,m;
    cin >> n >> m;
    for (int i = 1;i <= m;i++) {
        int u,v;
        cin >> u >> v;
        g[u].pb(v);
        g[v].pb(u);
    }
    for (int i = 1;i <= n;i++) {
        cin >> t[i].v;
        t[i].id = i;
    }
    sort(t+1,t+1+n,cmp);
    int cnt = 0;
    bool fl = true;
    for (int i = 1;i <= n;i++) {
        int u = t[i].id;
        int Max = 0;
        for (int j = 0;j < g[u].size();j++) {
            int v = g[u][j];
            Max = max(Max,vis[v]);
        }
        if (Max + 1 != t[i].v) {
            fl = false;
            cout << -1 << endl;
            break;
        }
        p[++cnt] = u;
        vis[u] = Max + 1;
    }
    if (fl) {
        for (int i = 1;i <= cnt;i++)
            cout << p[i] << " ";
        cout << endl;
    }
    return 0;
}


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

using namespace std;

int main(){
    int n, m;
    int u, v;
    bool flag = true;
    cin >> n >> m;
    vector<pair<int, int> > vec;
    unordered_set<int> set[n];
    vector<int> graph[n];
    vector<int> color;
    vector<int> order;
    for(int i=0; i<m; ++i){
        cin>>u>>v;
        u--; v--;
        graph[u].push_back(v);
        graph[v].push_back(u);
    }
    for(int i=0; i<n; ++i){
        int c;
        cin>>c;
        color.push_back(c);
        vec.push_back(make_pair(c, i));
    }
    sort(vec.begin(), vec.end());
    for(auto& p : vec){
        if(!flag)
            break;
        int c = p.first;
        int index = p.second;
        for(auto& neigh : graph[index]){
            if(c == color[neigh]){
                flag = false;
                break;
            }
            else if(color[neigh] < c)
             set[index].insert(color[neigh]);
        }
        if(set[index].size() != c-1){
            flag = false;
            break;
        }
        else
            order.push_back(index + 1);
    }
    if(!flag)
        cout<<-1<<endl;
    else{
        for(auto& x: order)
            cout<<x<<" ";
        cout<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
#define endl "\n"
#ifdef ONLINE_JUDGE
#define DEBUG(x)
#else
#define DEBUG(x) cout<<#x<<" : {"<<x<<"}"<<endl;
#endif
#define MAX 500005
using namespace std;
int main(){
    bool possible = true;
    int n, m;
    int u, v;
    cin>>n>>m;
    vector<int> graph[MAX];
    vector<pair<int, int> > seq;
    unordered_set<int> s[MAX];
    for(int i=0; i<m; ++i){
        cin>>u>>v;
        u--; v--;
        graph[u].push_back(v);
        graph[v].push_back(u);
    }
    for(int i=0; i<n; ++i){
        cin>>u;
        u--;
        seq.push_back(make_pair(u, i));
    }
    for(int i=0; i<n; ++i){
        for(int neighbor: graph[i])
            s[i].insert(seq[neighbor].first);
    }
    sort(seq.begin(), seq.end());
    int order, index;
    for(int i=0; i<n; ++i){
        if(!possible)
            break;
        order = seq[i].first;
        index = seq[i].second;
        for(int j=0; j<order; ++j){
            if(s[index].count(j)==0){
                possible = false;
                break;
            }
        }
        if(s[index].count(order))
            possible = false;
    }
    if(!possible)
        cout<<-1<<endl;
    else{
        for(int i=0; i<n; ++i)
            cout<<seq[i].second+1<<" ";
        cout<<endl;
    }
    return 0;
}


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

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, m;
    int u, v;
    bool flag = true;
    cin >> n >> m;
    vector<pair<int, int> > vec;
    unordered_set<int> set;
    vector<int> graph[n];
    vector<int> color;
    for(int i=0; i<m; ++i){
        cin>>u>>v;
        u--; v--;
        graph[u].push_back(v);
        graph[v].push_back(u);
    }
    for(int i=0; i<n; ++i){
        int c;
        cin>>c;
        color.push_back(c);
        vec.push_back(make_pair(c, i));
    }
    sort(vec.begin(), vec.end());
    for(auto& p : vec){
        if(!flag)
            break;
        int c = p.first;
        int index = p.second;
        for(auto& neigh : graph[index]){
            if(c == color[neigh]){
                flag = false;
                break;
            }
            else if(color[neigh] < c)
             set.insert(color[neigh]);
        }
        if(set.size() != c-1){
            flag = false;
            break;
        }
        set.clear();
    }
    if(!flag)
        cout<<-1<<endl;
    else{
        for(auto& x: vec)
            cout<<x.second + 1<<" ";
        cout<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
#define endl "\n"
#ifdef ONLINE_JUDGE
#define DEBUG(x)
#else
#define DEBUG(x) cout<<#x<<" : {"<<x<<"}"<<endl;
#endif
using namespace std;
int main(){
    bool possible = true;
    int n, m;
    int u, v;
    cin>>n>>m;
    vector<vector<int> > graph(n);
    vector<pair<int, int> > seq;
    unordered_set<int> s[n];
    for(int i=0; i<m; ++i){
        cin>>u>>v;
        u--; v--;
        graph[u].push_back(v);
        graph[v].push_back(u);
    }
    for(int i=0; i<n; ++i){
        cin>>u;
        u--;
        seq.push_back(make_pair(u, i));
    }
    for(int i=0; i<n; ++i){
        for(int neighbor: graph[i])
            s[i].insert(seq[neighbor].first);
    }
    sort(seq.begin(), seq.end());
    int order, index;
    for(int i=0; i<n; ++i){
        if(!possible)
            break;
        order = seq[i].first;
        index = seq[i].second;
        for(int j=0; j<order; ++j){
            if(s[index].count(j)==0){
                possible = false;
                break;
            }
        }
        if(s[index].count(order))
            possible = false;
    }
    if(!possible)
        cout<<-1<<endl;
    else{
        for(int i=0; i<n; ++i)
            cout<<seq[i].second+1<<" ";
        cout<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
#define endl "\n"
#ifdef ONLINE_JUDGE
#define DEBUG(x)
#else
#define DEBUG(x) cout<<#x<<" : {"<<x<<"}"<<endl;
#endif
#define MAX 500005
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    bool possible = true;
    int n, m;
    int u, v;
    cin>>n>>m;
    vector<int> graph[MAX];
    vector<pair<int, int> > seq;
    unordered_set<int> s[MAX];
    for(int i=0; i<m; ++i){
        cin>>u>>v;
        u--; v--;
        graph[u].push_back(v);
        graph[v].push_back(u);
    }
    for(int i=0; i<n; ++i){
        cin>>u;
        u--;
        seq.push_back(make_pair(u, i));
    }
    for(int i=0; i<n; ++i){
        for(int neighbor: graph[i])
            s[i].insert(seq[neighbor].first);
    }
    sort(seq.begin(), seq.end());
    int order, index;
    for(int i=0; i<n; ++i){
        if(!possible)
            break;
        order = seq[i].first;
        index = seq[i].second;
        for(int j=0; j<order; ++j){
            if(s[index].count(j)==0){
                possible = false;
                break;
            }
        }
        if(s[index].count(order))
            possible = false;
    }
    if(!possible)
        cout<<-1<<endl;
    else{
        for(int i=0; i<n; ++i)
            cout<<seq[i].second+1<<" ";
        cout<<endl;
    }
    return 0;
}


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

using namespace std;

int main(){
    int n, m;
    int u, v;
    bool flag = true;
    cin >> n >> m;
    vector<pair<int, int> > vec;
    unordered_set<int> set;
    vector<int> graph[n];
    vector<int> color;
    for(int i=0; i<m; ++i){
        cin>>u>>v;
        u--; v--;
        graph[u].push_back(v);
        graph[v].push_back(u);
    }
    for(int i=0; i<n; ++i){
        int c;
        cin>>c;
        color.push_back(c);
        vec.push_back(make_pair(c, i));
    }
    sort(vec.begin(), vec.end());
    for(auto& p : vec){
        if(!flag)
            break;
        int c = p.first;
        int index = p.second;
        for(auto& neigh : graph[index]){
            if(c == color[neigh]){
                flag = false;
                break;
            }
            else if(color[neigh] < c)
             set.insert(color[neigh]);
        }
        if(set.size() != c-1){
            flag = false;
            break;
        }
        set.clear();
    }
    if(!flag)
        cout<<-1<<endl;
    else{
        for(auto& x: vec)
            cout<<x.second + 1<<" ";
        cout<<endl;
    }
    return 0;
}


#include <cstdio>
#include <vector>
using namespace std;
struct Edge{int to,nxt;}edge[1000100];
int n,m,head[500100],num,rel[500100];
int ans[500100],cnt;
bool vis[500100];
vector<int> a[500100];
void add(int u,int v)
{
	edge[++num].to=v;
	edge[num].nxt=head[u];
	head[u]=num;
}
void sol()
{
	int x,v;
	for(int i=1;i<=n;i++)
	for(int j=0;j<a[i].size();j++)
	{
		x=a[i][j];
		if (rel[x]!=i) {printf("-1"); return;}
		ans[++cnt]=x; vis[x]=true;
		for(int k=head[x];k;k=edge[k].nxt)
		{
			v=edge[k].to;
			if (vis[v]) continue;
			if (rel[v]==rel[x]) rel[v]++;
		}
	}
	for(int i=1;i<=cnt;i++) printf("%d ",ans[i]);
	return;
}
int main()
{
	int u,v;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d",&u,&v);
		add(u,v); add(v,u);
	}
	for(int i=1;i<=n;i++) {scanf("%d",&u); a[u].push_back(i);}
	for(int i=1;i<=n;i++) rel[i]=1;
	sol();
	return 0;
}


#include <cstdio>
#include <vector>
using namespace std;
struct Edge{int to,nxt;}edge[500100];
int n,m,head[500100],num,rel[500100];
int ans[500100],cnt;
bool vis[500100];
vector<int> a[500100];
void add(int u,int v)
{
	edge[++num].to=v;
	edge[num].nxt=head[u];
	head[u]=num;
}
void sol()
{
	int x,v;
	for(int i=1;i<=n;i++)
	for(int j=0;j<a[i].size();j++)
	{
		x=a[i][j];
		if (rel[x]!=i) {printf("-1"); return;}
		ans[++cnt]=x; vis[x]=true;
		for(int k=head[x];k;k=edge[k].nxt)
		{
			v=edge[k].to;
			if (vis[v]) continue;
			if (rel[v]==rel[x]) rel[v]++;
		}
	}
	for(int i=1;i<=cnt;i++) printf("%d ",ans[i]);
	return;
}
int main()
{
	int u,v;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d",&u,&v);
		add(u,v); add(v,u);
	}
	for(int i=1;i<=n;i++) {scanf("%d",&u); a[u].push_back(i);}
	for(int i=1;i<=n;i++) rel[i]=1;
	sol();
	return 0;
}


#include <cstdio>
#include <queue>
using namespace std;
int n,m,head[500500],ret[500500],num,a[500500],b[500500];
int de[500500];
queue<int> q;
int ans[500500],cnt,x;
bool ju;
struct Edge{int to,nxt;}edge[500500];
int minn(int a,int b){return a<b?a:b;}
void add(int u,int v)
{
	edge[++num].to=v;
	edge[num].nxt=head[u];
	head[u]=num;
}
int main()
{
	int v;
	scanf("%d%d",&n,&m); ju=true;
	for(int i=1;i<=m;i++) scanf("%d%d",&a[i],&b[i]);
	for(int i=1;i<=n;i++) scanf("%d",&ret[i]);
	for(int i=1;i<=m;i++)
	{
		if (ret[a[i]]>ret[b[i]]) {add(b[i],a[i]); de[a[i]]++;}
		else if (ret[a[i]]<ret[b[i]]) {add(a[i],b[i]); de[b[i]]++;}
		else {printf("-1"); ju=false; break;}
	}
	if (ju)
	{
		for(int i=1;i<=n;i++) if (ret[i]==1) q.push(i);
		while(!q.empty())
		{
			x=q.front(); ans[++cnt]=x; q.pop();
			for(int i=head[x];i;i=edge[i].nxt)
			{
				v=edge[i].to;
				de[v]--;
				if (!de[v]) q.push(v);
			}
		}
		if (cnt<n) printf("-1");
		else {for(int i=1;i<=cnt;i++) printf("%d ",ans[i]);}
	}
	return 0;
}


#include <cstdio>
#include <queue>
using namespace std;
int n,m,head[500500],ret[500500],num,a[500500],b[500500];
int de[500500],f;
queue<int> q;
int ans[500500],cnt,x;
bool ju;
struct Edge{int to,nxt;}edge[500500];
int minn(int a,int b){return a<b?a:b;}
void add(int u,int v)
{
	edge[++num].to=v;
	edge[num].nxt=head[u];
	head[u]=num;
}
int main()
{
	int v;
	scanf("%d%d",&n,&m); ju=true;
	for(int i=1;i<=m;i++) scanf("%d%d",&a[i],&b[i]);
	for(int i=1;i<=n;i++) scanf("%d",&ret[i]);
	for(int i=1;i<=m;i++)
	{
		if (ret[a[i]]>ret[b[i]]) {add(b[i],a[i]); de[a[i]]++;}
		else if (ret[a[i]]<ret[b[i]]) {add(a[i],b[i]); de[b[i]]++;}
		else {printf("-1"); ju=false; break;}
	}
	if (ju)
	{
		f=1;
		for(int i=1;i<=n;i++) if (ret[i]==1) q.push(i);
		while(!q.empty())
		{
			x=q.front();
			if (f!=ret[x]) {f++; if (f!=ret[x]) {printf("-1"); ju=false; break;}}
			ans[++cnt]=x; q.pop();
			for(int i=head[x];i;i=edge[i].nxt)
			{
				v=edge[i].to;
				de[v]--;
				if (!de[v]) q.push(v);
			}
		}
		if (ju)
		{
			if (cnt<n) printf("-1");
			else {for(int i=1;i<=cnt;i++) printf("%d ",ans[i]);}
		}
	}
	return 0;
}


#include <cstdio>
#include <queue>
using namespace std;
int n,m,head[500500],ret[500500],num,a[500500],b[500500];
int de[500500];
queue<int> q;
int ans[500500],cnt,x;
bool ju,f[500500];
struct Edge{int to,nxt;}edge[500500];
int minn(int a,int b){return a<b?a:b;}
void add(int u,int v)
{
	edge[++num].to=v;
	edge[num].nxt=head[u];
	head[u]=num;
}
int main()
{
	int v;
	scanf("%d%d",&n,&m); ju=true;
	for(int i=1;i<=m;i++) scanf("%d%d",&a[i],&b[i]);
	for(int i=1;i<=n;i++) scanf("%d",&ret[i]);
	for(int i=1;i<=m;i++)
	{
		if (ret[a[i]]>ret[b[i]]) {add(b[i],a[i]); de[a[i]]++;}
		else if (ret[a[i]]<ret[b[i]]) {add(a[i],b[i]); de[b[i]]++;}
		else {printf("-1"); ju=false; break;}
	}
	if (ju)
	{
		for(int i=1;i<=n;i++) if (ret[i]==1) q.push(i);
		while(!q.empty())
		{
			x=q.front(); ans[++cnt]=x; q.pop();
			for(int i=head[x];i;i=edge[i].nxt)
			{
				v=edge[i].to;
				de[v]--; if (ret[v]==ret[x]+1) f[v]=true;
				if ((!de[v])&&f[v]==true) q.push(v);
			}
		}
		if (cnt<n) printf("-1");
		else {for(int i=1;i<=cnt;i++) printf("%d ",ans[i]);}
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define IOS std::ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define FRE freopen("in.txt", "r", stdin);
#define endl "\n"
#define PI acos(-1.0)
typedef long long LL;
typedef pair<int, int> PII;
const double eps = 1e-8;
const int inf = 0x3f3f3f3f;
const LL INF = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9 + 7;
const int N = 5e5 + 10, M = 17;

inline int read() {
  int x = 0, neg = 1; char op = getchar();
  while (!isdigit(op)) { if (op == '-') neg = -1; op = getchar(); }
  while (isdigit(op)) { x = 10 * x + op - '0'; op = getchar(); }
  return neg * x;
}

inline void print(int x) {
  if (x < 0) { putchar('-'); x = -x; }
  if (x >= 10) print(x / 10);
  putchar(x % 10 + '0');
}

set<int> cnt;
int t[N];
priority_queue<PII, vector<PII>, greater<PII> > q;
vector<int> v[N];
vector<int> e[N];

bool check(int x) {
	for(int i = 0; i < e[x].size(); i++) {
		if(t[x] == t[e[x][i]]) return false;
	}
	return true;
}

void solve() {
	int n, m;
	scanf("%d%d", &n, &m);
	while(m--) {
		int a, b;
		scanf("%d%d", &a, &b);
		e[a].push_back(b);
		e[b].push_back(a);
	}
	for(int i = 1; i <= n; i++) {
		scanf("%d", &t[i]);
		v[t[i]].push_back(i);
		cnt.insert(t[i]);
	}
	bool flag = 1;
	for(int i = 1; i < n; i++) {
		if(!check(i)) {
			flag = 0;
			break;
		}
	}
	if(!flag) {
		puts("-1");
		return;
	}
	vector<int> res;
	set<int>::iterator it;
	for(it = cnt.begin(); it != cnt.end(); it++) {
		int num = *it;
		q.push({v[num].size(), num});
	}
	while(!q.empty()) {
		int x = q.top().first, y = q.top().second; q.pop();
		for(int i = 0; i < x; i++) {
			res.push_back(v[y][i]);
		}
	}
	for(int i = 0; i < n; i++) printf("%d ", res[i]);
	puts("");
}

int main() {
//	FRE;
//	int t; scanf("%d", &t); while(t--)
	solve();
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define IOS std::ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define FRE freopen("in.txt", "r", stdin);
#define endl "\n"
#define PI acos(-1.0)
typedef long long LL;
typedef pair<int, int> PII;
const double eps = 1e-8;
const int inf = 0x3f3f3f3f;
const LL INF = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9 + 7;
const int N = 5e5 + 10, M = 17;

inline int read() {
  int x = 0, neg = 1; char op = getchar();
  while (!isdigit(op)) { if (op == '-') neg = -1; op = getchar(); }
  while (isdigit(op)) { x = 10 * x + op - '0'; op = getchar(); }
  return neg * x;
}

inline void print(int x) {
  if (x < 0) { putchar('-'); x = -x; }
  if (x >= 10) print(x / 10);
  putchar(x % 10 + '0');
}

set<int> cnt;
int t[N];
vector<int> v[N];
vector<int> e[N];

bool check(int x) {
	set<int> tmp;
	for(int i = 0; i < e[x].size(); i++) {
		if(t[x] == t[e[x][i]]) return false;
		if(t[x] > t[e[x][i]]) tmp.insert(t[e[x][i]]);
	}
	if(tmp.size() + 1 == t[x]) return true;
	return false;
}

void solve() {
	int mx = 0;
	int n, m;
	scanf("%d%d", &n, &m);
	while(m--) {
		int a, b;
		scanf("%d%d", &a, &b);
		e[a].push_back(b);
		e[b].push_back(a);
	}
	for(int i = 1; i <= n; i++) {
		scanf("%d", &t[i]);
		v[t[i]].push_back(i);
		mx = max(mx, t[i]);
	}
	bool flag = 1;
	for(int i = 1; i <= n; i++) {
		if(!check(i)) {
			flag = 0;
			break;
		}
	}
	if(!flag) {
		puts("-1");
		return;
	}
	for(int i = 1; i <= mx; i++) {
		for(int j = 0; j < v[i].size(); j++) {
			printf("%d ", v[i][j]);
		}
	}
	puts("");
}

int main() {
//	FRE;
//	int t; scanf("%d", &t); while(t--)
	solve();
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define IOS std::ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define FRE freopen("in.txt", "r", stdin);
#define endl "\n"
#define PI acos(-1.0)
typedef long long LL;
typedef pair<int, int> PII;
const double eps = 1e-8;
const int inf = 0x3f3f3f3f;
const LL INF = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9 + 7;
const int N = 5e5 + 10, M = 17;

inline int read() {
  int x = 0, neg = 1; char op = getchar();
  while (!isdigit(op)) { if (op == '-') neg = -1; op = getchar(); }
  while (isdigit(op)) { x = 10 * x + op - '0'; op = getchar(); }
  return neg * x;
}

inline void print(int x) {
  if (x < 0) { putchar('-'); x = -x; }
  if (x >= 10) print(x / 10);
  putchar(x % 10 + '0');
}

set<int> cnt;
int t[N];
priority_queue<PII, vector<PII>, greater<PII> > q;
vector<int> v[N];
vector<int> e[N];

bool check(int x) {
	for(int i = 0; i < e[x].size(); i++) {
		if(t[x] == t[e[x][i]]) return false;
	}
	return true;
}

void solve() {
	int n, m;
	scanf("%d%d", &n, &m);
	while(m--) {
		int a, b;
		scanf("%d%d", &a, &b);
		e[a].push_back(b);
		e[b].push_back(a);
	}
	for(int i = 1; i <= n; i++) {
		scanf("%d", &t[i]);
		v[t[i]].push_back(i);
		cnt.insert(t[i]);
	}
	set<int>::iterator it;
	for(it = cnt.begin(); it != cnt.end(); it++) {
		int num = *it;
		q.push({v[num].size(), num});
	}
	bool flag = 1;
	vector<int> res;
	while(!q.empty()) {
		int x = q.top().first, y = q.top().second; q.pop();
		for(int i = 0; i < x; i++) {
			int node = v[y][i];
			if(check(node)) res.push_back(node);
			else {
				flag = 0;
				break;
			}
		}
		if(!flag) break;
	}
	if(!flag) {
		puts("-1");
		return;
	}
	for(int i = 0; i < n; i++) printf("%d ", res[i]);
	puts("");
}

int main() {
//	FRE;
//	int t; scanf("%d", &t); while(t--)
	solve();
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define IOS std::ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define FRE freopen("in.txt", "r", stdin);
#define endl "\n"
#define PI acos(-1.0)
typedef long long LL;
typedef pair<int, int> PII;
const double eps = 1e-8;
const int inf = 0x3f3f3f3f;
const LL INF = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9 + 7;
const int N = 1e5 + 10, M = 17;

inline int read() {
  int x = 0, neg = 1; char op = getchar();
  while (!isdigit(op)) { if (op == '-') neg = -1; op = getchar(); }
  while (isdigit(op)) { x = 10 * x + op - '0'; op = getchar(); }
  return neg * x;
}

inline void print(int x) {
  if (x < 0) { putchar('-'); x = -x; }
  if (x >= 10) print(x / 10);
  putchar(x % 10 + '0');
}

set<int> cnt;
int t[N];
priority_queue<PII, vector<PII>, greater<PII> > q;
vector<int> v[N];
vector<int> e[N];

bool check(int x) {
	for(int i = 0; i < e[x].size(); i++) {
		if(t[x] == t[e[x][i]]) return false;
	}
	return true;
}

void solve() {
	int n, m;
	scanf("%d%d", &n, &m);
	while(m--) {
		int a, b;
		scanf("%d%d", &a, &b);
		e[a].push_back(b);
		e[b].push_back(a);
	}
//	puts("here");
	for(int i = 1; i <= n; i++) {
		scanf("%d", &t[i]);
		v[t[i]].push_back(i);
		cnt.insert(t[i]);
	}
//	puts("here");
	set<int>::iterator it;
	for(it = cnt.begin(); it != cnt.end(); it++) {
		int num = *it;
		q.push({v[num].size(), num});
	}
	bool flag = 1;
	vector<int> res;
	while(!q.empty()) {
		int x = q.top().first, y = q.top().second; q.pop();
		for(int i = 0; i < x; i++) {
			int node = v[y][i];
			if(check(node)) res.push_back(node);
			else {
				flag = 0;
				break;
			}
		}
		if(!flag) break;
	}
	if(!flag) {
		puts("-1");
		return;
	}
	for(int i = 0; i < n; i++) printf("%d ", res[i]);
	puts("");
}

int main() {
//	FRE;
//	int t; scanf("%d", &t); while(t--)
	solve();
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define IOS std::ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define FRE freopen("in.txt", "r", stdin);
#define endl "\n"
#define PI acos(-1.0)
typedef long long LL;
typedef pair<int, int> PII;
const double eps = 1e-8;
const int inf = 0x3f3f3f3f;
const LL INF = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9 + 7;
const int N = 5e5 + 10, M = 17;

inline int read() {
  int x = 0, neg = 1; char op = getchar();
  while (!isdigit(op)) { if (op == '-') neg = -1; op = getchar(); }
  while (isdigit(op)) { x = 10 * x + op - '0'; op = getchar(); }
  return neg * x;
}

inline void print(int x) {
  if (x < 0) { putchar('-'); x = -x; }
  if (x >= 10) print(x / 10);
  putchar(x % 10 + '0');
}

set<int> cnt;
int t[N];
priority_queue<PII, vector<PII>, greater<PII> > q;
vector<int> v[N];
vector<int> e[N];

bool check(int x) {
	for(int i = 0; i < e[x].size(); i++) {
		if(t[x] == t[e[x][i]]) return false;
	}
	return true;
}

void solve() {
	int n, m;
	scanf("%d%d", &n, &m);

	// ���
	while(m--) {
		int a, b;
		scanf("%d%d", &a, &b);
		e[a].push_back(b);
		e[b].push_back(a);
	}

	// ��¼ÿ��������
	for(int i = 1; i <= n; i++) {
		scanf("%d", &t[i]);
		v[t[i]].push_back(i);
		cnt.insert(t[i]);
	}

	// �ж��Ƿ�����Ҫ��
	bool flag = 1;
	for(int i = 1; i <= n; i++) {
		if(!check(i)) {
			flag = 0;
			break;
		}
	}
	if(!flag) {
		puts("-1");
		return;
	}

	// ��¼��
	vector<int> res;
	set<int>::iterator it;
	for(it = cnt.begin(); it != cnt.end(); it++) {
		int num = *it;
		q.push({v[num].size(), num});
	}

	set<int> ok;
	int x = q.top().first, y = q.top().second;
	for(int i = 0; i < x; i++) {
		int node = v[y][i];
		ok.insert(node);
		for(int j = 0; j < e[node].size(); j++) {
			ok.insert(e[node][j]);
		}
	}
//	printf("size = %d\n", ok.size());
	if(ok.size() != n) {
		puts("-1");
		return;
	}

	while(!q.empty()) {
		x = q.top().first, y = q.top().second; q.pop();
		for(int i = 0; i < x; i++) {
			res.push_back(v[y][i]);
		}
	}
	for(int i = 0; i < n; i++) printf("%d ", res[i]);
	puts("");
}

int main() {
//	FRE;
//	int t; scanf("%d", &t); while(t--)
	solve();
	return 0;
}