#D10707. Gridgedge
Gridgedge
Gridgedge
Problem
There is a grid of squares with in the upper left and in the lower right. When you are in a square (, ), from there , , , , , , , can be moved at a cost of .. However, you cannot go out of the grid. When moving from the mass to , calculate the cost of the shortest path and the remainder of the total number of shortest path combinations divided by .
However, the combination of routes shall be distinguished by the method of movement. For example, if your current location is , you can go to with the above or to get to at the shortest cost. You can do it, so count it as .
Constraints
The input satisfies the following conditions.
- All inputs given are integers.
Input
The input is given in the following format.
Output
When moving from the mass to , the cost of the shortest path and the remainder of the total number of combinations of the shortest paths divided by are separated by . Print on a line.
Examples
Input
2 2 0 0 1 1
Output
2 8
Input
1 1 0 0 0 0
Output
0 1
Input
1 10 0 0 0 9
Output
1 1
Input
5 5 0 0 4 4
Output
2 2
Input
421 435 196 169 388 9
Output
43 917334776
inputFormat
input satisfies the following conditions.
- All inputs given are integers.
Input
The input is given in the following format.
outputFormat
Output
When moving from the mass to , the cost of the shortest path and the remainder of the total number of combinations of the shortest paths divided by are separated by . Print on a line.
Examples
Input
2 2 0 0 1 1
Output
2 8
Input
1 1 0 0 0 0
Output
0 1
Input
1 10 0 0 0 9
Output
1 1
Input
5 5 0 0 4 4
Output
2 2
Input
421 435 196 169 388 9
Output
43 917334776
样例
5 5 0 0 4 4
2 2