50154. Path within a Network

I'm a slow walker, but I never walk backwards.

Task Description

We have a starting point, an end point, and seven clusters A, B, C, D, E, F, and G in a network. Each cluster consists of nodes, and there are five sets of directed paths among the starting point, the end point, and the seven clusters.

  • There is an edge from the starting point to every node in A, B, C, and D.
  • There is an edge from every node of A, B, and C, to every node of E.
  • There is an edge from every node of C and D, to every node of F.
  • There is an edge from every node of E, to every node of G.
  • There is an edge from every node of F and G, to the end point.

For example, the following figure shows the graph when the number of nodes in A, B, C, D, E, F, and G are 3, 2, 2, 2, 2, 3, and 2 respectively.

Now given the numbers of nodes in the seven clusters, write a program to compute the total number of edges, and the number of different paths from the starting point to the end point.

Input Format

There are seven lines in the input. The number in the first line is the number of nodes in A, the number in the second line is the number of nodes in B, and so on. All calculcation is in int and you do not need to worry about overflow.

Output Format

Output the total number of edges in the first line, and the number of different paths from the starting point to the end point in the second line.

Sample Input

3
2
2
2
2
3
2

Sample Output

44
40

Discussion