#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define space putchar(' ')
#define enter putchar('\n')
#define MAXN 4005
#define mp make_pair
#define pb push_back
//#define ivorysi
using namespace std;
typedef long long int64;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 + c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) out(x / 10);
    putchar('0' + x % 10);
}
int N,M;
struct node {
    int to,next;
}E[MAXN * 2];
int head[MAXN],sumE,d[MAXN],dep[MAXN],fa[MAXN],cnt[MAXN];
void add(int u,int v) {
    E[++sumE].to = v;
    E[sumE].next = head[u];
    head[u] = sumE;
}
void dfs(int u) {
    dep[u] = dep[fa[u]] + 1;
    for(int i = head[u] ; i ; i = E[i].next) {
	int v = E[i].to;
	if(v != fa[u]) {
	    fa[v] = u;
	    dfs(v);
	}
    }
}
int col(int u,int v) {
    if(dep[u] < dep[v]) swap(u,v);
    while(dep[u] != dep[v]) {
	++cnt[u];
	u = fa[u];
    }
    while(u != v) {
	++cnt[u];++cnt[v];
	u = fa[u];v = fa[v];
    }
}
vector<pii > Process(vector<pii> pth) {
    int x = 0;
    for(int i = 1 ; i <= N ; ++i) {
	if(d[i] == 1) {
	    x = i;break;
	}
    }
    d[x]--;int u = 0;
    for(int i = head[x] ; i ; i = E[i].next) {
	int v = E[i].to;
	if(d[v]) {
	    --d[v];u = v;break;
	}
    }
    if(!u) return pth;
    vector<pii > pass,npth;
    vector<int> id;
    id.clear();pass.clear();npth.clear();
    int pos[2005];
    int t,h;
    memset(pos,-1,sizeof(pos));
    for(int i = 0 ; i < pth.size() ; ++i){
	if(pth[i].fi == x && pth[i].se != x) {
	    pass.pb(pth[i]);id.pb(i);
	}
	else if(pth[i].fi != x && pth[i].se == x) {
	    swap(pth[i].fi,pth[i].se);
	    pass.pb(pth[i]);id.pb(i);
	}
	else {
	    npth.pb(pth[i]);
	    pos[i] = npth.size() - 1;
	}
    }
    t = npth.size();
    if(!pass.size()) return Process(pth);
    bool flag = 0;
    for(int i = 0 ; i < pass.size() ; i += 2) {
	if(i + 1 >= pass.size()) break;
	if(pass[i].se == pass[i + 1].se) swap(pth[id[i]].fi,pth[id[i]].se);
	npth.pb(mp(pass[i].se,pass[i + 1].se));
	pos[id[i]] = npth.size() - 1;
	pos[id[i + 1]] = npth.size() - 1;
    }
    if(pass.size() & 1) {
	flag = 1;
	h = pass.size() - 1;
	npth.pb(mp(u,pass[h].se));
	pos[id[h]] = npth.size() - 1;
    }
    npth = Process(npth);
    for(int i = 0 ; i < pth.size() ; ++i) {
	if(pos[i] < t) {pth[i] = npth[pos[i]];}
	else {
	    if(flag && i == id[h]) {
		if(npth[pos[i]].fi != u) swap(pth[i].fi,pth[i].se);
	    }
	    else {
		if(npth[pos[i]].fi != npth[pos[i]].se && npth[pos[i]].fi == pth[i].se) swap(pth[i].fi,pth[i].se);
	    }
	}
    }
    return pth;
}
void Solve() {
    read(N);read(M);
    int a,b;
    for(int i = 1 ; i < N ; ++i) {
	read(a);read(b);
	add(a,b);add(b,a);
	++d[a];++d[b];
    }
    dfs(1);
    vector<pii > v;
    for(int i = 1 ; i <= M ; ++i) {
	read(a);read(b);
	v.pb(mp(a,b));col(a,b);
    }
    v = Process(v);
    int ans = 0;
    for(int i = 1 ; i <= N ; ++i) ans += min(2,cnt[i]);
    out(ans);enter;
    for(int i = 0 ; i < v.size() ; ++i) {
	out(v[i].fi);space;out(v[i].se);enter;
    }
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
}


Measured memory_bytes: 56192