const maxn=338;
var n,u,v,i,j,tot:longint;
ch:array[0..5100] of longint;
function cc(x,y:longint):longint;
var k,temp:longint;
c:array[0..5100] of longint;
begin
if (x=y) then exit(1);
c[0]:=1;
for k:=1 to y do c[k]:=((c[k-1]*(x-k+1))div k) mod maxn;
exit(c[y]);
end;
begin
assign(input,'hopetree.in');
assign(output,'hopetree.out') ;
reset(input);
rewrite(output);
tot:=0;
readln(n);
fillchar(ch,sizeof(ch),0);
for i:=1 to n-1 do begin
readln(u,v);
inc(ch[u]);inc(ch[v]);
end;
for i:=1 to n do
if (ch[i]>=3) then tot:=(tot+cc(ch[i],3)) mod maxn;
inc(tot);
write(tot,' ');
dec(tot);
tot:=(tot+233) mod maxn+1;
writeln(tot);
close(input);
close(output);
end.