import Data.Char
import Data.List
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector as V
main=putStrLn.solve.map(unfoldr$B.readInt.B.dropWhile isSpace).B.lines=<<B.getContents
solve([n,q]:abpx)=unwords.map show.V.toList.V.accum(+)(V.replicate n 0)$f 0 0 0 where
  (ab,px)=splitAt(n-1)abpx
  f x p v=((v,y):).concatMap(f y v).filter(/=p)$g V.! v where y=x+xs V.! v
  g=V.accum(flip(:))(V.replicate n[])$concatMap(\[a,b]->[(a-1,b-1),(b-1,a-1)])ab
  xs=V.accum(+)(V.replicate n 0)$map(\[p,x]->(p-1,x))px