import java.util.*;
import java.io.*;

public class Main{
	public static LinkedList<Point> loadPoints(String fileName) /*throws IOException*/{
		LinkedList<Point> ret = new LinkedList<>();
		try{
			BufferedReader in = new BufferedReader(new FileReader(fileName));
			for(String l = in.readLine(); l!=null; l=in.readLine()){
				String[] s = l.split(" +");
				ret.add(new Point(Integer.parseInt(s[0]), Integer.parseInt(s[1])));
			}
		}catch(IOException ex){
			System.err.println("IOException while reading: "+fileName);
		}
		return ret;
	}

	public static void printPoints(TreeSet<Point> list){
		for(Point p : list){
			System.out.println(p);
		}
	}

	public static LinkedList<Tort> loadFrac(String fileName){
		LinkedList<Tort> ret = new LinkedList<>();
		try{
			BufferedReader in = new BufferedReader(new FileReader(fileName));
			for(String l = in.readLine(); l!=null; l=in.readLine()){
				String[] s = l.split(" +");
				ret.add(new Tort(Integer.parseInt(s[0]), Integer.parseInt(s[1])));
			}
		}catch(IOException ex){
			System.err.println("IOException while reading: "+fileName);
		}
		return ret;
	}

	public static void printFrac(TreeSet<Tort> list){
		for(Tort t : list){
			System.out.println(t);
		}
	}


	public static void main(String[] args){
		TreeSet<Point> lista=new TreeSet<>();
		for(Point p : loadPoints("input.txt")){
			lista.add(p);
		}
		printPoints(lista);
		TreeSet<Tort> lista2=new TreeSet<>();
		for(Tort t : loadFrac("input2.txt")){
			//System.out.print("Adding "+t+"... ");
			if(lista2.add(t)){
				//System.out.println("Added "+t);
			}else{
				//System.out.println(t+" was not added.");
			}
		}
		printFrac(lista2);
	}
}
