Rock, Paper, Scissors

No attempts yetTime limit1sMemory limit1024 MB

Problem

Vilius and Adomas play Rock, Paper, Scissors. Together they count "one… two… three…" while swinging their fists, and on "three" each player shows one of three signs with one hand: rock, paper, or scissors. The winner of a round is decided as follows.

  • Rock beats scissors.
  • Scissors beat paper.
  • Paper beats rock.
  • If both players show the same sign, the round is a tie.

They plan to play many rounds, so they agreed on the following scoring system.

  • Both players start with 0 points.
  • The winner of a round gains 1 point.
  • The loser of a round loses 1 point.
  • On a tie, neither player's score changes.

Vilius and Adomas have already played many rounds, but they have forgotten how many points they currently have! Each of them remembers how many times he showed each sign (rock, paper, and scissors), but not the order in which he showed them. Assuming the signs Vilius showed can be paired with the signs Adomas showed in any way (as long as the counts match), determine the maximum and the minimum number of points Vilius could have. (Once Vilius's score is known, they can work out Adomas's score themselves.)

Input

The first line contains three integers $a_1$, $p_1$, $z_1$ — the number of times Vilius showed rock, paper, and scissors, respectively. The second line contains $a_2$, $p_2$, $z_2$ — the corresponding counts for Adomas, in the same order.

Output

Print the maximum number of points Vilius could have on the first line, and the minimum number of points he could have on the second line.

Constraints

  • $0 \le a_1, p_1, z_1, a_2, p_2, z_2 \le 1000$
  • $a_1 + p_1 + z_1 = a_2 + p_2 + z_2$