#P381. 【例66.1】 图论入门

【例66.1】 图论入门

Description

Suppose an n×nn \times n array aa is used to represent the adjacency matrix of a directed graph:
(1) Write a function to determine the out-degree of a vertex.
(2) Write a function to determine the in-degree of a vertex.
(3) Write a function to determine the number of edges in the graph.

Input Format

The first line: total number of nodes nn, specified node mm, nodes are numbered starting from 11.
The next nn lines: the adjacency matrix of the directed graph.
1n,m,a[i][j]10001\leq n, m, a[i][j]\leq 1000

Output Format

The first line outputs three numbers: node number mm, the out-degree of mm, and the in-degree of mm (separated by spaces).
The second line outputs: the total number of edges in the graph.

Sample

5 3
0 4 2 2 3
2 0 1 5 10
2 0 0 4 0
0 3 7 0 7
6 2 0 0 0
3 2 3
15