#!/usr/bin/python
# Encoding: utf8

##Given a word W as argument, this script creates all possible pairs with W and the rest of words from the matrix

# INPUT: non-zero matrix (filtered)
# ARGUMENT: a specific word
# OUTPUT: all pairs of words for a given word

import sys
import re
import math
from collections import defaultdict

target = sys.argv[1]
w = defaultdict(int)



for line in sys.stdin:  
    line = line.strip() 
    line = line.split()
    if len(line) >= 3:
        word = line[0]
      
        w[word] += 1

for word in sorted(w):
    print '%s %s' % (target, word)
        
