# 1775. Jack and the Beanstalk

Once upon a time there was a poor widow who had an only son named Jack. All that they had was the house they lived in and a cow. At last they became too poor to keep the cow. The widow said to Jack one day, “Take this cow to the market and sell her. Then we’ll be able to buy bread. Try to get as much money as you can.” Jack, who was a good, but thoughtless boy, started for the market with his cow.

On his way to the market he met a man who had a pig with him.

“Good morning,” said the man.

“Won’t you give me your old cow for this fat young pig?” said the man.

Jack thought it a good idea. So he ax-changed his old cow for the young pig He walked on happily until he met another man who had some fine beans.

“These are magic beans,” said the man. “I’ll give you one of them, if you give me that pig.”

Jack thought it wonderful to have a magic bean. So he consented to it and carried the bean proudly back home. He showed the bean to his mother.

“Is this all that you have got for that cow?” she said. “Now, we have on cow to give us milk. All we have is this bean.” She got angry. She threw it out of the window. The bean fell in their garden.

During that night is sprouted and grew in a wonderful way. When jack and his mother woke the next morning, they saw that the beanstalk had grown so high that they could not see the top Jack made up his mind to climb to the top of the beanstalk. Higher and higher up he climbed until he found himself near a window of an old castle. Looking in, Jack saw a giant eating his, dinner. The giant finished his dinner and ordered his servant to bring his chief treasures, a hen and a harp.

“Lay eggs,” said the giant to the hen. The hen began to lay eggs. They were eggs of gold. “Play,” said the giant to the harp. The harp began to play sweet music. The harp played on and on until the giant grew tired and fell asleep.

Now Jack and the Beanstalk find a way to play, they choose a number from the rectangle in turn, and the score they gain is the number, so every time they choose the largest number from the rectangle and delete it, until there is no number in the rectangle any more. Then you must output two number of their score. Jack always choose first.

Then, you can enjoy this story of the second part:

Jack had crawled into the room by this time. When the giant was asleep, a servant beckoned to Jack.

“Look here. These are the treasures which the giant stole from your father before you were born,” said he. “Take them back to your mother, if you like. But, be quiet. He may wake.”

Jack thanked him, and picked up the hen and the harp very carefully. When he was climbing down the beanstalk, the harp happened to make a loud noise. The giant woke. Jack climbed down the beanstalk, with the hen and the harp under his arms. The giant ran down after Jack, but Jack ran faster than the giant. When he was near his home, he called out to his mother, “Mother, bring an ax.” His mother brought an ax. She saw her son climbing down the beanstalk. As soon as he got down to the ground, he chopped down the beanstalk. Down fell the giant with the beanstalk. He broke his neck, and was dead.

Jack and his mother were rich all the rest of their lives and lived happily ever after.

### 输入格式

Two number $n \ m$ ($1 \le n, m \le 1000$), is the size of the rectangle. then $nm$ number followed.

### 输出格式

Output the two numbers.

### 样例

Input
6 6
41 44 16 14 31 66
1 50 49 9 91 95
37 11 39 60 25 35
75 15 28 55 64 93
70 18 97 63 74 95
58 74 17 77 41 61

Output
925 864


1 人解决，15 人已尝试。

1 份提交通过，共有 46 份提交。

9.9 EMB 奖励。