#include<iostream>
using namespace std;struct Node
{int vertex;
Node *firstedge;};voidNo_Graph(){int m, n;
cin >> m >> n;int r, c;int*b = new int[m];for(int i =0; i < m; i++)
b[i]=0;int**a = new int*[m];for(int i =0; i < m; i++)
a[i]= new int[m];for(int i =0; i < m; i++)for(int j =0; j < m; j++)
a[i][j]=0;for(int i =0; i < n; i++){
cin >> r >> c;
a[r][c]=1;
a[c][r]=1;}for(int i =0; i < m; i++)for(int j =0; j < m; j++){
b[i]+= a[i][j];}for(int i =0; i < m; i++)
cout << i <<" "<< b[i]<< endl;}voidGraph(){
Node *s =NULL;int m, n;int r, c;
cin >> m >> n;
Node *a = new Node[m];for(int i =0; i < m; i++){
a[i].vertex = i;
a[i].firstedge =NULL;}for(int i =0; i < n; i++){
cin >> r >> c;if(a[r].firstedge ==NULL){
Node *p = new Node;
p->vertex = c;
p->firstedge =NULL;
a[r].firstedge = p;
s = p;}elseif(a[r].firstedge !=NULL){
Node *p = new Node;
p->vertex = c;
p->firstedge =NULL;
s->firstedge = p;
s = p;}}int*b = new int[m];for(int i =0; i < m; i++)
b[i]=0;for(int i =0; i < m; i++){
Node *p;
p = a[i].firstedge;int l =0;while(p){
b[p->vertex]++;
p = p->firstedge;
l++;}
b[i]+=l;}for(int i =0; i < m; i++)
cout << i <<" "<< b[i]<< endl;}intmain(){int y;while(cin >> y){switch(y){case1:No_Graph();break;case2:Graph();break;default:return0;}}}