#include <bits/stdc++.h>
#define fi first
#define se second
#define all(v) v.begin() , v.end()
#define sz(v) int(v.size())
#define unq(v) sort(all(v)); v.resize(unique(all(v)) - v.begin());
using namespace std;
typedef long long ll;
typedef pair<int , int> ii;
typedef pair<long long , int> lli;
const int maxN = int(5e5)+7;
int n , m;
int id_query[maxN] , s[maxN] , t[maxN];
vector<int> g[maxN];
int fa[maxN] , nxt[maxN];
int h[maxN] , p[maxN] , sz[maxN] , in[maxN] , out[maxN] , DfsTime = 0;
void dfs_init(int u){
in[u] = ++DfsTime;
sz[u] = 1;
for (int v : g[u]){
if (v != p[u]){
p[v] = u;
h[v] = h[u] + 1;
dfs_init(v);
sz[u] += sz[v];
}
}
out[u] = DfsTime;
}
int head[maxN] , chain[maxN] , pos[maxN] , numChain = 0 , numPos = 0;
void hld(int u){
if (head[numChain] == 0) head[numChain] = u;
chain[u] = numChain;
pos[u] = ++numPos;
int heavy = -1;
for (int v : g[u]){
if (v != p[u] && (heavy == -1 || sz[heavy] < sz[v])) heavy = v;
}
if (heavy != -1) hld(heavy);
for (int v : g[u]){
if (v != p[u] && v != heavy){
numChain++;
hld(v);
}
}
}
int lca(int u , int v){
while (chain[u] != chain[v]){
if (h[head[chain[u]]] > h[head[chain[v]]]) swap(u , v);
v = p[head[chain[v]]];
}
if (h[u] > h[v]) swap(u , v);
return u;
}
struct fenwich{
int t[maxN];
void reset(){
for (int i = 1 ; i <= n ; i++) t[i] = 0;
}
void update(int x , int y){
for (; x <= n ; x += x&-x) t[x] += y;
}
void update(int l , int r , int x){
update(l , +x);
update(r + 1 , -x);
}
int get(int x){
int ans = 0;
for (; x >= 1 ; x -= x&-x) ans += t[x];
return ans;
}
} fen;
void init(){
for (int i = 1 ; i <= n ; i++){
fa[i] = -1;
nxt[i] = i;
}
}
int root(int x){
if (fa[x] < 0) return x; else return fa[x] = root(fa[x]);
}
void unite(int u , int v){
u = root(u);
v = root(v);
if (u == v) return;
if (-fa[u] < -fa[v]) swap(u , v);
fa[u] += fa[v];
fa[v] = u;
if (h[nxt[u]] > h[nxt[v]]) nxt[u] = nxt[v];
}
vector<int> topo;
bool vis[maxN] , cycle = false;
void dfs(int id){
vis[id] = 1;
int u = nxt[root(s[id])] , v = nxt[root(t[id])];
while (u != v){
if (h[u] < h[v]) swap(u , v);
if (id_query[u] != 0 && id_query[u] != id){
if (vis[id_query[u]] == 0){
dfs(id_query[u]);
}
}
unite(u , p[u]);
u = nxt[root(u)];
}
if (id_query[u] != 0 && id_query[u] != id){
if (vis[id_query[u]] == 0) dfs(id_query[u]);
}
topo.push_back(id);
}
void print(){
fen.reset();
reverse(all(topo));
for (int x : topo){
int u = s[x];
int v = t[x];
int vcl = lca(u , v);
int num = (fen.get(in[u]) + fen.get(in[v])) - (fen.get(in[vcl]) + fen.get(in[p[vcl]]));
if (num > 0){
cout << "-1\n";
return;
}
fen.update(in[u] , out[u] , +1);
}
reverse(all(topo));
for (int x : topo) cout << x << " ";
}
int id[maxN];
void solve(){
cin >> n >> m;
for (int i = 1 ; i < n ; i++){
int u , v;
cin >> u >> v;
g[u].push_back(v);
g[v].push_back(u);
}
dfs_init(1);
hld(1);
for (int i = 1 ; i <= m ; i++){
cin >> s[i] >> t[i];
id_query[s[i]] = i;
id[i] = i;
}
init();
sort(id + 1 , id + m + 1 , [](int x , int y){
return h[s[x]] > h[s[y]];
});
for (int i = 1 ; i <= m ; i++){
if (vis[id[i]] == 0) dfs(id[i]);
}
print();
}
#define name "E"
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
if (fopen(name".INP" , "r")){
freopen(name".INP" , "r" , stdin);
freopen(name".OUT" , "w" , stdout);
}
int t = 1; //cin >> t;
while (t--) solve();
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNkZWZpbmUgZmkgZmlyc3QKI2RlZmluZSBzZSBzZWNvbmQKI2RlZmluZSBhbGwodikgdi5iZWdpbigpICwgdi5lbmQoKQojZGVmaW5lIHN6KHYpIGludCh2LnNp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IC0xOwogICAgZm9yIChpbnQgdiA6IGdbdV0pewogICAgICAgIGlmICh2ICE9IHBbdV0gJiYgKGhlYXZ5ID09IC0xIHx8IHN6W2hlYXZ5XSA8IHN6W3ZdKSkgaGVhdnkgPSB2OwogICAgfQogICAgaWYgKGhlYXZ5ICE9IC0xKSBobGQoaGVhdnkpOwogICAgZm9yIChpbnQgdiA6IGdbdV0pewogICAgICAgIGlmICh2ICE9IHBbdV0gJiYgdiAhPSBoZWF2eSl7CiAgICAgICAgICAgIG51bUNoYWluKys7CiAgICAgICAgICAgIGhsZCh2KTsKICAgICAgICB9CiAgICB9Cn0KCmludCBsY2EoaW50IHUgLCBpbnQgdil7CiAgICB3aGlsZSAoY2hhaW5bdV0gIT0gY2hhaW5bdl0pewogICAgICAgIGlmIChoW2hlYWRbY2hhaW5bdV1dXSA+IGhbaGVhZFtjaGFpblt2XV1dKSBzd2FwKHUgLCB2KTsKICAgICAgICB2ID0gcFtoZWFkW2NoYWluW3ZdXV07CiAgICB9CiAgICBpZiAoaFt1XSA+IGhbdl0pIHN3YXAodSAsIHYpOwogICAgcmV0dXJuIHU7Cn0KCnN0cnVjdCBmZW53aWNoewogICAgaW50IHRbbWF4Tl07CgogICAgdm9pZCByZXNldCgpewogICAgICAgIGZvciAoaW50IGkgPSAxIDsgaSA8PSBuIDsgaSsrKSB0W2ldID0gMDsKICAgIH0KCiAgICB2b2lkIHVwZGF0ZShpbnQgeCAsIGludCB5KXsKICAgICAgICBmb3IgKDsgeCA8PSBuIDsgeCArPSB4Ji14KSB0W3hdICs9IHk7CiAgICB9CgogICAgdm9pZCB1cGRhdGUoaW50IGwgLCBpbnQgciAsIGludCB4KXsKICAgICAgICB1cGRhdGUobCAsICt4KTsKICAgICAgICB1cGRhdGUociArIDEgLCAteCk7CiAgICB9CgogICAgaW50IGdldChpbnQgeCl7CiAgICAgICAgaW50IGFucyA9IDA7CiAgICAgICAgZm9yICg7IHggPj0gMSA7IHggLT0geCYteCkgYW5zICs9IHR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