#include<bits/stdc++.h>
using namespace std;
const int maxn = 200000 + 10;

int n, m, h[maxn], ecnt, acnt;
struct enode{
	int v, n;
	enode() {}
	enode(int _v, int _n):v(_v), n(_n) {}
}e[maxn << 1];
struct anode{
	int x, y;
	anode() {}
	anode(int _x, int _y):x(_x), y(_y) {}
}a[maxn];

inline void addedge(int u, int v) { ecnt ++; e[ecnt] = enode(v,h[u]); h[u] = ecnt; }

int pre[maxn], dep[maxn], dfn[maxn], lst[maxn], tim;
void predfs(int u, int fa) {
	tim ++; dfn[u] = tim;
  pre[u] = fa; dep[u] = dep[fa] + 1;
	for(int i = h[u];~ i;i = e[i].n) {
		int v = e[i].v;
		if(v == fa) continue;
		predfs(v,u);
	}
	lst[u] = tim;
}

vector<int> lis[maxn];
int sfa[maxn], used[maxn], d[maxn], ch[maxn][2];

int findfa(int u) { return (sfa[u] == u) ? (u) : (sfa[u] = findfa(sfa[u])); }

inline void work(int u, int v, int id) {
	if(dep[u] < dep[v]) swap(u,v);
	while(dep[u] > dep[v]) {
		lis[u].push_back(id);
		u = pre[u];
	}
	if(u == v) return;
	while(pre[u] != pre[v]) {
		lis[u].push_back(id);
		lis[v].push_back(id);
		u = pre[u], v = pre[v];
	}
	lis[u].push_back(id);
	lis[v].push_back(id);
}

int col[maxn];

inline void addcol(int u, int v, int c) {
	if(dep[u] < dep[v]) swap(u,v);
	while(dep[u] > dep[v]) {
		col[u] |= c;
		u = pre[u];
	}
	if(u == v) {
		col[u] |= c;
		return;
	}
  while(pre[u] != pre[v]) {
		col[u] |= c;
		col[v] |= c;
		u = pre[u], v = pre[v];
	}
	col[u] |= c;
	col[v] |= c;
	col[pre[u]] |= c;
}

inline void calc(int x, int y, int u) {
	memset(col,0,sizeof(col));
	addcol(a[x].x,a[x].y,1);
	addcol(a[y].x,a[y].y,2);
	while(col[pre[u]] == 3) {
		used[u] = 1;
		u = pre[u];
	}
}

int Ans = 0;
void dfs1(int u, int fa) {
  for(int i = h[u];~ i;i = e[i].n) {
		int v = e[i].v;
		if(v == fa) continue;
		dfs1(v,u);
	}
	Ans += min((int)lis[u].size(),2);
}

void dfs2(int u, int fa) {
	for(int i = h[u];~ i;i = e[i].n) {
		int v = e[i].v;
		if(v == fa) continue;
		dfs2(v,u);
	}
	int Sz = lis[u].size();
	int x = -1, y = -1;
	for(int i = 0;i < Sz;i ++) {
		int v = findfa(lis[u][i]);
		if(x == -1) x = v;
		else {
			if(x == v) continue;
			y = v;
			break;
		}
	}
	if(y == -1 || used[u]) return;
//	cout << u << endl;
  calc(x,y,u);
	if(dfn[u] <= dfn[a[x].x] && dfn[a[x].x] <= lst[u]) swap(a[x].x,a[x].y);
	if(dfn[u] <= dfn[a[y].y] && dfn[a[y].y] <= lst[u]) swap(a[y].x,a[y].y);
	int p = ++ acnt;
	a[p] = anode(a[x].x,a[y].y);
	ch[p][0] = x; ch[p][1] = y;
//	d[x] ++; d[y] ++;
	sfa[x] = sfa[y] = sfa[p] = p;
}

void dfs3(int u) {
	int ls = ch[u][0], rs = ch[u][1];
	if(!ls && !rs) return;
	if(a[u].x != a[ls].x) swap(a[ls].x,a[ls].y), swap(a[rs].x,a[rs].y);
	dfs3(ls);
	dfs3(rs);
}

int val[maxn];

inline void Check_add(int u, int v) {
	while(dep[u] > dep[v]) {
		val[u] |= 1;
		u = pre[u];
	}
	while(dep[u] < dep[v]) {
		val[v] |= 2;
		v = pre[v];
	}
	if(u == v) return;
	while(pre[u] != pre[v]) {
		val[u] |= 1;
		val[v] |= 2;
		u = pre[u], v = pre[v];
	}
	val[u] |= 1, val[v] |= 2;
}

int res;

inline int calc_sum(int x) {
	if(x == 0) return 0;
	if(x == 1 || x == 2) return 1;
	if(x == 3) return 2;
}

void dfs_ch(int u, int fa) {
  res += min(2,calc_sum(val[u]));
	for(int i = h[u];~ i;i = e[i].n) {
		int v = e[i].v;
		if(v == fa) continue;
		dfs_ch(v,u);
	}
}

inline void Check() {
  memset(val,0,sizeof(val));
	for(int i = 1;i <= m;i ++) {
    Check_add(a[i].x,a[i].y);
	}
	res = 0;
	dfs_ch(1,0);
	if(res == Ans) puts("Yes");
	else puts("No");
}

int main() {
	scanf("%d%d", &n, &m); ecnt = 0;
	memset(h,-1,sizeof(h));
	for(int i = 1;i < n;i ++) {
		int u, v;
		scanf("%d%d", &u, &v);
		addedge(u,v);
		addedge(v,u);
	}
	tim = dfn[0] = 0;
	predfs(1,0);
	for(int i = 1;i <= m;i ++) {
		int u, v;
		scanf("%d%d", &u, &v);
		a[i] = anode(u,v);
		work(u,v,i);
		sfa[i] = i;
	}
	acnt = m;
	dfs1(1,0);
	dfs2(1,0);
	for(int i = 1;i <= acnt;i ++) {
		if(sfa[i] != i) continue;
		dfs3(i);
	}
	printf("%d\n", Ans);
//  Check();
//	/*
	for(int i = 1;i <= m;i ++) {
		printf("%d %d\n", a[i].x, a[i].y);
	}
//	*/
	return 0;
}


Measured memory_bytes: 24320