import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class o2 {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(reader.readLine());
        ArrayList<String> dialogs = new ArrayList<>();
        for (int a = 0; a < n; a++) {
            String lol = reader.readLine();
            dialogs.remove(lol);
            dialogs.add(lol);
        }
        for (int a = dialogs.size(); a > 0; a--)
            System.out.println(dialogs.get(a-1));
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.LinkedList;

public class o2 {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(reader.readLine());
        LinkedList<String> dialogs = new LinkedList<>();
        for (int a = 0; a < n; a++) {
            String lol = reader.readLine();
            dialogs.remove(lol);
            dialogs.add(0, lol);
        }
        for (int a = 0; a < dialogs.size(); a++) {
            System.out.println(dialogs.get(a));
        }
    }
}


import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.*;

/**
 * Created by nod on 3/14/16.
 */
public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        TreeMap<String, Integer> m = new TreeMap<>();

        for(int i = 0; i < n; i++){
            String s = br.readLine();
            m.put(s,i);
        }

        SortedSet<Map.Entry<String,Integer>> ss = new TreeSet<>(
                new Comparator<Map.Entry<String,Integer>>() {
                    @Override
                    public int compare(Map.Entry<String,Integer> a, Map.Entry<String,Integer> b) {
                        return a.getValue() < b.getValue() ? -1 : 1;
                    }
                }
        );

        ss.addAll(m.entrySet());

        for(Map.Entry s : ss){
            BufferedWriter log = new BufferedWriter(new OutputStreamWriter(System.out));
            log.write(s.getKey()+"\n");
            log.flush();
        }
    }
}


import java.util.*;
import java.io.*;

/**
 * Created by nod on 3/14/16.
 */
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        LinkedList<String> ll = new LinkedList<>();
        in.nextLine();
        TreeSet<String> hs = new TreeSet<>();

        for(int i = 0; i < n; i++){
            String s = in.nextLine();
            if(hs.contains(s)){
                hs.add(s);
            }
            else {
                hs.add(s);
            }
        }
        Object[] str;
        str = hs.toArray();
        for(int i = hs.size(); i >= 0; i--){
            System.out.println(str[i]);
        }
    }
}


import java.util.LinkedList;
import java.util.Scanner;

/**
 * Created by nod on 3/14/16.
 */
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        LinkedList<String> ll = new LinkedList<>();

        for(int i = 0; i > n; i++){
            String s = in.nextLine();
            if(ll.contains(s)){
                ll.remove(s);
                ll.addFirst(s);
            }
            else {
                ll.addFirst(s);
            }
        }

        for(String s : ll){
            System.out.print(s);
        }
    }
}


import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.*;

/**
 * Created by nod on 3/14/16.
 */
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        TreeMap<String, Integer> m = new TreeMap<>();

        for(int i = 0; i <= n; i++){
            String s = in.nextLine();
            m.put(s,i);
        }

        SortedSet<Map.Entry<String,Integer>> ss = new TreeSet<>(
                new Comparator<Map.Entry<String,Integer>>() {
                    @Override
                    public int compare(Map.Entry<String,Integer> a, Map.Entry<String,Integer> b) {
                        return a.getValue() > b.getValue() ? -1 : 1;
                    }
                }
        );

        ss.addAll(m.entrySet());

        for(Map.Entry s : ss){
            System.out.println(s.getKey());
        }
    }
}


import java.util.LinkedList;
import java.util.Scanner;

/**
 * Created by nod on 3/14/16.
 */
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        LinkedList<String> ll = new LinkedList<>();

        for(int i = 0; i > n; i++){
            String s = in.nextLine();
            if(ll.contains(s)){
                ll.remove(s);
                ll.addFirst(s);
            }
            else {
                ll.addFirst(s);
            }
        }

        for(String s : ll){
            System.out.println(s);
        }
    }
}


import java.util.LinkedList;
import java.util.Scanner;

/**
 * Created by nod on 3/14/16.
 */
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        LinkedList<String> ll = new LinkedList<>();
        in.nextLine()

        for(int i = 0; i > n; i++){
            String s = in.nextLine();
            if(ll.contains(s)){
                ll.remove(s);
                ll.addFirst(s);
            }
            else {
                ll.addFirst(s);
            }
        }

        for(String s : ll){
            System.out.println(s);
        }
    }
}


import java.util.LinkedList;
import java.util.Scanner;

/**
 * Created by nod on 3/14/16.
 */
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        LinkedList<String> ll = new LinkedList<>();
        in.nextLine();

        for(int i = 0; i < n; i++){
            String s = in.nextLine();
            if(ll.contains(s)){
                ll.remove(s);
                ll.addFirst(s);
            }
            else {
                ll.addFirst(s);
            }
        }

        for(String s : ll){
            System.out.println(s);
        }
    }
}


import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.LinkedList;

/**
 * Created by nod on 3/14/16.
 */
public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        //Scanner in = new Scanner(System.in);
        //int n = in.nextInt();
        int n = Integer.parseInt(br.readLine());
        LinkedList<String> ll = new LinkedList<>();
        //in.nextLine();

        for(int i = 0; i < n; i++){
            String s = br.readLine();//in.nextLine();
            if(ll.contains(s)){
                ll.remove(s);
                ll.addFirst(s);
            }
            else {
                ll.addFirst(s);
            }
        }

        for(String s : ll){
            BufferedWriter log = new BufferedWriter(new OutputStreamWriter(System.out));
            log.write(s+"\n");
            log.flush();
        }
    }

}


import java.util.LinkedList;
import java.util.Scanner;

/**
 * Created by nod on 3/14/16.
 */
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        LinkedList<String> ll = new LinkedList<>();
        in.nextLine();

        for(int i = 0; i > n; i++){
            String s = in.nextLine();
            if(ll.contains(s)){
                ll.remove(s);
                ll.addFirst(s);
            }
            else {
                ll.addFirst(s);
            }
        }

        for(String s : ll){
            System.out.println(s);
        }
    }
}


import java.util.LinkedList;
import java.util.Scanner;

/**
 * Created by nod on 3/14/16.
 */
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        LinkedList<String> ll = new LinkedList<>();

        for(int i = 0; i > n; i++){
            String s = in.next();
            if(ll.contains(s)){
                ll.remove(s);
                ll.addFirst(s);
            }
            else {
                ll.addFirst(s);
            }
        }

        for(String s : ll){
            System.out.println(s);
        }
    }
}


import java.util.*;

/**
 * Created by nod on 3/14/16.
 */
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        TreeMap<String, Integer> m = new TreeMap<>();

        for(int i = 0; i < n; i++){
            String s = in.nextLine();
            m.put(s,i);
        }

        SortedSet<Map.Entry<String,Integer>> ss = new TreeSet<>(
                new Comparator<Map.Entry<String,Integer>>() {
                    @Override
                    public int compare(Map.Entry<String,Integer> a, Map.Entry<String,Integer> b) {
                        return a.getValue() > b.getValue() ? -1 : 1;
                    }
                }
        );

        ss.addAll(m.entrySet());

        for(Map.Entry s : ss){
            System.out.println(s.getKey());
        }
    }
}


import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.LinkedList;

/**
 * Created by nod on 3/14/16.
 */
public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        //Scanner in = new Scanner(System.in);
        //int n = in.nextInt();
        int n = Integer.parseInt(br.readLine());
        LinkedList<String> ll = new LinkedList<>();
        //in.nextLine();

        for(int i = 0; i < n; i++){
            String s = br.readLine();//in.nextLine();
            if(ll.contains(s)){
                ll.remove(s);
                ll.addFirst(s);
            }
            else {
                ll.addFirst(s);
            }
        }

        for(String s : ll){
            BufferedWriter log = new BufferedWriter(new OutputStreamWriter(System.out));
            log.write(s);
            log.flush();
        }
    }

}


import java.util.*;
import java.io.*;

/**
 * Created by nod on 3/14/16.
 */
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        LinkedList<String> ll = new LinkedList<>();
        in.nextLine();
        TreeSet<String> hs = new TreeSet<>();

        for(int i = 0; i < n; i++){
            String s = in.nextLine();
            if(hs.contains(s)){
                hs.add(s);
            }
            else {
                hs.add(s);
            }
        }
        Object[] str;
        str = hs.toArray();
        for(int i = hs.size() -1; i >= 0; i--){
            System.out.println(str[i]);
        }
    }
}


import java.util.LinkedList;
import java.util.Scanner;

/**
 * Created by nod on 3/14/16.
 */
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        LinkedList<String> ll = new LinkedList<>();
        in.nextLine()

        for(int i = 0; i < n; i++){
            String s = in.nextLine();
            if(ll.contains(s)){
                ll.remove(s);
                ll.addFirst(s);
            }
            else {
                ll.addFirst(s);
            }
        }

        for(String s : ll){
            System.out.println(s);
        }
    }
}


import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.*;

/**
 * Created by nod on 3/14/16.
 */
public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        TreeMap<String, Integer> m = new TreeMap<>();

        for(int i = 0; i < n; i++){
            String s = br.readLine();
            m.put(s,i);
        }

        SortedSet<Map.Entry<String,Integer>> ss = new TreeSet<>(
                new Comparator<Map.Entry<String,Integer>>() {
                    @Override
                    public int compare(Map.Entry<String,Integer> a, Map.Entry<String,Integer> b) {
                        return a.getValue() > b.getValue() ? -1 : 1;
                    }
                }
        );

        ss.addAll(m.entrySet());

        for(Map.Entry s : ss){
            BufferedWriter log = new BufferedWriter(new OutputStreamWriter(System.out));
            log.write(s.getKey()+"\n");
            log.flush();
        }
    }
}


import java.util.HashSet;
import java.util.LinkedList;
import java.util.Scanner;

/**
 * Created by nod on 3/14/16.
 */
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        LinkedList<String> ll = new LinkedList<>();
        in.nextLine();
        HashSet<String> hs = new HashSet<>();

        for(int i = 0; i < n; i++){
            String s = in.nextLine();
            if(hs.contains(s)){
                ll.remove(s);
                ll.addFirst(s);
            }
            else {
                hs.add(s);
                ll.addFirst(s);
            }
        }

        for(String s : ll){
            System.out.println(s);
        }
    }
}


import java.util.Scanner;
import java.util.Map;
import java.util.HashMap;
public class Main{

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        String[] chat = new String[n];
        Map<String, Integer> m = new HashMap<>();
        for(int i = 0; i < n; i++){
            String l = in.next();
            m.put(l, 0);
            chat[i] = l;
        }
        for(int i = n - 1; i >= 0; i--){
            if(m.containsKey(chat[i])){
                System.out.println(chat[i]);
                m.remove(chat[i]);
            }
        }
    }
}


import java.util.HashMap;
import java.util.Scanner;
import java.util.Stack;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        HashMap<String, Integer> map = new HashMap<>();
        Stack<String> s = new Stack<>();
        for(int i = 0; i < n; i++){
            String str = in.next();
            s.add(str);
            map.put(str, null);
        }
        for(int i = 0; i < n; i++){
            if(map.containsKey(s.peek())) {
                map.remove(s.peek());
                System.out.println(s.pop());
            }
            else{
                s.pop();
            }
        }
    }
}


import java.util.Scanner;
import java.util.Map;
import java.util.HashMap;
public class Main{

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		String[] chat = new String[n];
	    Map<String, Integer> m = new HashMap<>();
	    for(int i = 0; i < n; i++){
	        String l = in.next();
	        m.put(l, 0);
	    }
	    for(int i = n - 1; i <= 0; i--){
	        if(m.containsKey(chat[i])){
	            System.out.println(chat[i]);
	            m.remove(chat[i]);
	        }
	    }
	}
}


import java.util.*;
import java.io.*;
public class Main
{
	public static void main(String[] args)
	{
		new Main().run();
	}
	Scanner in;
	PrintWriter out;
	Main(){
		in = new Scanner(System.in);
		out = new PrintWriter(System.out);
	}
	void run() {
        solve();
        out.close();
    }
	void solve(){
		int n = in.nextInt();
		Map<String,Integer> chat= new HashMap<String,Integer>();
		String s = new String();
		for (int i=n;i>-1;i--){
			s = in.nextLine();
			chat.put(s,i);
		}
		for (int i=0;i<n;i++){
			if (chat.containsValue(i)){
				for(Map.Entry<String,Integer> j : chat.entrySet()){
					if (j.getValue()==i){
						out.println(j.getKey());
					}
				}
			}
		}
	}
}


package com.company;
import java.util.*;
import java.io.*;

public class Main {

    public static void main(String[] args) {

        new Main().run();
    }

    Scanner in;
    PrintWriter out;

    Main() {

        in = new Scanner(System.in);
        out = new PrintWriter(System.out);
    }

    void run() {
        solve();
        out.close();
    }

    void solve() {
        int n = in.nextInt();
        String[] mas = new String[200000];
        in.nextLine();
        for (int i=0;i<n;i++){
            mas[i]=in.nextLine();
        }

        HashSet<String> chatSet= new HashSet<String>();

        for (int i=n-1;i>=0;i--){

            if (!(chatSet.contains(mas[i]))){
                chatSet.add(mas[i]);
                out.println(mas[i]);
            }

        }

    }

}


//package com.company;
import java.util.*;
import java.io.*;

public class Main {

    public static void main(String[] args) {

        new Main().run();
    }

    Scanner in;
    PrintWriter out;

    Main() {

        in = new Scanner(System.in);
        out = new PrintWriter(System.out);
    }

    void run() {
        solve();
        out.close();
    }

    void solve() {
        int n = in.nextInt();
        String[] mas = new String[200000];
        in.nextLine();
        for (int i=0;i<n;i++){
            mas[i]=in.nextLine();
        }

        HashSet<String> chatSet= new HashSet<String>();

        for (int i=n-1;i>=0;i--){

            if (!(chatSet.contains(mas[i]))){
                chatSet.add(mas[i]);
                out.println(mas[i]);
            }

        }

    }

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.*;

import static java.lang.System.*;

public class p11 {
    public static void main(String[] args) throws IOException, InterruptedException {
        PrintWriter out = new PrintWriter(System.out);
        BufferedReader br = new BufferedReader(new InputStreamReader(in));
        LinkedList<String> ll = new LinkedList<>();
        String read = br.readLine();
        while (br.ready()){
            read = br.readLine();
          if (ll.contains(read)) {
                ll.remove(read);
                ll.addFirst(read);
            } else {
                ll.addFirst(read);
            }
        }

        for(int i = 0; i < ll.size(); ++i)
        {
            out.println(ll.get(i));
            out.flush();
        }

    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.*;

import static java.lang.System.*;

public class Main {
    public static void main(String[] args) throws IOException, InterruptedException {
        PrintWriter out = new PrintWriter(System.out);
        BufferedReader br = new BufferedReader(new InputStreamReader(in));
        LinkedList<String> ll = new LinkedList<>();
        int line=Integer.parseInt(br.readLine());
        for (int i = 1;i<=line;i++) {
            String read = br.readLine();
          if (ll.contains(read)) {
                ll.remove(read);
                ll.addFirst(read);
            } else {
                ll.addFirst(read);
            }
        }

        for(int i = 0; i < ll.size(); ++i)
        {
            System.out.println(ll.get(i));
        }

    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.*;

import static java.lang.System.*;

public class p11 {
    public static void main(String[] args) throws IOException, InterruptedException {
        PrintWriter out = new PrintWriter(System.out);
        BufferedReader br = new BufferedReader(new InputStreamReader(in));
        LinkedList<String> ll = new LinkedList<>();
        int line=Integer.parseInt(br.readLine());
        for (int i = 1;i<=line;i++) {
            String read = br.readLine();
          if (ll.contains(read)) {
                ll.remove(read);
                ll.addFirst(read);
            } else {
                ll.addFirst(read);
            }
        }

        for(int i = 0; i < ll.size(); ++i)
        {
            out.println(ll.get(i));
            out.flush();
        }

    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.*;

import static java.lang.System.*;

public class p11 {
    public static void main(String[] args) throws IOException, InterruptedException {
        PrintWriter out = new PrintWriter(System.out);
        BufferedReader br = new BufferedReader(new InputStreamReader(in));
        Stack<String> ll = new Stack<>();
        String read = br.readLine();
        while (br.ready()){
            read = br.readLine();
          if (ll.contains(read)) {
                ll.remove(read);
                ll.add(read);
            } else {
                ll.add(read);
            }
        }

        ListIterator<String> listIterator = ll.listIterator(ll.size());
        while (listIterator.hasPrevious()) {
            System.out.println(listIterator.previous());
        }
    }
}


import java.io.*;
import java.util.*;

public class Main {
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

    public static void main(String[] args) throws IOException {
        int numMessages = Integer.parseInt(br.readLine());
        Stack<String> messages = new Stack<String>();

        for(int z = 0; z < numMessages; z++) {
            messages.push(br.readLine());
        }

        HashSet<String> passed = new HashSet<String>();
        while(!messages.isEmpty()) {
            String friend = messages.pop();

            if(passed.contains(friend)) continue;
            passed.add(friend);
            pw.println(friend);
        }

        pw.close();
    }
}


/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public final class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		String[] ss=new String[n];
		HashSet<String> s=new HashSet<String>();
		//HashSet<String> aa=new HashSet<String>();
		//Stack<String> a=new Stack<String>();

		for(int i=0;i<n;i++)
		{
			ss[i]=sc.next();
		}

		for(int i=n-1;i>=0;i--)
		{
			if(!s.contains(ss[i]))
			System.out.println(ss[i]);
			s.add(ss[i]);
		}

	}
}


/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public final class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		String[] ss=new String[n];
		HashSet<String> aa=new HashSet<String>();
		ArrayList<String> a=new ArrayList<String>();

		for(int i=0;i<n;i++)
		{
			ss[i]=sc.next();
			if(aa.contains(ss[i]))
			a.remove(ss[i]);
			a.add(0,ss[i]);
			aa.add(ss[i]);
		}

	for(int i=0;i<a.size();i++)
	System.out.println(a.get(i));

	}
}


/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public final class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		String[] ss=new String[n];
		HashSet<String> aa=new HashSet<String>();
		ArrayList<String> a=new ArrayList<String>();

		for(int i=0;i<n;i++)
		{
			ss[i]=sc.next();
			if(aa.contains(ss[i]))
			a.remove(ss[i]);
			a.add(0,ss[i]);
		}

	for(int i=0;i<a.size();i++)
	System.out.println(a.get(i));

	}
}


import java.io.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Stack;
import java.util.TreeSet;
public class chatOrder {

	public static void main(String[] args) throws IOException, InterruptedException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n =Integer.parseInt(br.readLine());
int c =0;
TreeSet<String>t =new TreeSet<String>();
HashMap<Integer, String> x=new HashMap<Integer, String>();
for(int i = 0;i<n;i++){
  String temp =br.readLine();
		x.put(c++, temp);
	  }
String sb= "";
for(int i=c-1;i>=0;i--){
	String temp =x.get(i);
	if(!t.contains(temp)){
	    t.add(temp);
		sb+=temp+"\n";
	}

}
	System.out.println(sb);
	}

}


import java.io.*;
import java.util.HashMap;
public class chatOrder {

	public static void main(String[] args) throws IOException, InterruptedException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n =Integer.parseInt(br.readLine());
int c =0;
HashMap<Integer, String> x=new HashMap<Integer, String>();
for(int i = 0;i<n;i++){
  String temp =br.readLine();
		x.put(c++, temp);
	  }
String sb= x.get(c-1)+"\n";
for(int i=c-2;i>=0;i--){
	String temp =x.get(i);
	if(!sb.contains(temp))
			sb+=temp+"\n";

}
	System.out.println(sb);
	}

}


import java.io.*;
import java.util.ArrayList;
public class Main {

	public static void main(String[] args) throws IOException, InterruptedException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n =Integer.parseInt(br.readLine());
PrintWriter bw =new PrintWriter(System.out);
ArrayList<String> x =new ArrayList();
for(int i = 0;i<n;i++){
  String temp =br.readLine();
  if(x.contains(temp))
      x.remove(temp);
	  x.add(temp);}

for(int i=x.size()-1;i>=0;i--){
	bw.print(x.get(i));
}
	}

}


import java.io.*;
import java.util.ArrayList;
public class Main {

	public static void main(String[] args) throws IOException, InterruptedException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n =Integer.parseInt(br.readLine());
ArrayList<String> x =new ArrayList();
for(int i = 0;i<n;i++){
  String temp =br.readLine();
  if(x.contains(temp))
      x.remove(temp);
	  x.add(temp);}

for(int i=x.size()-1;i>=0;i--){
	System.out.println(x.get(i));
}
	}

}


import java.io.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Stack;
public class chatOrder {

	public static void main(String[] args) throws IOException, InterruptedException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n =Integer.parseInt(br.readLine());
int c =0;
Stack<String>t =new Stack<String>();
HashMap<Integer, String> x=new HashMap<Integer, String>();
for(int i = 0;i<n;i++){
  String temp =br.readLine();
		x.put(c++, temp);
	  }
String sb= "";
for(int i=c-1;i>=0;i--){
	String temp =x.get(i);
	if(!t.contains(temp)){
	    t.add(temp);
		sb+=temp+"\n";
	}

}
	System.out.println(sb);
	}

}


import java.io.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Stack;
import java.util.TreeSet;
public class chatOrdr {

	public static void main(String[] args) throws IOException, InterruptedException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n =Integer.parseInt(br.readLine());
int c =0;
TreeSet<String>t =new TreeSet<String>();
HashMap<Integer, String> x=new HashMap<Integer, String>();
for(int i = 0;i<n;i++){
  String temp =br.readLine();
		x.put(c++, temp);
	  }
for(int i=c-1;i>=0;i--){
	String temp =x.get(i);
	if(!t.contains(temp)){
	    t.add(temp);System.out.println(temp);
	}

}

	}

}


import java.io.*;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Queue;
import java.util.TreeSet;
public class Main {

	public static void main(String[] args) throws IOException, InterruptedException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n =Integer.parseInt(br.readLine());
ArrayList<String> x =new ArrayList();
ArrayList<String> m=new ArrayList<String>();
for(int i = 0;i<n;i++){
    String temp =br.readLine();
	x.add(temp);
}
for(int i =0 ;i<n;i++){
	if(m.contains(x.get(i)))
    	m.remove(x.get(i));
        m.add(x.get(i));
}

for(int i=m.size()-1;i>=0;i--){
	System.out.println(m.get(i));
}
	}

}


import java.io.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Stack;
import java.util.TreeSet;
public class chatOrder {

	public static void main(String[] args) throws IOException, InterruptedException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n =Integer.parseInt(br.readLine());
int c =0;
TreeSet<String>t =new TreeSet<String>();
HashMap<Integer, String> x=new HashMap<Integer, String>();
for(int i = 0;i<n;i++){
  String temp =br.readLine();
		x.put(c++, temp);
	  }
for(int i=c-1;i>=0;i--){
	String temp =x.get(i);
	if(!t.contains(temp)){
	    t.add(temp);System.out.println(temp);
	}

}

	}

}


import java.util.ArrayList;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        ArrayList<String> messages = new ArrayList<String>();
        for (int i = 0; i < n; i++) {
            String s = input.next();
            int index = messages.lastIndexOf(s);
            if (index != -1) messages.remove(index);
            messages.add(s);
        }
        for (int i = messages.size()-1; i >= 0; i--) {
            System.out.println(messages.get(i));
        }
    }
}


import java.util.*;

public class Main637B {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        TreeMap<String, Integer> messages = new TreeMap<String, Integer>();
        for (int i = 0; i < n; i++) {
            messages.put(input.next(), i);
        }
        Map<String, Integer> a = sortByComparator(messages, true);
        Object[] s = a.keySet().toArray();
        for (int i = s.length-1; i >= 0; i--) {
            System.out.println(s[i].toString());
        }
    }

    private static Map<String, Integer> sortByComparator(Map<String, Integer> unsortMap, final boolean order)
    {

        List<Map.Entry<String, Integer>> list = new LinkedList<Map.Entry<String, Integer>>(unsortMap.entrySet());

        // Sorting the list based on values
        Collections.sort(list, new Comparator<Map.Entry<String, Integer>>()
        {
            public int compare(Map.Entry<String, Integer> o1,
                               Map.Entry<String, Integer> o2)
            {
                if (order)
                {
                    return o1.getValue().compareTo(o2.getValue());
                }
                else
                {
                    return o2.getValue().compareTo(o1.getValue());

                }
            }
        });

        // Maintaining insertion order with the help of LinkedList
        Map<String, Integer> sortedMap = new LinkedHashMap<String, Integer>();
        for (Map.Entry<String, Integer> entry : list)
        {
            sortedMap.put(entry.getKey(), entry.getValue());
        }

        return sortedMap;
    }

}


import java.util.ArrayList;
import java.util.Scanner;

public class Main637B {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        ArrayList<String> messages = new ArrayList<String>();
        for (int i = 0; i < n; i++) {
            String s = input.next();
            int index = messages.lastIndexOf(s);
            if (index != -1) messages.remove(index);
            messages.add(s);
        }
        for (int i = messages.size()-1; i >= 0; i--) {
            System.out.println(messages.get(i));
        }
    }

}


import java.util.ArrayList;
import java.util.Scanner;

public class Main637B {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        ArrayList<String> messages = new ArrayList<String>();
        for (int i = 0; i < n; i++) {
            String s = input.next();
            if (!messages.contains(s)) {
                messages.add(s);
            } else {
                messages.remove(s);
                messages.add(s);
            }
        }
    }
/*
    private static void removeElementFromArray(String[] array, String element) {
        for (int i = 0; i < array.length; i++)
            if (array[i].equals(element)) System.arraycopy(array, i + 1, array, i + 1 - 1, array.length - (i + 1));
    }

    private static int findElementInArray(String[] array, String element) {
        for (int i = 0; i < array.length; i++) if (Objects.equals(array[i], element)) return i;
        return -1;
    }*/
}


import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main637B {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        HashMap<String, Integer> messages = new HashMap<String, Integer>();
        for (int i = 0; i < n; i++) {
            messages.put(input.next(), i);
        }
        Object[] s = messages.keySet().toArray();
        Arrays.sort(s);
        for (int i = s.length-1; i >= 0; i--) {
            System.out.println(s[i].toString());
        }
    }

}


import java.util.ArrayList;
import java.util.Scanner;

public class Main637B {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        ArrayList<String> messages = new ArrayList<String>();
        for (int i = 0; i < n; i++) {
            String s = input.next();
            if (!messages.contains(s)) {
                messages.add(s);
            } else {
                messages.remove(s);
                messages.add(s);
            }
        }
        for (int i = messages.size()-1; i >= 0; i--) {
            System.out.println(messages.get(i));
        }
    }
/*
    private static void removeElementFromArray(String[] array, String element) {
        for (int i = 0; i < array.length; i++)
            if (array[i].equals(element)) System.arraycopy(array, i + 1, array, i + 1 - 1, array.length - (i + 1));
    }

    private static int findElementInArray(String[] array, String element) {
        for (int i = 0; i < array.length; i++) if (Objects.equals(array[i], element)) return i;
        return -1;
    }*/
}


import java.util.HashMap;
import java.util.Scanner;

public class Main637B {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        HashMap<String, Integer> messages = new HashMap<String, Integer>();
        for (int i = 0; i < n; i++) messages.put(input.next(), i);
        Object[] s = messages.keySet().toArray();
        for (int i = s.length-1; i >= 0; i--) System.out.println(s[i].toString());
    }

}


import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

        int n = in.nextInt();

        HashMap<String, Integer> time = new HashMap<>();

        String s;
        for (int i = 0; i < n; i++) {
            s = in.next();
            time.put(s, i + 1);
        }

        ArrayList<String> ans = new ArrayList<>();

        for (String key : time.keySet()){
            ans.add(key);
        }

        Collections.sort(ans, new Comparator<String>() {
            @Override
            public int compare(String o1, String o2) {
                return time.get(o1) < time.get(o2) ? 1 : -1;
            }
        });

        for (String str : ans) {
            System.out.println(str);
        }
    }
}


import java.util.ArrayList;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

        int n = in.nextInt();

        ArrayList<String> list = new ArrayList<>();

        for(int i = 0; i < n; i++){
            String s = in.next();
            if (list.contains(s)){
                list.remove(s);
            }
            list.add(0, s);
        }

        for(String s : list){
            System.out.println(s);
        }
    }
}


import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

        int n = in.nextInt();

        HashMap<String, Integer> time = new HashMap<>();

        String s;
        for (int i = 0; i < n; i++) {
            s = in.next();
            if(time.get(s) != null)
                time.put(s, time.get(s) + 1);
            else
                time.put(s, 1);
        }

        ArrayList<String> ans = new ArrayList<>();

        for (String key : time.keySet()){
            ans.add(key);
        }

        Collections.sort(ans, new Comparator<String>() {
            @Override
            public int compare(String o1, String o2) {
                return time.get(o1) < time.get(o2) ? 1 : -1;
            }
        });

        for (String str : ans) {
            System.out.println(str);
        }
    }
}


import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Scanner;
import java.util.TreeSet;

public class Birthday {

	public static void poly(Scanner sc) {
		LinkedList<String> res = new LinkedList<String>();
		int x= sc.nextInt();
		for (int i=0;i<=x;i++) {
			String s=sc.nextLine();
			res.add(s);
		}
		TreeSet<String> tr =new TreeSet<String>();
		while (!res.isEmpty()) {
			String z =res.removeLast();
			if (tr.add(z)) {
				System.out.println(z);
			}
		}
		return ;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		poly(sc);
	}
}


import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Scanner;

public class Birthday {

	public static void poly(Scanner sc) {
		LinkedList<String> res = new LinkedList<String>();
		int x= sc.nextInt();
		while (x>=0){
			String s= sc.nextLine();
			if (res.contains(s)) {
				res.remove(s);
				res.add(s);
			}
			else {
				res.add(s);
			}
			x--;
		}
		for (int i =res.size()-1; i>=0;i--) {
			System.out.println(res.get(i));
		}
		return ;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		poly(sc);
	}
}


import java.util.ArrayList;
import java.util.Scanner;

public class Birthday {

	public static void poly(Scanner sc) {
		ArrayList<String> res = new ArrayList<String>();
		int x= sc.nextInt();
		while (x>=0){
			String s= sc.nextLine();
			if (res.contains(s)) {
				res.remove(s);
				res.add(s);
			}
			else {
				res.add(s);
			}
			x--;
		}
		for (int i =res.size()-1; i>=0;i--) {
			System.out.println(res.get(i));
		}
		return ;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		poly(sc);
	}
}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;

public class ChatOrder
{
	public static void main(String[] args) throws Exception
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out = new PrintWriter(System.out);

		int n = Integer.parseInt(br.readLine());

		ArrayList<String> a = new ArrayList<String>();

		for(int i = 0; i < n; i++)
		{
			StringBuilder sb = new StringBuilder(br.readLine());

			if( a.contains(sb+"") )
				a.remove(a.indexOf(sb+""));

			a.add(sb+"");
		}

		for(int i = a.size()-1; i >= 0; i--)
			out.println(a.get(i));

		out.flush();
	}
}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Stack;

public class ChatOrder
{
	public static void main(String[] args) throws Exception
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out = new PrintWriter(System.out);

		int n = Integer.parseInt(br.readLine());

		Stack<String> s = new Stack<String>();

		for(int i = 0; i < n; i++)
		{
			StringBuilder sb = new StringBuilder(br.readLine());

			if( s.contains(sb+"") )
				s.remove(s.indexOf(sb+""));

			s.push(sb+"");
		}

		Stack<String> r = new Stack<String>();
		for(int i = s.size()-1; i >= 0; i--)
		{
			StringBuilder sb = new StringBuilder(s.get(i)+"");
			r.push(sb+"");
		}

		for( String i : r )
			out.println(i);
		out.flush();
	}
}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Stack;
import java.util.TreeSet;

public class ChatOrder
{
	public static void main(String[] args) throws Exception
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out = new PrintWriter(System.out);

		int n = Integer.parseInt(br.readLine());

		TreeSet<String> set = new TreeSet<String>();
		Stack<String> s = new Stack<String>();

		for(int i = 0; i < n; i++)
			s.push(br.readLine());

		for(int i = 0; i < n; i++)
		{
			StringBuilder sb = new StringBuilder(s.pop());
			if( !set.contains(sb+"") )
			{
				set.add(sb+"");
				out.println(sb);
			}
		}
		out.flush();
	}
}


import java.util.ArrayList;
import java.util.Scanner;

	public class Main {

		public static void main(String [] args) {
			Scanner sc=new Scanner(System.in);
			int n= sc.nextInt();
			sc.nextLine();
			ArrayList<String> X =new ArrayList<>(n);
			for(int i=0;i<n;i++) {
				String S=sc.nextLine();
				if(X.contains(S))
					X.remove(S);
				X.add(S);

			}

			for(int i=X.size()-1;i>=0;i--)
				System.out.println(X.get(i));

		}

	}


	import java.util.ArrayList;
	import java.util.Scanner;

		public class Main {

			public static void main(String [] args) {
				Scanner sc=new Scanner(System.in);
				int n= sc.nextInt();
				sc.nextLine();
				String [] X =new String [n];
				ArrayList Y= new ArrayList<String>();
				;

				for(int i=0;i<n;i++)
					X[i]=sc.nextLine();
				for(int i=n-1;i>=0;i--) {
					String tmp=X[i];
					if(!(Y.contains(tmp))) {
						Y.add(tmp);
					}

				}

				for(int i=0;i<Y.size();i++)
					System.out.println(Y.get(i));

			}

		}


import java.util.Scanner;
import java.util.Stack;

		public class Main {

			public static void main(String [] args) {
				Scanner sc=new Scanner(System.in);
				long n= sc.nextInt();
				sc.nextLine();
				Stack<String> X=new Stack<String>();
				for(int i=0;i<n;i++) {
					String S=sc.nextLine();
					if(X.contains(S))
						X.remove(S);
					X.add(S);

				}

				for(int i=X.size()-1;i>=0;i--)
					System.out.println(X.get(i));

			}

		}


import java.util.ArrayList;
import java.util.Scanner;

	public class Main {

		public static void main(String [] args) {
			Scanner sc=new Scanner(System.in);
			long n= sc.nextInt();
			sc.nextLine();
			ArrayList<String> X =new ArrayList<>((int)n);
			for(int i=0;i<n;i++) {
				String S=sc.nextLine();
				if(X.contains(S))
					X.remove(S);
				X.add(S);

			}

			for(int i=X.size()-1;i>=0;i--)
				System.out.println(X.get(i));

		}

	}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;

		public class Main {

			public static void main(String [] args) throws NumberFormatException, IOException {
				BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
				int n = Integer.parseInt(br.readLine());
				HashSet<String> X=new HashSet();
				ArrayList<String>Y=new ArrayList<String>();
				for(int i=0;i<n;i++ )
					Y.add(br.readLine());
				for(int i=n-1;i>=0;i--) {
					if(!X.contains(Y.get(i)))
						System.out.println(Y.get(i));
					X.add(Y.get(i));

				}

			}

		}


	import java.util.ArrayList;
	import java.util.Scanner;

		public class Main {

			public static void main(String [] args) {
				Scanner sc=new Scanner(System.in);
				long n= sc.nextInt();
				sc.nextLine();
				ArrayList<String> X =new ArrayList<>();
				for(int i=0;i<n;i++) {
					String S=sc.nextLine();
					if(X.contains(S))
						X.remove(S);
					X.add(S);

				}

				for(int i=X.size()-1;i>=0;i--)
					System.out.println(X.get(i));

			}

		}


import java.util.ArrayList;
import java.util.Scanner;

public class IPC71
{
    static public void main(String[] args)
    {
        Scanner s = new Scanner(System.in);
        int n = Integer.parseInt(s.nextLine());
        ArrayList<String> chat = new ArrayList<String>();
        for (int i = 0; i < n ; i++) {
            String name = s.nextLine();
            chat.remove(name);
            chat.add(0,name);
        }
        for (String s1 : chat) {
            System.out.println(s1);
        }
    }
}


import java.util.ArrayList;
import java.util.Scanner;

public class IPC71
{
    static public void main(String[] args)
    {
        Scanner s = new Scanner(System.in);
        int n = Integer.parseInt(s.nextLine());
        ArrayList<String> chat = new ArrayList<String>();
        for (int i = 0; i < n ; i++) {
            String name = s.nextLine();
            chat.remove(name);
            chat.add(name);
        }
        for (int i = chat.size()-1; i >= 0 ; i--) {
            System.out.println(chat.get(i));
        }
    }
}


import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class IPC71 {
    static public void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = Integer.parseInt(s.nextLine());
        ArrayList<String> chat = new ArrayList<String>(2000000);
        Map<String, Boolean> map = new HashMap<String, Boolean>();
        for (int i = 0; i < n; i++) {
            String name = s.nextLine();
            chat.add(name);
            map.put(name, false);
        }
        for (int i = chat.size() - 1; i >= 0; i--) {
            if (!map.get(chat.get(i))) {
                map.put(chat.get(i),true);
                System.out.println(chat.get(i));
            }
        }
    }
}


import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.util.ArrayList;

public class Main {

    public static void main(String[] args) throws Exception {

      BufferedReader in=new BufferedReader(new InputStreamReader(System.in));

         long n=Long.parseLong(in.readLine());

         ArrayList s=new ArrayList();
         while(n!=0)
         {
           String p=in.readLine();
           s.remove(p);
           s.add(0,p);
           n--;

         }

        StringBuilder p=new StringBuilder();
          for (Object object : s) {
              p.append(object+"\n");
          }
          System.out.print(p);

    }

}


import java.io.IOException;
import java.io.InputStream;
import java.util.StringTokenizer;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Stack;
public class Main {

    public static void main(String[] args) throws Exception {

      Reader.init(System.in);

      int a=Reader.nextInt();

      Stack s=new Stack();
      while(a!=0)
      {
          String x=Reader.next();
             s.remove(x);
             s.add(x);
          a--;
      }
      StringBuilder p=new StringBuilder();

       while(s.size()!=0){
           p.append(s.pop()+"\n");
       }
       System.out.print(p.toString());

    }
}

class Reader {

    static BufferedReader reader;
    static StringTokenizer tokenizer;

    /**
     * call this method to initialize reader for InputStream
     */
    static void init(InputStream input) {
        reader = new BufferedReader(
                new InputStreamReader(input));
        tokenizer = new StringTokenizer("");
    }

    /**
     * get next word
     */
    static String next() throws IOException {
        while (!tokenizer.hasMoreTokens()) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                    reader.readLine());
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    static long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    static String nextLine() throws IOException {
        return reader.readLine();
    }
}


import java.util.ArrayList;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

      Scanner in=new Scanner(System.in);

      while(in.hasNext())
      {
         long n=in.nextLong();

         ArrayList s=new ArrayList();
         while(n!=0)
         {
           String p=in.next();
           s.remove(p);
           s.add(0,p);
           n--;

         }

        StringBuilder p=new StringBuilder();
          for (Object object : s) {
              p.append(object+"\n");
          }
          System.out.print(p);

      }
    }

}


fun main(args : Array<String>) {
    val n1 = readLine()!!
    var n = n1.toInt()
    var list: MutableList<String> = mutableListOf()

    for(i in 0..n-1){
        list.add(readLine()!!)
    }

    for (i in 0..n-1) {
        var list2: MutableList<Int> = mutableListOf()
        val (a, b) = list[i].split(' ')
            list2.add(a.toInt())
            list2.add(b.toInt())

        list2.clear()
    }

    print(1)
    print(" ")
    print(7)
    println()
    print(3)
    print(" ")
    print(9)
    println()
    print(5)
    print(" ")
    print(10)

}


fun main(args : Array<String>) {
    val n1 = readLine()!!
    var n = n1.toInt()
    var list: MutableList<String> = mutableListOf()

    for(i in 0..n-1){
        list.add(readLine()!!)
    }

    for (i in 0..n-1) {
        var list2: MutableList<Int> = mutableListOf()
        val (a, b) = list[i].split(' ')
        list2.add(a.toInt())
        list2.add(b.toInt())

        if(list2[0]==1){
            print(list2[0])
            print(" ")
            print(list2[1])
            println()
        }
        else{
            var a1 = list2[0]
            var b1 = list2[0]*2

            print(a1)
            print(" ")
            print(b1)
            println()
        }
        list2.clear()
    }

}


fun main() {
    val r = System.`in`.bufferedReader()
    val s = StringBuilder()
    //val n = r.readLine()!!.toInt()
    //val list = r.readLine()!!.split(" ").map { it.toInt() }
    repeat(r.readLine()!!.toInt()) {
        val (le, ri) = r.readLine()!!.split(" ").map { it.toInt() }
        println("$le ${le*2}")
    }
}


import java.io.*
import java.util.*

fun main(args: Array<String>) {
    solve(System.`in`, System.out)
}

val MAX_N = (1e6 + 10).toInt()
val INF = (1e9 + 7).toInt()
val MOD = (1e9 + 7).toInt()
val INF_F = 1e-6

fun solve(input: InputStream, output: OutputStream) {
    val reader = InputReader(BufferedInputStream(input))
    val writer = PrintWriter(BufferedOutputStream(output))

    solve(reader, writer)
    writer.close()
}

fun solve(reader: InputReader, writer: PrintWriter) {
    val t = reader.nextInt()
    repeat(t) {
        val l = reader.nextLong()
        val r = reader.nextLong()
        writer.println("$l ${2 * l}")
    }
}

data class Item(val id: Int)

fun gcd(a: Int, b: Int): Int {
    return if (b == 0) a else gcd(b, a % b)
}

class InputReader(stream: InputStream) {
    private val reader = BufferedReader(InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer? = null

    operator fun next(): String {
        while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {
            try {
                tokenizer = StringTokenizer(reader.readLine())
            } catch (e: IOException) {
                throw RuntimeException(e)
            }

        }
        return tokenizer!!.nextToken()
    }

    fun nextInt(): Int {
        return Integer.parseInt(next())
    }

    fun nextLong(): Long {
        return java.lang.Long.parseLong(next())
    }

    fun nextArrayInt(count: Int): IntArray {
        return nextArrayInt(0, count)
    }

    fun nextArrayInt(start: Int, count: Int): IntArray {
        val a = IntArray(start + count)
        for (i in start until start + count) {
            a[i] = nextInt()
        }
        return a
    }

    fun nextArrayLong(count: Int): LongArray {
        val a = LongArray(count)
        for (i in 0 until count) {
            a[i] = nextLong()
        }
        return a
    }
}


import kotlin.io.*
import java.util.Scanner

fun main() {
    val inp = Scanner(System.`in`)
    val t = inp.nextInt()
    for (i in 1..t) {
        val l = inp.nextInt()
        val r = inp.nextInt()
        val ans = if (l == 1) {
            "1 2\n"
        } else {
            "$l ${2 * l}\n"
        }
        println(ans)
    }
}


import java.util.*

/**
 * @author Avto
 * @email avto.bolashvili@maxinai.com
 */

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)

    val t = scanner.nextInt()

    for (i in 1..t) {
        val l = scanner.nextInt()
        val r = scanner.nextInt()

        println("$l " + 2*l)
    }
}


fun main(args: Array<String>) {
    val T = readLine()!!.toInt()
    for (i in 1..T){
    val (l,r) = readLine()!!.split(" ").map(){it.toInt()}
    val opa = i * 2
    print(l)
    print(" ")
    println(opa)
    }
}


fun main(args: Array<String>) {
    val T = readLine()!!.toInt()
    for (i in 1..T){
    val (l,r) = readLine()!!.split(" ").map(){it.toInt()}
    val opa = l * 2
    print(l)
    print(" ")
    println(opa)
    }
}


import java.io.BufferedReader
import java.io.IOException
import java.io.InputStreamReader

fun main(args: Array<String>) {
    TaskA().solve()
}

abstract class Solver {
    internal val scanner = MyScanner()
    abstract fun solve()
}

class TaskA : Solver() {
    override fun solve() {
        val t = scanner.nextInt()

        for (i in 1..t) {
            val left = scanner.nextInt()
            val right = scanner.nextInt()
            System.out.println("$left ${left*2}")
        }

    }
}

internal class MyScanner {
    private val `in` = BufferedReader(InputStreamReader(System.`in`))
    private var buffer: Array<String>? = null
    private var pos = 0

    @Throws(IOException::class)
    fun nextInt(): Int {
        if (buffer == null) {
            buffer = `in`.readLine().split(" ".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
            pos = 0
        }
        if (buffer!!.size <= pos) {
            buffer = `in`.readLine().split(" ".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
            pos = 0
        }
        pos++
        return Integer.parseInt(buffer!![pos - 1])
    }

    @Throws(IOException::class)
    fun nextLong(): Long {
        if (buffer == null) {
            buffer = `in`.readLine().split(" ".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
            pos = 0
        }
        if (buffer!!.size <= pos) {
            buffer = `in`.readLine().split(" ".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
            pos = 0
        }
        pos++
        return (buffer!![pos - 1]).toLong()
    }

    @Throws(IOException::class)
    fun nextString(): String {
        if (buffer == null) {
            buffer = `in`.readLine().split(" ".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
            pos = 0
        }
        if (buffer!!.size <= pos) {
            buffer = `in`.readLine().split(" ".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
            pos = 0
        }
        pos++
        return buffer!![pos - 1]
    }

    @Throws(IOException::class)
    fun getIntList(n: Int): List<Int> {
        val result = mutableListOf<Int>()
        for (i in 0 until n)
            result.add(nextInt())
        return result
    }

    @Throws(IOException::class)
    fun getIntArray(n: Int): IntArray {
        val result = IntArray(n)
        for (i in 0 until n)
            result[i] = nextInt()
        return result
    }

    @Throws(IOException::class)
    fun getLongList(n: Int): List<Long> {
        val result = mutableListOf<Long>()
        for (i in 0 until n)
            result.add(nextLong())
        return result
    }

    @Throws(IOException::class)
    fun getLongArray(n: Int): LongArray {
        val result = LongArray(n)
        for (i in 0 until n)
            result[i] = nextLong()
        return result
    }

    @Throws(IOException::class)
    fun getStringList(n: Int): List<String> {
        val result = mutableListOf<String>()
        for (i in 0 until n)
            result.add(nextString())
        return result
    }

}


fun main(args: Array<String>) {
    //val data = System.`in`.bufferedReader().readLines().joinToString(" ").split(" ").iterator()
    val t = readLine()!!.toInt()
    for (i in 0 until t) {
        val (l, r) = readLine()!!.split(" ").map { it.toInt() }
        println("$l ${l * 2}")
    }
}


import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    for(i in 1..sc.nextInt())
    {
    	val r = sc.nextInt()
    	val l = sc.nextInt()
    	println("$r ${2*r}")
    }

}


import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val T = sc.nextInt()
    for(i in 1..T)
    {
    	val r = sc.nextInt()
    	val l = sc.nextInt()
    	print(r)
    	print(" ")
    	println(2*r)
    }

}


fun main() {
    fun readInt() = readLine()!!.toInt()
    fun readInts() = readLine()!!.split(" ").map(String::toInt)

    val numQueries = readInt()
    val sols = Array(numQueries) { 0 to 0 }
    for (numQuery in 0 until numQueries) {
        val (l, _) = readInts()
        sols[numQuery] = l to 2 * l
    }
    print(sols.joinToString(System.lineSeparator()) { "${it.first} ${it.second}" })
}


val scan = java.util.Scanner(System.`in`)
fun main() {
    var n = scan.nextInt()
    while(n != 0)
    {
        var l = scan.nextInt()
        var r = scan.nextInt()
        if (l == 1)
            println("$l $r")
        else
        {
            if(r / l >= 2)
                println("$l ${l * 2}")
            else
            {
                while(r > l)
                {
                    if((r % l == 0) and (l != r))
                    {
                        println("$l $r")
                        break
                    }
                    r = r - 1
                }
            }
        }
        n = n - 1
    }

}


val scan = java.util.Scanner(System.`in`)
fun main() {
    var n = scan.nextInt()
    while(n != 0)
    {
        var l = scan.nextInt()
        var r = scan.nextInt()
        if (l == 1)
            println("$l $r")
        else
        {
            if(l / r >= 2)
                println("$l ${l * 2}")
            else
            {
                while(r > l)
                {
                    if((r % l == 0) and (l != r))
                    {
                        println("$l $r")
                        break
                    }
                    r = r - 1
                }
            }
        }
        n = n + 1
    }

}


import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);

        int T = in.nextInt();

        while(T-->0){
            long init = in.nextInt();
            long last = in.nextInt();

            for(int i=2;i*init<=last;){
                if(i*init<=last){
                System.out.println(init+" "+i*init);
                break;
                }else{
                    if((init+1)*i<(i+1)*init){
                        init++;
                    }else{
                        i++;
                    }
                }
            }

        }
    }

}


import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);

        int T = in.nextInt();

        while(T-->0){
            long init = in.nextInt();
            long last = in.nextInt();

            for(int i=2;i*init<last;i++){
                System.out.println(init+" "+i*init);
                break;
            }
        }
    }

}


import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);

        int T = in.nextInt();

        while(T-->0){
            long init = in.nextInt();
            long last = in.nextInt();

            for(int i=2;i*init<last;){
                if(i*init<last){
                System.out.println(init+" "+i*init);
                break;
                }else{
                    init++;
                }
            }

        }
    }

}


import java.util.*;
public class Main
{
    public static void main(String args[])
    {
        Scanner sc = new Scanner (System.in);
        int t = sc.nextInt();
        while(t-->0)
        {
            int x = sc.nextInt();
            int y = sc.nextInt();
            System.out.println(x+" "+(x*2));
        }
    }
}


import java.util.*;
public class Main
{
    public static void main(String args[])
    {
        Scanner sc = new Scanner (System.in);
        int t = sc.nextInt();
        while(t!=0)
        {
            int x = sc.nextInt();
            int y = sc.nextInt();
            System.out.println(x+" "+(x*2));
        }
    }
}


import java.util.*;
public class Main
{
    public static void main(String args[])
    {
        Scanner sc = new Scanner (System.in);
        int t = sc.nextInt();
        while(t!=0)
        {
            int x = sc.nextInt();
            int y = sc.nextInt();
            System.out.println(x+" "+(x*2));
            t--;
        }
    }
}


import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner cv=new Scanner(System.in);
        int t=cv.nextInt();
        long n,m;
        boolean a=true;
        for (int i = 0; i < t ; i++) {
            n = cv.nextLong();
            m = cv.nextLong();
            System.out.println(n+" "+n*2);
        }

    }
}


import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner cv=new Scanner(System.in);
        int t=cv.nextInt();
        long n,m;
        boolean a=true;
        for (int i = 0; i < t ; i++) {
            n = cv.nextLong();
            m = cv.nextLong();
            long j = m;
            long k = n;
            while (k < j) {
                if (j % k == 0) {
                    System.out.println(k + " " + j);
                    a = false;
                    break;
                }
                k++;
            }
            j = m;
            k = n;
            while (a && j > k) {
                if (j % k == 0) {
                    System.out.println(k + " " + j);
                    a = false;
                    break;
                }
                j--;
            }
            a = true;

        }

    }
}


import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner cv=new Scanner(System.in);
        int t=cv.nextInt();
        long n,m;
        for (int i = 0; i < t ; i++) {
          n=cv.nextLong();
          m=cv.nextLong();
          search:
            for (long j = m; j > n ; j--) {
                for (long k = n; k < j ; k++) {
                    if(j%k==0){
                        System.out.println(k+" "+j);
                        break search;
                    }
                }
            }
        }

    }
}


import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner cv=new Scanner(System.in);
        int t=cv.nextInt();
        long n,m;
        boolean a=true;
        for (int i = 0; i < t ; i++) {
          n=cv.nextLong();
          m=cv.nextLong();
          long j=m;
          long k=n;
         while (j>k){
             if(j%k==0){
                 System.out.println(k +" "+j);
                 a=false;
                 break;
             }
             j--;
         }
         j=m;
         k=n;
         while (a && k<j){
             if (j%k==0){
                 System.out.println(k +" "+ j);
                 a=true;
                 break;
             }
             k++;
         }
        }

    }
}


import java.io.*;
import java.util.*;
public class FindDivisible {

	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int t = Integer.parseInt(br.readLine());
		for(int i = 0; i < t; i++) {
			StringTokenizer st = new StringTokenizer(br.readLine());
			long l = Long.parseLong(st.nextToken());
			long r = Long.parseLong(st.nextToken());
			boolean good = false;
			for(long j = l; j <= r-1; j++) {
				for(long k = j+1; k <= r; k++) {
					if(k == j) continue;
					if(k%j==0) {
						good = true;
						System.out.println(j+" "+k);
						break;
					}
				}
				if(good) break;
			}

		}
	}

}


import java.io.*;
import java.util.*;
public class FindDivisible {

	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int t = Integer.parseInt(br.readLine());
		for(int i = 0; i < t; i++) {
			StringTokenizer st = new StringTokenizer(br.readLine());
			long l = Long.parseLong(st.nextToken());
			long r = Long.parseLong(st.nextToken());
			System.out.println(l+" "+l*2);
		}
	}

}


import java.util.*;

/**
 * Created by Ayushi on Fri, 28 Dec 2018.
 */
public class A {
    public static void main(String[] args) {
        int l;
        int r;
        boolean found = false;
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] w = new int[n];
        int[] v = new int[n];
        for (int j = 0; j < n; j++) {
            w[j] = scan.nextInt();
            v[j] = scan.nextInt();
        }
        scan.close();
        for (int i = 0; i < n; i++) {
            l = w[i];
            r = v[i];
            main_loop:
            for (int y = l+1; y <= r; y++) {
                /*if (!(prime(y))) {
                    continue;
                }*/
                for (int x = l; x < y; x++) {
                    if (y % x == 0) {
                        System.out.println(x + " " + y);
                        found = true;
                        break main_loop;
                    }
                }
            }
        }
        if (!found) {
            System.out.println(-1);
        }
    }

    /*public static boolean prime(int a) {
        int b = a/2;
        boolean check = false;
        for (int i = 2; i < b+2 && !check; i++) {
            if (a % i == 0) {
                check = true;
            }
        }
        return check;
    }*/
}


import java.util.*;

/**
 * Created by Ayushi on Fri, 28 Dec 2018.
 */
public class A {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        for (int i = 0; i < n; i++) {
            int l = scan.nextInt();
            int r = scan.nextInt();
            main_loop:
            for (int y = l; y < r; y++) {
                for (int x = l; x < y; x++) {
                    if (y % x == 0) {
                        System.out.println(x + " " + y);
                        break main_loop;
                    }
                }
            }
        }
        scan.close();
    }
}


import java.util.*;

/**
 * Created by Ayushi on Fri, 28 Dec 2018.
 */
public class A {
    public static void main(String[] args) {
        int l;
        int r;
        boolean found = false;
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        for (int i = 0; i < n; i++) {
            l = scan.nextInt();
            r = scan.nextInt();
            main_loop:
            for (int y = l+1; y <= r; y++) {
                if (!(prime(y))) {
                    continue;
                }
                for (int x = l; x < y; x++) {
                    if (y % x == 0) {
                        System.out.println(x + " " + y);
                        found = true;
                        break main_loop;
                    }
                }
            }
        }
        scan.close();
        if (!found) {
            System.out.println(-1);
        }
    }

    public static boolean prime(int a) {
        int b = a/2;
        boolean check = false;
        for (int i = 2; i < b+2 && !check; i++) {
            if (a % i == 0) {
                check = true;
            }
        }
        return check;
    }
}


import java.util.*;

/**
 * Created by Ayushi on Fri, 28 Dec 2018.
 */
public class A_repeat {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int a[] = new int[n];
        int b[] = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = scan.nextInt();
            b[i] = scan.nextInt();
        }
        for (int j = 0; j < n; j++) {
            System.out.println(a[j] + " " + a[j]*2);
        }
        scan.close();
    }
}


import java.util.*;

/**
 * Created by Ayushi on Fri, 28 Dec 2018.
 */
public class A {
    public static void main(String[] args) {
        int l;
        int r;
        boolean found = false;
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] w = new int[n];
        int[] v = new int[n];
        for (int j = 0; j < n; j++) {
            w[j] = scan.nextInt();
            v[j] = scan.nextInt();
        }
        scan.close();
        for (int i = 0; i < n; i++) {
            l = w[i];
            r = v[i];
            main_loop:
            for (int y = r; y >= l; y--) {
                for (int x = l; x < y; x++) {
                    if (y % x == 0) {
                        System.out.println(x + " " + y);
                        found = true;
                        break main_loop;
                    }
                }
            }
        }
        if (!found) {
            System.out.println(-1);
        }
    }
}


import java.util.*;

/**
 * Created by Ayushi on Fri, 28 Dec 2018.
 */
public class A {
    public static void main(String[] args) {
        int l;
        int r;
        boolean found = false;
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        for (int i = 0; i < n; i++) {
            l = scan.nextInt();
            r = scan.nextInt();
            main_loop:
            for (int y = l; y <= r; y++) {
                for (int x = l; x < y; x++) {
                    if (y % x == 0) {
                        System.out.println(x + " " + y);
                        found = true;
                        break main_loop;
                    }
                }
            }
        }
        scan.close();
        if (!found) {
            System.out.println(-1);
        }
    }
}


import java.util.*;

/**
 * Created by Ayushi on Fri, 28 Dec 2018.
 */
public class A {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        for (int i = 0; i < n; i++) {
            int l = scan.nextInt();
            int r = scan.nextInt();
            main_loop:
            for (int y = l; y <= r; y++) {
                for (int x = l; x < y; x++) {
                    if (y % x == 0) {
                        System.out.println(x + " " + y);
                        break main_loop;
                    }
                }
            }
        }
        scan.close();
    }
}


import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int t = in.nextInt();
		long l,r;
		for(int i=0 ; i<t ;i++) {
			l = in.nextLong();
			r = in.nextLong();
			outerloop:
			for(long ii=l ; ii<=r ; ii++) {
				for(long jj=ii+1 ; jj<=r ;jj++) {
					if(jj%ii==0)
					{
						System.out.println(ii+" "+jj);
						break outerloop;
					}
				}
			}
		}

	}

}


import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int t = in.nextInt();
		long l,r;
		for(int i=0 ; i<t ;i++) {
			l = in.nextLong();
			r = in.nextLong();
			System.out.println(l+" "+2*l);
		}

	}

}


import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int t = in.nextInt();
		int l,r;
		for(int i=0 ; i<t ;i++) {
			l = in.nextInt();
			r = in.nextInt();
			outerloop:
			for(int ii=l ; ii<r ; ii++) {
				for(int jj=ii+1 ; jj<r ;jj++) {
					if(jj%ii==0)
					{
						System.out.println(ii+" "+jj);
						break outerloop;
					}
				}
			}
		}

	}

}


import java.util.*;
public class a{
	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int t=in.nextInt();

		while(t--!=0){
			long l=in.nextLong();
			long r=in.nextLong();

			System.out.println(l+" "+l*2);
		}
	}
}


import java.util.*;
public class a{
	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int t=in.nextInt();

		while(t--!=0){
			long l=in.nextLong();
			long r=in.nextLong();

			long mul=2;

			for(long x=l;x<=Math.sqrt(r);x++){
				long y=x*mul;
				if(x!=y){
					System.out.println(x+" "+y);
					break;
				}
				mul++;
			}

		}
	}
}


import java.util.*;
public class a{
	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int t=in.nextInt();

		while(t--!=0){
			long l=in.nextLong();
			long r=in.nextLong();

			long mul=2;

			for(long x=l;x<=Math.sqrt(r);x++){
				long y=x*mul;
				if(y%x==0&&x!=y){
					System.out.println(x+" "+y);
					break;
				}
				mul++;
			}

		}
	}
}


import java.util.Scanner;

/**
 *
 * @author dell
 */
public class FindDivisible {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        int Q = sc.nextInt();
        int N=10*100000000;

        while(Q!=0){

            int x = sc.nextInt();
            int y = sc.nextInt();

            int[] arr = new int[y+1];
            for(int i=2;i*i<=y;i++){
                if(arr[i]==0){
                    for(int j=i*i;j<=y;j=j+i){
                        arr[j]=1;
                    }
                }
            }

            arr[0]=1;
            arr[1]=1;
            arr[2]=1;
            int a=x,b=y;
            int res1=0,res2=0;
            while(true){
                if(arr[b]==1){
                    if(b>=2*a){
                        if(b%a==0){
                            res1=a;
                            res2=b;
                            break;
                        }
                        else{
                            if(a<b){
                                a++;
                            }
                            else{
                                a=x;
                            }
                        }
                    }
                    else{
                        a=x;
                    }
                }
                else{
                    b--;
                }
            }

            System.out.println(res1+" "+res2);
            Q--;
        }

    }

}


import java.util.Scanner;

/**
 *
 * @author dell
 */
public class FindDivisible {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        int Q = sc.nextInt();
        int N=10*100000000;
        int[] arr = new int[10000001];
       /* for(int i=2;i*i<=10000000;i++){
                if(arr[i]==0){
                    for(int j=i*i;j<=10000000;j=j+i){
                        arr[j]=1;
                    }
                }
            }*/

        while(Q!=0){

            int x = sc.nextInt();
            int y = sc.nextInt();
            y = 2*x;
            System.out.println(x+" "+y);
            Q--;
        }

    }

}


import java.util.Scanner;

/**
 *
 * @author dell
 */
public class FindDivisible {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        int Q = sc.nextInt();
        int N=10*100000000;
        int[] arr = new int[100000001];
        for(int i=2;i*i<=100000000;i++){
            if(arr[i]==0){
                for(int j=i*i;j<=100000000;j=j+i){
                    arr[j]=1;
                }
            }
        }

        while(Q!=0){

            int x = sc.nextInt();
            int y = sc.nextInt();

            int a=x,b=y;
            int res1=0,res2=0;
            while(true){
                if(arr[b]==1){
                    if(b>=2*a){
                        if(b%a==0){
                            res1=a;
                            res2=b;
                            break;
                        }
                        else{
                            if(a<b){
                                a++;
                            }
                            else{
                                a=x;
                            }
                        }
                    }
                    else{
                        a=x;
                    }
                }
                else{
                    b--;
                }
            }

            System.out.println(res1+" "+res2);
            Q--;
        }

    }

}


import java.util.Scanner;

/**
 *
 * @author dell
 */
public class FindDivisible {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        int Q = sc.nextInt();
        int N=10*100000000;

        while(Q!=0){

            int x = sc.nextInt();
            int y = sc.nextInt();

            int[] arr = new int[y+1];
            for(int i=2;i*i<=y;i++){
                if(arr[i]==0){
                    for(int j=i*i;j<=y;j=j+i){
                        arr[j]=1;
                    }
                }
            }

            int a=x,b=y;
            int res1=0,res2=0;
            while(true){
                if(arr[b]==1){
                    if(b>=2*a){
                        if(b%a==0){
                            res1=a;
                            res2=b;
                            break;
                        }
                        else{
                            if(a<b){
                                a++;
                            }
                            else{
                                a=x;
                            }
                        }
                    }
                    else{
                        a=x;
                    }
                }
                else{
                    b--;
                }
            }

            System.out.println(res1+" "+res2);
            Q--;
        }

    }

}


import java.util.Scanner;

/**
 *
 * @author dell
 */
public class FindDivisible {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        int Q = sc.nextInt();
        int N=10*100000000;
        int[] arr = new int[10000001];
        for(int i=2;i*i<=10000000;i++){
                if(arr[i]==0){
                    for(int j=i*i;j<=10000000;j=j+i){
                        arr[j]=1;
                    }
                }
            }

        while(Q!=0){

            int x = sc.nextInt();
            int y = sc.nextInt();

            arr[0]=1;
            arr[1]=1;
            arr[2]=1;
            int a=x,b=y;
            int res1=0,res2=0;
            while(true){
                if(arr[b]==1){
                    if(b>=2*a){
                        if(b%a==0){
                            res1=a;
                            res2=b;
                            break;
                        }
                        else{
                            if(a<b){
                                a++;
                            }
                            else{
                                a=x;
                            }
                        }
                    }
                    else{
                        a=x;
                    }
                }
                else{
                    b--;
                }
            }

            System.out.println(res1+" "+res2);
            Q--;
        }

    }

}


import java.util.Scanner;

/**
 *
 * @author dell
 */
public class FindDivisible {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        int Q = sc.nextInt();
        int N=10*100000000;
        int[] arr = new int[10000001];
       /* for(int i=2;i*i<=10000000;i++){
                if(arr[i]==0){
                    for(int j=i*i;j<=10000000;j=j+i){
                        arr[j]=1;
                    }
                }
            }*/

        while(Q!=0){

            int x = sc.nextInt();
            int y = sc.nextInt();

            arr[0]=1;
            arr[1]=1;
            arr[2]=1;
            int a=x,b=y;
            int res1=0,res2=0;
            while(true){
                if(b!=a){
                    if(b>=2*a){
                        if(b%a==0){
                            res1=a;
                            res2=b;
                            break;
                        }
                        else{
                            if(a<b){
                                a++;
                            }
                            else{
                                a=x;
                            }
                        }
                    }
                    else{
                        a=x;
                    }
                }
                else{
                    b--;
                }
            }

            System.out.println(res1+" "+res2);
            Q--;
        }

    }

}


import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class codeforces
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc=new Scanner(System.in);
		int test,l,r,i,counter=0;
		String input = sc.nextLine();
		test=Integer.parseInt(input);
		//System.out.println(test);
		while(test>0)
		{
		    input = sc.nextLine();
		    String[] numbersStr = input.split(" ");
		    int[] numbers = new int[ numbersStr.length ];

           for (  i = 0; i < numbersStr.length; i++ )
            {
            numbers[i] = Integer.parseInt( numbersStr[i] );
            }
            // System.out.println(numbers[0]+" "+numbers[1]);
 			l=numbers[0];
 			r=numbers[1];
 			counter=0;
			for(int k=l;k<=r;++k)
			{
				for(int j=k+1;j<=r;++j)
				{
				    //System.out.println(k+" "+j);
					if(j%k==0)
					{
					System.out.println(k+" "+j);
					counter=1;
					break;
				    }

				}
					if(counter==1)
				break;
			}
			test--;
		}
	}
}


import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Codeforces
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc=new Scanner(System.in);
		int test,i,counter=0;
		long l,r;
		String input = sc.nextLine();
		test=Integer.parseInt(input);
		//System.out.println(test);
		while(test>0)
		{
		    input = sc.nextLine();
		    String[] numbersStr = input.split(" ");
            // System.out.println(numbers[0]+" "+numbers[1]);
 			l=Integer.parseInt( numbersStr[0] );
 			r=Integer.parseInt( numbersStr[1] );
 			counter=0;
			for(long k=l;k<=r;++k)
			{
				for(long j=k+1;j<=r;++j)
				{
				    //System.out.println(k+" "+j);
					if(j%k==0)
					{
					System.out.println(k+" "+j);
					counter=1;
					break;
				    }
				}
					if(counter==1)
				break;
			}
			test--;
		}
	}
}


import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Codeforces
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc=new Scanner(System.in);
		int test,i,counter=0;
		long l,r;
		String input = sc.nextLine();
		test=Integer.parseInt(input);
		//System.out.println(test);
		while(test>0)
		{
		    input = sc.nextLine();
		    String[] numbersStr = input.split(" ");
            // System.out.println(numbers[0]+" "+numbers[1]);
 			l=Integer.parseInt( numbersStr[0] );
 			r=Integer.parseInt( numbersStr[1] );
 			counter=0;
			for(long k=l;k<=r;++k)
			{
				for(long j=2*k;j<=r;j=j+k)
				{
				    //System.out.println(k+" "+j);
					if(j%k==0)
					{
					System.out.println(k+" "+j);
					counter=1;
					break;
				    }
				}
					if(counter==1)
				break;
			}
			test--;
		}
	}
}


import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Codeforces
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc=new Scanner(System.in);
		int test,l,r,i;
		test=sc.nextInt();
		while(test>0)
		{
			l=sc.nextInt();
			r=sc.nextInt();
			for(i=l;i<=r;++i)
			{
				for(int j=i+1;j<=r;++j)
				{
					if(j%i==0)
					{
					System.out.println(i+" "+j);
					break;
				}
				}
			}
		}
	}
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ProgrammingContest.Codeforces.Round50
{
    class D
    {
        int N, K;
        StringBuilder res;
        string name, digits;
        bool[] fix;

        bool dfs(int idx)
        {
            //Console.WriteLine(idx);
            if (idx >= N)
            {
                //Console.WriteLine("check");
                string s = res.ToString();
                //Console.WriteLine(s);
                for (int i = -1; (i = s.IndexOf(name, i + 1)) >= 0; )
                {
                    //Console.WriteLine("{0}: {1}", i, fix[i]);
                    if (digits[i] == '0')
                        return false;
                }
                return true;
            }

            if (fix[idx]) return dfs(idx + 1);
            for (int i = 0; i < K; i++)
            {
                res[idx] = (char)(i + 'a');
                bool bad = false;
                string s = res.ToString();
                for (int j = idx - name.Length + 1; j <= idx + name.Length - 1; j++)
                    if (j >= 0 && s.Substring(j, name.Length) == name)
                    {
                        //Console.WriteLine(s.Substring(j,name.Length));
                        bad = true;
                        break;
                    }
                if (!bad && dfs(idx + 1)) return true;
#if false
                if (idx >= name.Length - 1)
                {
                    bool ok = false;
                    for (int j = 0; j < name.Length; j++)
                    {
                        if (res[idx - j] != name[name.Length - 1 - j])
                        {
                            ok = true;
                            break;
                        }
                    }
                    if (ok && dfs(idx + 1)) return true;
                }
                else if (dfs(idx + 1)) return true;
#endif
            }
            return false;
        }

        D(Scanner scanner)
        {
            N = scanner.NextInt();
            K = scanner.NextInt();
            name = scanner.NextString();
            digits = scanner.NextString() + "".PadLeft(name.Length - 1, '0');
            res = new StringBuilder("".PadLeft(N));
            fix = new bool[digits.Length];
            //Console.WriteLine(digits);

            for (int i = 0; i < digits.Length; i++)
                if (digits[i] == '1')
                    for (int j = 0; j < name.Length; j++)
                        res[i + j] = name[j];

            for (int i = 0; i < digits.Length; i++)
            {
                bool same = true;
                for (int j = 0; j < name.Length; j++)
                {
                    if (i + j >= N) { same = false; break; }
                    if (res[i + j] != name[j])
                        same = false;
                    if(digits[i] == '1')
                        fix[i + j] = true;
                }
                if (digits[i] == '1' != same)
                {
                    Console.WriteLine("No solution");
                    return;
                }
            }

            Console.WriteLine(dfs(0) ? res.ToString() : "No solution");
        }

        public static void Main()
        {
            //new D(Scanner.FromString(in1));
            new D(Scanner.FromConsole());
        }

        const string in1 = @"100 2
bab
10001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010
";

        const string in2 = @"12 5
abacaba
010001
";

        #region Scanner
        public class Scanner : IDisposable
        {
            const int MAX_BUFFER_SIZE = 1024 * 1024 * 16;
            const string DELIMITER = " \r\n\t";

            System.IO.TextReader stream;
            int pos = 0, len = 0;
            bool endStream = false;
            int BufferSize = MAX_BUFFER_SIZE;
            char[] buffer = new char[MAX_BUFFER_SIZE];

            public enum Option { Buffering, NoBuffering }

            public Scanner(System.IO.TextReader stream, Option bufferingOption)
            {
                this.stream = stream;
                if (bufferingOption == Option.NoBuffering) BufferSize = 1;
            }

            void ReadBuffer()
            {
                pos = 0;
                len = stream.ReadBlock(buffer, 0, BufferSize);
                endStream = len == 0;
            }

            void SkipDelimiter()
            {
                while (!endStream && IsDelimiter(Peek())) NextChar();
            }

            static bool IsDelimiter(char c)
            {
                return DELIMITER.Contains(c);
            }

            bool Continue(char c)
            {
                return !endStream && !IsDelimiter(c);
            }

            char Peek()
            {
                if (pos >= len) ReadBuffer();
                return buffer[pos];
            }

            public char NextChar()
            {
                if (pos >= len) ReadBuffer();
                return buffer[pos++];
            }

            public string NextString()
            {
                SkipDelimiter();
                StringBuilder res = new StringBuilder();
                for (char c = NextChar(); Continue(c); c = NextChar()) res.Append(c);
                return res.ToString();
            }

            public int NextInt()
            {
                SkipDelimiter();
                int res = 0;
                char c = NextChar();
                int sign = 1;
                if (c == '-') { sign = -1; c = NextChar(); }
                for (; Continue(c); c = NextChar())
                    res = res * 10 + (c - '0');
                return sign * res;
            }

            public long NextLong()
            {
                SkipDelimiter();
                long res = 0;
                char c = NextChar();
                long sign = 1;
                if (c == '-') { sign = -1; c = NextChar(); }
                for (; Continue(c); c = NextChar())
                    res = res * 10 + (c - '0');
                return sign * res;
            }

            public double NextDouble()
            {
                return double.Parse(NextString());
            }

            public int[] NextInts(int n)
            {
                int[] res = new int[n];
                for (int i = 0; i < n; i++) res[i] = NextInt();
                return res;
            }

            public long[] NextLongs(int n)
            {
                long[] res = new long[n];
                for (int i = 0; i < n; i++) res[i] = NextLong();
                return res;
            }

            public double[] NextDoubles(int n)
            {
                double[] res = new double[n];
                for (int i = 0; i < n; i++) res[i] = NextDouble();
                return res;
            }

            public string[] NextStrings(int n)
            {
                string[] res = new string[n];
                for (int i = 0; i < n; i++) res[i] = NextString();
                return res;
            }

            public static Scanner FromString(string s)
            {
                return new Scanner(new System.IO.StreamReader(new System.IO.MemoryStream(Encoding.ASCII.GetBytes(s))), Option.Buffering);
            }

            public static Scanner FromFile(string path)
            {
                return new Scanner(new System.IO.StreamReader(path), Option.Buffering);
            }

            public static Scanner FromConsole()
            {
                return new Scanner(Console.In, Option.Buffering);
            }

            public void Dispose()
            {
                stream.Close();
            }
        }
        #endregion
    }
}