The Mario series is a series of highly popular and acclaimed video games by Nintendo, featuring Nintendo's mascot Mario and, in many games, his brother Luigi and his best friend Yoshi. Gameplay in the series often centers around jumping on and defeating enemies. The games usually feature simple plots; the most common theme is that of Bowser, the primary antagonist, kidnapping Princess Peach, whom Mario saves. Despite the plots usually being very simple, the Mario role-playing games tend to have deeper plots, often involving enemies other than Bowser (many of which involve Bowser actually teaming up with Mario), with aspirations for world domination. Mario has been featured in 200 games, and the series has sold over 200 million copies total, making it the best-selling video game series of all time.
Today,Mario comes to a forest,whick has many apple trees.These trees are special,the apples are grown in the nodes of the tree,whick is shown as follow.
Numbers in the nodes indicate the amount of apples which are also in this node. The root of a tree is also considered as a node too.
There are many trees in this forest, and some trees are connect by one-way road.
Mario is
start at a root, and he can jump along the branches up or down. Before each jump, he has to eat an apple, and after he eat an apple he have to jump up or down. Mario can walk along the roads too. He can walk along a road with at most an apple, or without any apple. These walks need not any apples. He can
finish his journey at any root. All the nodes, including normal node and root node, are numbered together from 1 to M.
How many apples is Mario able to eat at most?