VPL1_BD - Autumn Leaves (Easy)

Kamshout arrived from a long journey. He was telling his selknam friends about what he had seen in the magical forest. Leaves were dyed orange before falling and sprouted again in spring. His friends laughed at him and Kamshout decided to return to the magical forest.

At the forest, and astonished by this phenomenon, he decided to analyze it more closely. He noticed that when a parrot sat on a branch the leaves started changing colors and fell. But each branch had a different resistance. The parrot sat on all the branches until all the leaves fell.

After observing this Kamshout wanted to count how many leaves fell and how many remained in the tree, after the parrot sat on X branches. Each time the parrot sits on a branch the resistance of all the leaves on the branch decreases (resistance equal to zero means that the leaf falls of the branch).

To remember if a leaf is affected by a branch or not he uses a matrix where column j corresponds to the leaf j and row i to the branch i. If the branch i affects the leaf j then the value will be 1 else it will be 0. He discretized the resistance values of leaves and arranged them in a vector where position ij indicated the resistance of leaf ij.

Input

The first line will contain an integer N and M, corresponding to the number of branches and leaves respectively. Followed by an N by M matrix where each position corresponds to the branch i and leaf j. N values will follow that represent the resistance Ti of each branch. After X values will follow that correspond to the branch number in which the parrot will sit. By seating, the parrot decrease the resistance of the branch by 1.

Output

One line containing the number of leaves left in the tree and how many leaves fell.

Example

Input:
4 4
1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1
5 4 2 1
1
2
3
4
0

Output:
3 1

Constraints

Subtask 1 (40%)

  • 0 < R < N
  • 0 < N, M < 100
  • 0 < Ti < 100
  • 0 < X < 100

Subtask 2 (60%)

  • 0 < R < N
  • 0 < N, M < 1,000
  • 0 < Ti < 10,000
  • 0 < X < 100,000

Added by:Venezuelan Programming League
Date:2013-03-08
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64

© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.