#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[v] < sz[heavy])){
v = heavy;
}
}
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);
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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IC0xOwogICAgZm9yIChpbnQgdiA6IGdbdV0pewogICAgICAgIGlmICh2ICE9IHBbdV0gJiYgKGhlYXZ5ID09IC0xIHx8IHN6W3ZdIDwgc3pbaGVhdnldKSl7CiAgICAgICAgICAgIHYgPSBoZWF2eTsKICAgICAgICB9CiAgICB9CiAgICBpZiAoaGVhdnkgIT0gLTEpewogICAgICAgIGhsZChoZWF2eSk7CiAgICB9CiAgICBmb3IgKGludCB2IDogZ1t1XSl7CiAgICAgICAgaWYgKHYgIT0gcFt1XSAmJiB2ICE9IGhlYXZ5KXsKICAgICAgICAgICAgbnVtQ2hhaW4rKzsKICAgICAgICAgICAgaGxkKHYpOwogICAgICAgIH0KICAgIH0KfQoKaW50IGxjYShpbnQgdSAsIGludCB2KXsKICAgIHdoaWxlIChjaGFpblt1XSAhPSBjaGFpblt2XSl7CiAgICAgICAgaWYgKGhbaGVhZFtjaGFpblt1XV1dID4gaFtoZWFkW2NoYWluW3ZdXV0pIHN3YXAodSAsIHYpOwogICAgICAgIHYgPSBwW2hlYWRbY2hhaW5bdl1dXTsKICAgIH0KICAgIGlmIChoW3VdID4gaFt2XSkgc3dhcCh1ICwgdik7CiAgICByZXR1cm4gdTsKfQoKc3RydWN0IGZlbndpY2h7CiAgICBpbnQgdFttYXhOXTsKCiAgICB2b2lkIHJlc2V0KCl7CiAgICAgICAgZm9yIChpbnQgaSA9IDEgOyBpIDw9IG4gOyBpKyspIHRbaV0gPSAwOwogICAgfQoKICAgIHZvaWQgdXBkYXRlKGludCB4ICwgaW50IHkpewogICAgICAgIGZvciAoOyB4IDw9IG4gOyB4ICs9IHgmLXgpIHRbeF0gKz0geTsKICAgIH0KCiAgICB2b2lkIHVwZGF0ZShpbnQgbCAsIGludCByICwgaW50IHgpewogICAgICAgIHVwZGF0ZShsICwgK3gpOwogICAgICAgIHVwZGF0ZShyICsgMSAsIC14KTsKICAgIH0KCiAgICBpbnQgZ2V0KGludCB4KXsKICAgICAgICBpbnQgYW5zID0gMDsKIC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TsKICAgICAgICB1ID0gbnh0W3Jvb3QodSldOwogICAgfQogICAgaWYgKGlkX3F1ZXJ5W3VdICE9IDAgJiYgaWRfcXVlcnlbdV0gIT0gaWQpewogICAgICAgIGlmICh2aXNbaWRfcXVlcnlbdV1dID09IDApIGRmcyhpZF9xdWVyeVt1XSk7CiAgICB9CiAgICB0b3BvLnB1c2hfYmFjayhpZCk7Cn0KCnZvaWQgcHJpbnQoKXsKICAgIGZlbi5yZXNldCgpOwogICAgcmV2ZXJzZShhbGwodG9wbykpOwogICAgZm9yIChpbnQgeCA6IHRvcG8pewogICAgICAgIGludCB1ID0gc1t4XTsKICAgICAgICBpbnQgdiA9IHRbeF07CiAgICAgICAgaW50IHZjbCA9IGxjYSh1ICwgdik7CiAgICAgICAgaW50IG51bSA9IChmZW4uZ2V0KGluW3VdKSArIGZlbi5nZXQoaW5bdl0pKSAtIChmZW4uZ2V0KGluW3ZjbF0pICsgZmVuLmdldChpbltwW3ZjbF1dKSk7CiAgICAgICAgaWYgKG51bSA+IDApewogICAgICAgICAgICBjb3V0IDw8ICItMVxuIjsKICAgICAgICAgICAgcmV0dXJuOwogICAgICAgIH0KICAgICAgICBmZW4udXBkYXRlKGluW3VdICwgb3V0W3VdICwgKzEpOwogICAgfQogICAgcmV2ZXJzZShhbGwodG9wbykpOwogICAgZm9yIChpbnQgeCA6IHRvcG8pIGNvdXQgPDwgeCA8PCAiICI7Cn0KCmludCBpZFttYXhOXTsKCnZvaWQgc29sdmUoKXsKICAgIGNpbiA+PiBuID4+IG07CiAgICBmb3IgKGludCBpID0gMSA7IGkgPCBuIDsgaSsrKXsKICAgICAgICBpbnQgdSAsIHY7CiAgICAgICAgY2luID4+IHUgPj4gdjsKICAgICAgICBnW3VdLnB1c2hfYmFjayh2KTsKICAgICAgICBnW3ZdLnB1c2hfYmFjayh1KTsKICAgIH0KICAgIGRmc19pbml0KDEpOwogICAgZm9yIChpbnQgaSA9IDEgOyBpIDw9IG0gOyBpKyspewogICAgICAgIGNpbiA+PiBzW2ldID4+IHRbaV07CiAgICAgICAgaWRfcXVlcnlbc1tpXV0gPSBpOwogICAgICAgIGlkW2ldID0gaTsKICAgIH0KICAgIGluaXQoKTsKICAgIHNvcnQoaWQgKyAxICwgaWQgKyBtICsgMSAsIFtdKGludCB4ICwgaW50IHkpewogICAgICAgICByZXR1cm4gaFtzW3hdXSA+IGhbc1t5XV07CiAgICB9KTsKICAgIGZvciAoaW50IGkgPSAxIDsgaSA8PSBtIDsgaSsrKXsKICAgICAgICBpZiAodmlzW2lkW2ldXSA9PSAwKSBkZnMoaWRbaV0pOwogICAgfQogICAgcHJpbnQoKTsKfQoKI2RlZmluZSBuYW1lICJFIgoKaW50IG1haW4oKXsKICAgIGlvc19iYXNlOjpzeW5jX3dpdGhfc3RkaW8oMCk7IGNpbi50aWUoMCk7IGNvdXQudGllKDApOwogICAgaWYgKGZvcGVuKG5hbWUiLklOUCIgLCAiciIpKXsKICAgICAgICBmcmVvcGVuKG5hbWUiLklOUCIgLCAiciIgLCBzdGRpbik7CiAgICAgICAgZnJlb3BlbihuYW1lIi5PVVQiICwgInciICwgc3Rkb3V0KTsKICAgIH0KICAgIGludCB0ID0gMTsgLy9jaW4gPj4gdDsKICAgIHdoaWxlICh0LS0pIHNvbHZlKCk7CiAgICByZXR1cm4gMDsKfQoK