def node_degree(nodes):
	num_of_nodes,connections = nodes.split('\n')[0],nodes.split('\n')[1:]
	node_dict = {}
	i = 1
	while i <= int(num_of_nodes):
		node_dict[str(i)]=Node(i)
		i += 1
	for connection in connections:

		first_node = node_dict[connection.split()[0]]
		second_node = node_dict[connection.split()[1]]
		first_node.degree += 1 
		second_node.degree += 1 
		first_node.connections += [second_node]
		second_node.connections += [first_node]
	for node in sorted(node_dict.values(), key= lambda node: node.value):
		print "Node",node.value,'has a degree of ',node.degree
class Node:
	def __init__(self,value):
		self.value = value
		self.degree = 0
		self.connections = []
	def __repr__(self):
		return "Node " + str(self.value)

n1="""16
1 2
1 3
2 3
1 4
3 4
1 5
2 5
1 6
2 6
3 6
3 7
5 7
6 7
3 8
4 8
6 8
7 8
2 9
5 9
6 9
2 10
9 10
6 11
7 11
8 11
9 11
10 11
1 12
6 12
7 12
8 12
11 12
6 13
7 13
9 13
10 13
11 13
5 14
8 14
12 14
13 14
1 15
2 15
5 15
9 15
10 15
11 15
12 15
13 15
1 16
2 16
5 16
6 16
11 16
12 16
13 16
14 16
15 16"""

node_degree(n1)