ENV[Z='RUBY_THREAD_VM_STACK_SIZE']||exec({Z=>?5*8},'ruby',$0);M=10**9+7;G=(0..gets.to_i).map{[]};$<.map{|s|a,b=s.split.map &:to_i;G[a]<<b;G[b]<<a};F=->x,y{w=b=1;G[x].map{|e|(c,d=F[e,x];w*=d;b*=c)if e!=y};[w%=M,b+w]};p F[1,0][1]%M