#include<bits/stdc++.h>

using namespace std;

int main(){
  map<int , vector< pair<int, int > > > adjList;  // Seems like torture xD
  
  /***********Explanation************
  * Abstract form of a map = map< key, value >
  * Here key = int,
  *      Value = vector of pairs
  * Key is actually a node(let's say N) of graph here and 
  * Value is the vector containing all the nodes which are 
  * connected to N directly.
  * Why we need pair< d1, d2 > ?
  * d2 = node connected to N directly.
  * d1 = weight of edge between N and d2.
  * For unweighted graph we can use only int instead of pair
  * or we can keep value 0 for all edges if we use pair of
  * int like shown below.
  *************************************/
  // Suppose we are given number of edges 'n' and all the edges in form of (u, v). 
  // So we can use a for loop to scan inputs.
  
  int n;
  cin >> n;
  for(int i = 0 ; i < n ; i ++){
    int u, v;
    cin >> u >> v;
    // If graph is undirected:
    /* 1. */ adjList[u].push_back(make_pair(0, v));
    /* 2. */ adjList[v].push_back(make_pair(0, u));
    // If graph is directed from u to v
    // Then no need to write 2nd statement.
  }
  
  // Print Adjacency List
  
  for(map<int , vector< pair<int, int > > >::iterator it = adjList.begin() ; it != adjList.end() ; it++){
    cout << it->first << " : ";
    vector<pair<int, int> > neighbours = it->second;
    for(int i = 0 ; i < neighbours.size() ; i++){
      cout << "(" << neighbours[i].first << " " << neighbours[i].second << ")";
    }
    cout << endl;
  }
  
  
  
}