import java.util.StringTokenizer;
import java.util.Collections;
import java.util.Collection;
import java.util.Set;
import java.util.HashSet;
import java.util.Map;
import java.util.HashMap;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Queue;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Stack;
import java.util.Vector;
import java.util.Hashtable;
import java.util.Iterator;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.FileReader;

import java.math.BigInteger;

public class Main
{

	static PrintWriter writer;
	static StringTokenizer sz;
	static BufferedReader reader;

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

		int v,n = readInt();
		int nMatch = n * (n - 1) / 2 ;
		int freq[] = new int[n + 1];
		int sleep[] = new int[n + 1];

		for (int i=1;i < nMatch;++i)
		{
			readLine();
			++freq[v = readInt()];
			++freq[readInt()];
			++sleep[v];
		}

		int count = 0;
		int vals[] = new int[2];

		for (int i=1;i <= n;++i)
		{
			if (freq[i] != (n - 1))
				vals[count++] = i;
		}

		boolean flag = false;
		for(int i=1;i<=n;++i)
		{
			if(sleep[vals[0]]+1==sleep[i])
			{
				flag = true;
				break;
			}
		}

		if(flag)
			writer.print(vals[1]+" "+vals[0]);
		else
			writer.print(vals[0]+" "+vals[1]);

		close();
	}

	private static class Pair implements Comparable<Pair>
	{
		int first,second;

		public Pair(int f, int s)
		{
			first = f;
			second = s;
		}

		@Override
		public int compareTo(Main.Pair p1)
		{
			if (first == p1.first)
				return  second - p1.second;
			return first - p1.first;
		}

		@Override
		public String toString()
		{
			return first + " " + second;
		}
	}

	private static String readString()
	throws IOException
	{
		if (sz.hasMoreTokens())
			return sz.nextToken();
		return reader.readLine();
	}

	private static void readLine()
	throws IOException
	{
		sz = new StringTokenizer(reader.readLine());
	}

	private static int readInt()
	throws IOException
	{
		if (sz.hasMoreTokens())
			return Integer.parseInt(sz.nextToken());
		return Integer.parseInt(reader.readLine());
	}

	private static long readLong()
	throws IOException
	{
		if (sz.hasMoreTokens())
			return Long.parseLong(sz.nextToken());
		return Long.parseLong(reader.readLine());
	}

	private static void declare()
	{
		writer = new PrintWriter(System.out);
		reader = new BufferedReader(
			new InputStreamReader(System.in));
		sz = new StringTokenizer("");
	}

	private static void declareFile()
	throws IOException
	{
		writer = new PrintWriter("output.txt");
		reader = new BufferedReader(
			new FileReader("input.txt"));
		sz = new StringTokenizer("");
	}

	private static void close()
	throws IOException
	{
		reader.close();
		writer.flush();
		writer.close();
	}
}


import java.io.BufferedReader;
//import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
//import java.io.FileReader;
//import java.io.FileWriter;
//import java.lang.StringBuilder;
//import java.util.Arrays;
//import java.util.HashMap;
//import java.util.ArrayList;
//import java.lang.Comparable;

public class Tournament {
    public static void main(String[] args) throws IOException {
        //BufferedReader in = new BufferedReader(new FileReader("input.txt"));
        //PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("output.txt")));
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        int n = Integer.parseInt(in.readLine());
        int m = ((n * (n - 1)) / 2) - 1;
        int[] compteur = new int[n+1];
        for(int i = 0; i < m; i++) {
            StringTokenizer st = new StringTokenizer(in.readLine());
            int p1 = Integer.parseInt(st.nextToken());
            int p2 = Integer.parseInt(st.nextToken());
            compteur[p1]++;
            compteur[p2]++;
        }
        int j = 0;
        int[] p = new int[2];
        for(int i = 1; i <= n; i++) {
            if(compteur[i] < n - 1) {
                p[j++] = i;
                if(j == 2) {
                    i = n + 1;
                }
            }
        }
        out.print(p[0] + " " + p[1]);
        out.close();
    }
}


import java.io.BufferedReader;
//import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
//import java.io.FileReader;
//import java.io.FileWriter;
//import java.lang.StringBuilder;
//import java.util.Arrays;
//import java.util.HashMap;
//import java.util.ArrayList;
//import java.lang.Comparable;

public class Tournament {
    public static void main(String[] args) throws IOException {
        //BufferedReader in = new BufferedReader(new FileReader("input.txt"));
        //PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("output.txt")));
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        int n = Integer.parseInt(in.readLine());
        int m = ((n * (n - 1)) / 2) - 1;
        int[] winner = new int[n+1];
        int[] total = new int[n+1];
        int[] loser = new int[n+1];
        for(int i = 0; i < m; i++) {
            StringTokenizer st = new StringTokenizer(in.readLine());
            int p1 = Integer.parseInt(st.nextToken());
            int p2 = Integer.parseInt(st.nextToken());
            winner[p1]++;
            loser[p2]++;
            total[p1]++;
            total[p2]++;
        }
        int j = 0;
        int[] p = new int[2];
        for(int i = 1; i <= n; i++) {
            if(total[i] < n - 1) {
                p[j++] = i;
                if(j == 2) {
                    i = n + 1;
                }
            }
        }
        if(winner[p[0]] > winner[p[1]])
            out.print(p[0] + " " + p[1]);
        else
            out.print(p[1] + " " + p[0]);
        out.close();
    }
}


import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner me = new Scanner(System.in);
        int n = me.nextInt();
        int t = -1 + n * (n - 1) / 2;
        int []tr = new int[100]; int[] win = new int[100]; int t1; int t2; int []ans = new int[2];
        while(t-- > 0){
            t1 = me.nextInt();
            t2 = me.nextInt();
            tr[t1]++; tr[t2]++; win[t1]++;
        }
        t1 = 0;
        for(int i = 1; i <= n; i++){
            if(tr[i] == n - 2) ans[t1++] = i;
        }
        if(win[ans[0]] >= win[ans[1]]) System.out.println(ans[0] + " " + ans[1]);
        else System.out.println(ans[1] + " " + ans[0]);
    }
}


import java.io.*;
import java.util.*;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.text.DecimalFormat;
import java.lang.Math;
import java.util.Iterator;
public class b86{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		ArrayList<Integer> B = new ArrayList<Integer>();
		ArrayList<Integer> A = new ArrayList<Integer>();
		for(int i = 0; i < ((n*(n-1))/2)-1; i++){
		    int a = sc.nextInt();
		    int b = sc.nextInt();
		    B.add(10*Math.min(a,b)+Math.max(a,b));
		}
		for(int i = 1; i <n; i++){
		    for(int j = i+1; j <=n; j++){
		        A.add(10*i+j);
		    }
		}
		for(int i = 0; i < A.size(); i++){
		    if(!B.contains(A.get(i))){
		        System.out.println(A.get(i)/10+" "+A.get(i)%10);
		    }
		}
	}
}


import java.io.*;
import java.util.*;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.text.DecimalFormat;
import java.lang.Math;
import java.util.Iterator;
public class b86{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		ArrayList<Integer> B = new ArrayList<Integer>();
		ArrayList<Integer> A = new ArrayList<Integer>();
		for(int i = 0; i <= n; i++){
		    int a = sc.nextInt();
		    int b = sc.nextInt();
		    B.add(10*Math.min(a,b)+Math.max(a,b));
		}
		for(int i = 1; i <n; i++){
		    for(int j = i+1; j <=n; j++){
		        A.add(10*i+j);
		    }
		}
		for(int i = 0; i < A.size(); i++){
		    if(!B.contains(A.get(i))){
		        System.out.println(A.get(i)%10+" "+A.get(i)/10);
		    }
		}
	}
}


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

public class Main{
    public static void main(String [] args)
    {
        Scanner scan=new Scanner(System.in);
        int n=scan.nextInt();
        int win[]=new int[n+1];
        int tr[]=new int[n+1];

        for(int i=0;i<n*(n-1)/2 -1 ;i++)
        {
            int t1=scan.nextInt();
            int t2=scan.nextInt();
            tr[t1]++;
            tr[t2]++;
            win[t1]++;
        }
        int ans[]=new int[2];
        int x=0;
        for(int i=1 ; i<=n ;i++)
        {
            if(tr[i]==n-2)
                ans[x++]=i;
        }
        if(win[ans[0]] >=win[ans[1]])
            System.out.println(ans[0]+" "+ans[1]);
        else
            System.out.println(ans[1]+" "+ans[0]);
    }
}


import java.io.*;
import java.util.*;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.text.DecimalFormat;
import java.lang.Math;
import java.util.Iterator;
public class b86{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		ArrayList<Integer> B = new ArrayList<Integer>();
		ArrayList<Integer> A = new ArrayList<Integer>();
		for(int i = 0; i < ((n*(n-1))/2)-1; i++){
		    int a = sc.nextInt();
		    int b = sc.nextInt();
		    B.add(10*Math.min(a,b)+Math.max(a,b));
		}
		for(int i = 1; i <n; i++){
		    for(int j = i+1; j <=n; j++){
		        A.add(10*i+j);
		    }
		}
		for(int i = 0; i < A.size(); i++){
		    if(!B.contains(A.get(i))){
		        System.out.println(A.get(i)%10+" "+A.get(i)/10);
		    }
		}
	}
}


import java.util.Scanner;

public class Tournament {
    public static void main(String asd[])throws Exception
    {
        Scanner in=new Scanner(System.in);
        int n=in.nextInt();
        int a[]=new int[n];
        for(int i=0;i<n*(n-1)/2-1;i++)
        {
            int b=in.nextInt();
            int c=in.nextInt();
            a[b-1]++;
            a[c-1]++;
        }
        int x=0,y=0;
        for(int i=0;i<n;i++)
        {
            if(a[i]!=(n-1)&&x==0)
            {
                x=i+1;
            }
            else if(a[i]!=(n-1) && x!=0)
                y=i+1;
        }
        if(Integer.bitCount(x)<Integer.bitCount(y))
            System.out.println(x+" "+y);
        else if(Integer.bitCount(x)>Integer.bitCount(y))
            System.out.println(y+" "+x);
        else{
            System.out.println(y+" "+x);
        }
    }
}


import java.util.Scanner;

public class Tournament {
    public static void main(String asd[])throws Exception
    {
        Scanner in=new Scanner(System.in);
        int n=in.nextInt();
        int a[]=new int[n];
        int aa[]=new int[n];
        for(int i=0;i<n*(n-1)/2-1;i++)
        {
            int b=in.nextInt();
            int c=in.nextInt();
            a[b-1]++;
            a[c-1]++;
            aa[b-1]++;
        }
        int x=0,y=0;
        for(int i=0;i<n;i++)
        {
            if(a[i]!=(n-1)&&x==0)
            {
                x=i+1;
            }
            else if(a[i]!=(n-1) && x!=0)
                y=i+1;
        }
        if(aa[x]>aa[y])
            System.out.println(x+" "+y);
        else
            System.out.println(y+" "+x);
    }
}


import java.util.Scanner;

public class Tournament {
    public static void main(String asd[])throws Exception
    {
        Scanner in=new Scanner(System.in);
        int n=in.nextInt();
        int a[]=new int[n];
        int aa[]=new int[n];
        for(int i=0;i<n*(n-1)/2-1;i++)
        {
            int b=in.nextInt();
            int c=in.nextInt();
            a[b-1]++;
            a[c-1]++;
            aa[b-1]++;
        }
        int x=0,y=0;
        for(int i=0;i<n;i++)
        {
            if(a[i]!=(n-1)&&x==0)
            {
                x=i+1;
            }
            else if(a[i]!=(n-1) && x!=0)
                y=i+1;
        }
        if(aa[x-1]>aa[y-1])
            System.out.println(x+" "+y);
        else
            System.out.println(y+" "+x);
    }
}


import java.util.*;
import java.io.*;
import java.math.BigInteger;
import java.util.regex.*;

public class Codeforces{

	static class MyScanner{
		BufferedReader br;
		StringTokenizer st;

		MyScanner(FileReader fileReader){
			br = new BufferedReader(fileReader);
		}

		MyScanner(){
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String nn(){
			while(st == null || !st.hasMoreElements()){
				try{
					st = new StringTokenizer(br.readLine());
				}catch(IOException e){
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		String nextLine(){
			String s = "";
			try{
				s = br.readLine();
			}catch(IOException e){
				e.printStackTrace();
			}
			return s;
		}

		int ni(){
			return Integer.parseInt(nn());
		}

		long nl(){
			return Long.parseLong(nn());
		}

		double nd(){
			return Double.parseDouble(nn());
		}
	}

	private static PrintWriter out;

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

		// Input from file
		// File inputFile = new File("JavaFile.txt");
		// File outputFile = new File("JavaOutputFile.txt");
		// FileReader fileReader = new FileReader(inputFile);
		// Here it ends

		MyScanner sc = new MyScanner();
		// MyScanner sc = new MyScanner(fileReader);

		out = new PrintWriter(new BufferedOutputStream(System.out)); // Output to console
		// out = new PrintWriter(new PrintStream(outputFile)); // Output to file

		int n = sc.ni();
		int[] matches = new int[n+1];
		int[][] wins = new int[n+1][n+1];
		for(int i = 0; i < n * (n - 1) / 2 - 1; i++){
			int x = sc.ni(), y = sc.ni();
			matches[x]++;
			matches[y]++;

			wins[x][y] = 1;
			wins[y][x] = -1;
		}

		int[] missing = new int[2];
		int cur = 0;
		for(int i = 1; i <= n; i++) if(matches[i] < n - 1) missing[cur++] = i;

		// out.println(Arrays.toString(missing));
		// for(int i = 1; i <= n; i++){
			// for(int j = 1; j <= n; j++) System.out.print(wins[i][j] + "\t");
			// System.out.println();
		// }
		// System.out.println("Hello");
		for(int i = 1; i <= n; i++){
			// System.out.println(wins[missing[0]][i] + " " + wins[missing[1]][i]);
			if(wins[missing[0]][i] != wins[missing[1]][i] && wins[missing[0]][i] != 0 && wins[missing[1]][i] != 0){
				// System.out.println(wins[missing[0]][i] + " " + wins[missing[1]][i]);
				if(wins[missing[0]][i] == 1) out.println(missing[0] + " " + missing[1]);
				else out.println(missing[1] + " " + missing[0]);
				break;
			}
		}

		out.close();
	}
}


import java.util.*;
import java.io.*;
import java.math.BigInteger;
import java.util.regex.*;

public class Codeforces{

	static class MyScanner{
		BufferedReader br;
		StringTokenizer st;

		MyScanner(FileReader fileReader){
			br = new BufferedReader(fileReader);
		}

		MyScanner(){
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String nn(){
			while(st == null || !st.hasMoreElements()){
				try{
					st = new StringTokenizer(br.readLine());
				}catch(IOException e){
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		String nextLine(){
			String s = "";
			try{
				s = br.readLine();
			}catch(IOException e){
				e.printStackTrace();
			}
			return s;
		}

		int ni(){
			return Integer.parseInt(nn());
		}

		long nl(){
			return Long.parseLong(nn());
		}

		double nd(){
			return Double.parseDouble(nn());
		}
	}

	private static PrintWriter out;

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

		// Input from file
		// File inputFile = new File("JavaFile.txt");
		// File outputFile = new File("JavaOutputFile.txt");
		// FileReader fileReader = new FileReader(inputFile);
		// Here it ends

		MyScanner sc = new MyScanner();
		// MyScanner sc = new MyScanner(fileReader);

		out = new PrintWriter(new BufferedOutputStream(System.out)); // Output to console
		// out = new PrintWriter(new PrintStream(outputFile)); // Output to file

		int n = sc.ni();
		int[] matches = new int[n+1];
		int[][] wins = new int[n+1][n+1];
		for(int i = 0; i < n * (n - 1) / 2 - 1; i++){
			int x = sc.ni(), y = sc.ni();
			matches[x]++;
			matches[y]++;

			wins[x][y] = 1;
			wins[y][x] = -1;
		}

		int[] missing = new int[2];
		int cur = 0;
		for(int i = 1; i <= n; i++) if(matches[i] < n - 1) missing[cur++] = i;

		for(int i = 1; i <= n; i++){
			if(wins[missing[0]][i] != wins[missing[1]][1] && wins[missing[0]][i] != 0 && wins[missing[1]][i] != 0){
				if(wins[missing[0]][i] == 1) out.println(missing[0] + " " + missing[1]);
				else out.println(missing[1] + " " + missing[0]);
				break;
			}
		}

		out.close();
	}
}


import java.util.*;
import java.io.*;
import java.math.BigInteger;
import java.util.regex.*;

public class Codeforces{

	static class MyScanner{
		BufferedReader br;
		StringTokenizer st;

		MyScanner(FileReader fileReader){
			br = new BufferedReader(fileReader);
		}

		MyScanner(){
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String nn(){
			while(st == null || !st.hasMoreElements()){
				try{
					st = new StringTokenizer(br.readLine());
				}catch(IOException e){
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		String nextLine(){
			String s = "";
			try{
				s = br.readLine();
			}catch(IOException e){
				e.printStackTrace();
			}
			return s;
		}

		int ni(){
			return Integer.parseInt(nn());
		}

		long nl(){
			return Long.parseLong(nn());
		}

		double nd(){
			return Double.parseDouble(nn());
		}
	}

	private static PrintWriter out;

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

		// Input from file
		// File inputFile = new File("JavaFile.txt");
		// File outputFile = new File("JavaOutputFile.txt");
		// FileReader fileReader = new FileReader(inputFile);
		// Here it ends

		MyScanner sc = new MyScanner();
		// MyScanner sc = new MyScanner(fileReader);

		out = new PrintWriter(new BufferedOutputStream(System.out)); // Output to console
		// out = new PrintWriter(new PrintStream(outputFile)); // Output to file

		int n = sc.ni();
		int[] matches = new int[n+1];
		int[][] wins = new int[n+1][n+1];
		for(int i = 0; i < n * (n - 1) / 2 - 1; i++){
			int x = sc.ni(), y = sc.ni();
			matches[x]++;
			matches[y]++;

			wins[x][y] = 1;
			wins[y][x] = -1;
		}

		int[] missing = new int[2];
		int cur = 0;
		for(int i = 1; i <= n; i++) if(matches[i] < n - 1) missing[cur++] = i;

		// out.println(Arrays.toString(missing));
		// for(int i = 1; i <= n; i++){
			// for(int j = 1; j <= n; j++) System.out.print(wins[i][j] + "\t");
			// System.out.println();
		// }
		// System.out.println("Hello");
		boolean flag = false;
		for(int i = 1; i <= n; i++){
			// System.out.println(wins[missing[0]][i] + " " + wins[missing[1]][i]);
			if(wins[missing[0]][i] != wins[missing[1]][i] && wins[missing[0]][i] != 0 && wins[missing[1]][i] != 0){
				// System.out.println(wins[missing[0]][i] + " " + wins[missing[1]][i]);
				if(wins[missing[0]][i] == 1) out.println(missing[0] + " " + missing[1]);
				else out.println(missing[1] + " " + missing[0]);
				flag = true;
				break;
			}
		}

		if(!flag) out.println(missing[0] + " " + missing[1]);

		out.close();
	}
}


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

import static java.lang.Math.*;

public class Cf182 implements Runnable
{
	static class InputReader
	{
		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;
		private SpaceCharFilter filter;
		private BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		public InputReader(InputStream stream)
		{
			this.stream = stream;
		}

		public int read()
		{
			if (numChars==-1)
				throw new InputMismatchException();

			if (curChar >= numChars)
			{
				curChar = 0;
				try
				{
					numChars = stream.read(buf);
				}
				catch (IOException e)
				{
					throw new InputMismatchException();
				}

				if(numChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public String nextLine()
		{
			String str = "";
			try
			{
				str = br.readLine();
			}
			catch (IOException e)
			{
				e.printStackTrace();
			}
			return str;
		}
		public int nextInt()
		{
			int c = read();

			while(isSpaceChar(c))
				c = read();

			int sgn = 1;

			if (c == '-')
			{
				sgn = -1;
				c = read();
			}

			int res = 0;
			do
			{
				if(c<'0'||c>'9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			}
			while (!isSpaceChar(c));

			return res * sgn;
		}

		public long nextLong()
		{
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-')
			{
				sgn = -1;
				c = read();
			}
			long res = 0;

			do
			{
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			}
			while (!isSpaceChar(c));
				return res * sgn;
		}

		public double nextDouble()
		{
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-')
			{
				sgn = -1;
				c = read();
			}
			double res = 0;
			while (!isSpaceChar(c) && c != '.')
			{
				if (c == 'e' || c == 'E')
					return res * Math.pow(10, nextInt());
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			}
			if (c == '.')
			{
				c = read();
				double m = 1;
				while (!isSpaceChar(c))
				{
					if (c == 'e' || c == 'E')
						return res * Math.pow(10, nextInt());
					if (c < '0' || c > '9')
						throw new InputMismatchException();
					m /= 10;
					res += (c - '0') * m;
					c = read();
				}
			}
			return res * sgn;
		}

		public String readString()
		{
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do
			{
				res.appendCodePoint(c);
				c = read();
			}
			while (!isSpaceChar(c));

			return res.toString();
		}

		public boolean isSpaceChar(int c)
		{
			if (filter != null)
				return filter.isSpaceChar(c);
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		public String next()
		{
			return readString();
		}

		public interface SpaceCharFilter
		{
			public boolean isSpaceChar(int ch);
		}
	}
	public static void main(String args[]) throws Exception
	{
		new Thread(null, new Cf182(),"Main",1<<27).start();
	}

	//  array sorting by colm
public static void sortbyColumn(int arr[][], int col)
    {

        Arrays.sort(arr, new Comparator<int[]>() {

          @Override
          public int compare(final int[] entry1,
                             final int[] entry2) {

            if (entry1[col] > entry2[col])
                return 1;
            else
                return -1;
          }
        });
    }

	// gcd

	public static long findGCD(long arr[], int n)
	{
		long result = arr[0];
		for (int i = 1; i < n; i++)
			result = gcd(arr[i], result);
		return result;
	}
	// fibonaci
	static int fib(int n)
    {
        int a = 0, b = 1, c;
        if (n == 0)
            return a;
        for (int i = 2; i <= n; i++)
        {
            c = a + b;
            a = b;
            b = c;
        }
        return b;
    }

// sort a string
    public static String sortString(String inputString)
    {

        char tempArray[] = inputString.toCharArray();

        Arrays.sort(tempArray);

        return new String(tempArray);
    }
    // pair function

    // list.add(new Pair<>(sc.nextInt(), i + 1));
    //     Collections.sort(list, (a, b) -> Integer.compare(b.first, a.first));
    // private static class Pair<F, S> {

    //     private F first;

    //     private S second;

    //     public Pair() {}

    //     public Pair(F first, S second) {
    //         this.first = first;
    //         this.second = second;
    //     }
    // }

	// SortedArrayList<Integer> test = new SortedArrayList<Integer>();
    // test.insert(5);
            public static class SortedArrayList<T> extends ArrayList<T> {

            @SuppressWarnings("unchecked")
            public void insert(T value) {
                add(value);
                Comparable<T> cmp = (Comparable<T>) value;
                for (int i = size()-1; i > 0 && cmp.compareTo(get(i-1)) < 0; i--)
                    Collections.swap(this, i, i-1);
            }
        }

    static long gcd(long a, long b)
    {
    if (a == 0)
        return b;
    return gcd(b % a, a);
    }

    static long lcm(long a, long b)
    {
        return (a*b)/gcd(a, b);
    }

   class Pair {
    int x;
    int y;

        // Constructor
    public Pair(int x, int y)
        {
            this.x = x;
            this.y = y;
        }
}

   class Compare {

     void compare(Pair arr[], int n)
    {
        // Comparator to sort the pair according to second element
        Arrays.sort(arr, new Comparator<Pair>() {
            @Override public int compare(Pair p1, Pair p2)
            {
                return p1.y - p2.y;
            }
        });

    }
}
	public void run()
	{
		InputReader sc = new InputReader(System.in);
		PrintWriter w = new PrintWriter(System.out);
		int n = sc.nextInt();
		int temp[] = new int[n+1];
		int len = (n*n - n)/2 - 1;
		for(int i=0;i<len;i++)
		{
		    temp[sc.nextInt()]++;
		    temp[sc.nextInt()]++;
		}
		int x = -1,y = -1;
		for(int i=1;i<=n;i++)
		{
		    if(temp[i]!=n-1)
		    {
		        if(x==-1)
		            x = i;
		        else if(y==-1)
		            y = i;
		        else
		            break;
		    }
		}
		w.println(x+" "+y);
        w.flush();
	    w.close();
	}
}


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

import static java.lang.Math.*;

public class Cf182 implements Runnable
{
	static class InputReader
	{
		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;
		private SpaceCharFilter filter;
		private BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		public InputReader(InputStream stream)
		{
			this.stream = stream;
		}

		public int read()
		{
			if (numChars==-1)
				throw new InputMismatchException();

			if (curChar >= numChars)
			{
				curChar = 0;
				try
				{
					numChars = stream.read(buf);
				}
				catch (IOException e)
				{
					throw new InputMismatchException();
				}

				if(numChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public String nextLine()
		{
			String str = "";
			try
			{
				str = br.readLine();
			}
			catch (IOException e)
			{
				e.printStackTrace();
			}
			return str;
		}
		public int nextInt()
		{
			int c = read();

			while(isSpaceChar(c))
				c = read();

			int sgn = 1;

			if (c == '-')
			{
				sgn = -1;
				c = read();
			}

			int res = 0;
			do
			{
				if(c<'0'||c>'9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			}
			while (!isSpaceChar(c));

			return res * sgn;
		}

		public long nextLong()
		{
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-')
			{
				sgn = -1;
				c = read();
			}
			long res = 0;

			do
			{
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			}
			while (!isSpaceChar(c));
				return res * sgn;
		}

		public double nextDouble()
		{
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-')
			{
				sgn = -1;
				c = read();
			}
			double res = 0;
			while (!isSpaceChar(c) && c != '.')
			{
				if (c == 'e' || c == 'E')
					return res * Math.pow(10, nextInt());
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			}
			if (c == '.')
			{
				c = read();
				double m = 1;
				while (!isSpaceChar(c))
				{
					if (c == 'e' || c == 'E')
						return res * Math.pow(10, nextInt());
					if (c < '0' || c > '9')
						throw new InputMismatchException();
					m /= 10;
					res += (c - '0') * m;
					c = read();
				}
			}
			return res * sgn;
		}

		public String readString()
		{
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do
			{
				res.appendCodePoint(c);
				c = read();
			}
			while (!isSpaceChar(c));

			return res.toString();
		}

		public boolean isSpaceChar(int c)
		{
			if (filter != null)
				return filter.isSpaceChar(c);
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		public String next()
		{
			return readString();
		}

		public interface SpaceCharFilter
		{
			public boolean isSpaceChar(int ch);
		}
	}
	public static void main(String args[]) throws Exception
	{
		new Thread(null, new Cf182(),"Main",1<<27).start();
	}

	//  array sorting by colm
public static void sortbyColumn(int arr[][], int col)
    {

        Arrays.sort(arr, new Comparator<int[]>() {

          @Override
          public int compare(final int[] entry1,
                             final int[] entry2) {

            if (entry1[col] > entry2[col])
                return 1;
            else
                return -1;
          }
        });
    }

	// gcd

	public static long findGCD(long arr[], int n)
	{
		long result = arr[0];
		for (int i = 1; i < n; i++)
			result = gcd(arr[i], result);
		return result;
	}
	// fibonaci
	static int fib(int n)
    {
        int a = 0, b = 1, c;
        if (n == 0)
            return a;
        for (int i = 2; i <= n; i++)
        {
            c = a + b;
            a = b;
            b = c;
        }
        return b;
    }

// sort a string
    public static String sortString(String inputString)
    {

        char tempArray[] = inputString.toCharArray();

        Arrays.sort(tempArray);

        return new String(tempArray);
    }
    // pair function

    // list.add(new Pair<>(sc.nextInt(), i + 1));
    //     Collections.sort(list, (a, b) -> Integer.compare(b.first, a.first));
    // private static class Pair<F, S> {

    //     private F first;

    //     private S second;

    //     public Pair() {}

    //     public Pair(F first, S second) {
    //         this.first = first;
    //         this.second = second;
    //     }
    // }

	// SortedArrayList<Integer> test = new SortedArrayList<Integer>();
    // test.insert(5);
            public static class SortedArrayList<T> extends ArrayList<T> {

            @SuppressWarnings("unchecked")
            public void insert(T value) {
                add(value);
                Comparable<T> cmp = (Comparable<T>) value;
                for (int i = size()-1; i > 0 && cmp.compareTo(get(i-1)) < 0; i--)
                    Collections.swap(this, i, i-1);
            }
        }

    static long gcd(long a, long b)
    {
    if (a == 0)
        return b;
    return gcd(b % a, a);
    }

    static long lcm(long a, long b)
    {
        return (a*b)/gcd(a, b);
    }

   class Pair {
    int x;
    int y;

        // Constructor
    public Pair(int x, int y)
        {
            this.x = x;
            this.y = y;
        }
}

   class Compare {

     void compare(Pair arr[], int n)
    {
        // Comparator to sort the pair according to second element
        Arrays.sort(arr, new Comparator<Pair>() {
            @Override public int compare(Pair p1, Pair p2)
            {
                return p1.y - p2.y;
            }
        });

    }
}
	public void run()
	{
		InputReader sc = new InputReader(System.in);
		PrintWriter w = new PrintWriter(System.out);
		int n = sc.nextInt();
		int temp[] = new int[n+1];
		int len = (n*n - n)/2 - 1;
		ArrayList<Integer>[] al = new ArrayList[n+1];
		for (int i = 0; i <= n; i++)
            al[i] = new ArrayList<Integer>();

		for(int i=0;i<len;i++)
		{
		    int x = sc.nextInt();
		    int y = sc.nextInt();
		    temp[x]++;
		    temp[y]++;
		    al[x].add(y);
		}
		int x = -1,y = -1;
		for(int i=1;i<=n;i++)
		{
		    if(temp[i]!=n-1)
		    {
		        if(x==-1)
		            x = i;
		        else if(y==-1)
		            y = i;
		        else
		            break;
		    }
		}
		int flag = 0;
		for(int i:al[x])
		{
		    for(int k:al[i])
		    {
		        if(k==y)
		        {
		            flag = 1;
		            break;
		        }
		    }
		    if(flag==1)
		        break;
		}
		if(flag==1)
		    w.println(x+" "+y);
		else
		    w.println(y+" "+x);
        w.flush();
	    w.close();
	}
}


import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

import javax.management.RuntimeErrorException;

public class Template implements Runnable {

	BufferedReader in;
	PrintWriter out;
	StringTokenizer tok = new StringTokenizer("");

	void init() throws FileNotFoundException {
		try {
			in = new BufferedReader(new FileReader("input.txt"));
			out = new PrintWriter("output.txt");
		} catch (Exception e) {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
		}
	}

	class GraphBuilder {
		int n, m;
		int[] x, y;
		int index;
		int[] size;

		GraphBuilder(int n, int m) {
			this.n = n;
			this.m = m;
			x = new int[m];
			y = new int[m];
			size = new int[n];
		}

		void add(int u, int v) {
			x[index] = u;
			y[index] = v;
			size[u]++;
			size[v]++;
			index++;
		}

		void addDir(int u, int v) {
			x[index] = u;
			y[index] = v;
			size[u]++;
			index++;
		}

		int[][] buildDir() {
			int[][] graph = new int[n][];
			for (int i = 0; i < n; i++) {
				graph[i] = new int[size[i]];
			}
			for (int i = m - 1; i >= 0; i--) {
				graph[x[i]][--size[x[i]]] = y[i];
			}
			return graph;
		}

		int[][] build() {
			int[][] graph = new int[n][];
			for (int i = 0; i < n; i++) {
				graph[i] = new int[size[i]];
			}
			for (int i = m - 1; i >= 0; i--) {
				graph[x[i]][--size[x[i]]] = y[i];
				graph[y[i]][--size[y[i]]] = x[i];
			}
			return graph;
		}
	}

	String readString() throws IOException {
		while (!tok.hasMoreTokens()) {
			try {
				tok = new StringTokenizer(in.readLine());
			} catch (Exception e) {
				return null;
			}
		}
		return tok.nextToken();
	}

	int readInt() throws IOException {
		return Integer.parseInt(readString());
	}

	int[] readIntArray(int size) throws IOException {
		int[] res = new int[size];
		for (int i = 0; i < size; i++) {
			res[i] = readInt();
		}
		return res;
	}

	long readLong() throws IOException {
		return Long.parseLong(readString());
	}

	double readDouble() throws IOException {
		return Double.parseDouble(readString());
	}

	<T> List<T>[] createGraphList(int size) {
		List<T>[] list = new List[size];
		for (int i = 0; i < size; i++) {
			list[i] = new ArrayList<>();
		}
		return list;
	}

	public static void main(String[] args) {
		new Template().run();
		// new Thread(null, new Template(), "", 1l * 200 * 1024 * 1024).start();
	}

	long timeBegin, timeEnd;

	void time() {
		timeEnd = System.currentTimeMillis();
		System.err.println("Time = " + (timeEnd - timeBegin));
	}

	long memoryTotal, memoryFree;

	void memory() {
		memoryFree = Runtime.getRuntime().freeMemory();
		System.err.println("Memory = " + ((memoryTotal - memoryFree) >> 10) + " KB");
	}

	public void run() {
		try {
			timeBegin = System.currentTimeMillis();
			memoryTotal = Runtime.getRuntime().freeMemory();
			init();
			solve();
			out.close();
			if (System.getProperty("ONLINE_JUDGE") == null) {
				time();
				memory();
			}
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(-1);
		}
	}

	boolean ans(boolean[][] res, int n) {
		int[] p = new int[n];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (i == j)
					continue;
				if (res[i][j])
					p[i]++;
			}
		}
		HashSet<Integer> set = new HashSet<>();
		for (int x : p)
			set.add(x);
		if (set.size() != n)
			return false;
		return true;
	}

	void solve() throws IOException {
		int n = readInt();
		boolean[][] wasGame = new boolean[n][n];
		boolean[][] res = new boolean[n][n];
		int cnt = n * (n - 1) / 2 - 1;
		for (int i = 0; i < cnt; i++) {
			int a = readInt() - 1;
			int b = readInt() - 1;
			wasGame[a][b] = wasGame[b][a] = true;
			res[a][b] = true;
			res[b][a] = false;
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (i == j)
					continue;
				if (wasGame[i][j]) continue;
				res[i][j] = true;
				res[j][i] = false;
				if (ans(res, n)) {
					out.println((i + 1) + " " + (j + 1));
					return;
				}

			}
		}

	}

}


import java.io.OutputStreamWriter;
import java.io.BufferedWriter;
import java.util.Comparator;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Random;
import java.io.Writer;
import java.util.HashSet;
import java.util.List;
import java.io.IOException;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.ArrayList;
import java.util.NoSuchElementException;
import java.util.TreeSet;
import java.math.BigInteger;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Alex
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		OutputWriter out = new OutputWriter(outputStream);
		TaskB solver = new TaskB();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskB {
    public void solve(int testNumber, InputReader in, OutputWriter out){
	    int n = in.ri();
	    int[][] input = IOUtils.readIntTable(in, (n * (n - 1)) / 2 - 1, 2);
	    int[] win = new int[n];
	    int[] count = new int[n];
	    for(int[] pair : input) {
		    int first = pair[0] - 1, second = pair[1] - 1;
		    win[first]++;
		    count[first]++;
		    count[second]++;
	    }
	    int[] res = new int[2];
	    int index = 0;
	    for(int i = 0; i < count.length; i++)  if (count[i] != n - 1) res[index++] = i;
	    if (win[res[0]] < win[res[1]]) ArrayUtils.swap(res, 0, 1);
	    out.printLine(res[0] + 1, res[1] + 1);
    }
}

class InputReader {
	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}
	public int ri(){
		return readInt();
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return isWhitespace(c);
	}

	public static boolean isWhitespace(int c) {
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}
	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}

class OutputWriter {
	private final PrintWriter writer;

	public OutputWriter(OutputStream outputStream) {
		writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
	}
	public void print(Object...objects) {
		for (int i = 0; i < objects.length; i++) {
			if (i != 0)
				writer.print(' ');
			writer.print(objects[i]);
		}
	}
	public void printLine(Object...objects) {
		print(objects);
		writer.println();
	}
	public void close() {
		writer.close();
	}
}

class IOUtils {
	public static int[] readIntArray(InputReader in, int size) {
		int[] array = new int[size];
		for (int i = 0; i < size; i++)
			array[i] = in.readInt();
		return array;
	}
	public static int[][] readIntTable(InputReader in, int rowCount, int columnCount) {
		int[][] table = new int[rowCount][];
		for (int i = 0; i < rowCount; i++)
			table[i] = readIntArray(in, columnCount);
		return table;
	}
}

class ArrayUtils {
	public static void swap(int[] data, int i, int j) {
		int tmp = data[i];
		data[i] = data[j];
		data[j] = tmp;
	}
}


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

public class Main {

  static LinkedList<Integer>[] graph;
  static boolean[] marked;

  static void dfs(int v) {
      marked[v] = true;

      for (int w : graph[v]) {
          if (!marked[w])
            dfs(w);
      }
  }

  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

    int N = Integer.parseInt(in.readLine());
    graph = new LinkedList[N];

    for (int i = 0; i < N; i++)
        graph[i] = new LinkedList<>();

    marked = new boolean[N];
    int[] count = new int[N];

    for (int i = 0; i < N * (N - 1) / 2 - 1; i++) {
        StringTokenizer st = new StringTokenizer(in.readLine());
        int v = Integer.parseInt(st.nextToken()) - 1;
        int w = Integer.parseInt(st.nextToken()) - 1;
        count[v]++;
        count[w]++;
        graph[v].add(w);
    }

    int v = -1;
    int w = -1;

    for (int i = 0; i < N; i++) {
        if (count[i] != N - 1) {
            if (v == -1)
                v = i;
            else
                w = i;
        }
    }

    dfs(v);
    if (marked[w])
        System.out.println((v + 1) + " " + (w + 1));
    else
        System.out.println((w + 1) + " " + (v + 1));

    in.close();
  }
}


/* package codechef; // 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 class Main
{
	public static void main (String[] args)
	{
		// your code goes here
		Scanner in = new Scanner(System.in);
		int participants=in.nextInt();
		int matches = (participants*(participants-1)/2)-1;
		//unqeighted directed graph (competion graph)
		boolean adjmatrix[][]=new boolean[51][51];
		for(int i=0;i<matches;i++){
		    int a=in.nextInt();
		    int b=in.nextInt();
		    adjmatrix[b][a]=true;//is b dominated by a: yes
		}
		for(int i=1;i<=participants;i++){
		    for(int j=1;j<=participants;j++){
		        if(i==j) continue;
		        if(!adjmatrix[i][j]&&!adjmatrix[j][i]){
		            //missing match
		            //do a bfs search
		            if(bfs(adjmatrix,i,j)){
		                System.out.println(j+" "+i);
		            }else{
		                System.out.println(i+" "+j);
		            }
		            return;
		        }
		    }
		}

	}
	public static boolean bfs(boolean[][] adj,int i,int j){
	    LinkedList<Integer> q = new LinkedList<Integer>();
	    q.add(i);
	    boolean[] visited=new boolean[51];
	    while(!q.isEmpty()){
	        Integer cur=q.remove();
	        if(cur==j) return true;
	        if(visited[cur]) continue;
	        visited[cur]=true;
	        for(int x=1;x<=50;x++){
	            if(x==cur) continue;

	            if(adj[cur][x]) {

	                q.add(x);
	            }
	        }
	    }
	    return false;
	}
}


/* package codechef; // 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 class Main
{
	public static void main (String[] args)
	{
		// your code goes here
		Scanner in = new Scanner(System.in);
		int participants=in.nextInt();
		int matches = (participants*(participants-1)/2)-1;
		//unqeighted directed graph (competion graph)
		int adjmatrix[][]=new int[51][51];
		for(int i=0;i<matches;i++){
		    adjmatrix[in.nextInt()][in.nextInt()]=1;
		}
		for(int i=1;i<=participants;i++){
		    for(int j=1;j<=participants;j++){
		        if(i==j) continue;
		        if(adjmatrix[i][j]==0&&adjmatrix[j][i]==0){
		            //missing match
		            //do a bfs search
		            if(bfs(adjmatrix,i,j)){
		                System.out.println(i+" "+j);
		            }else{
		                System.out.println(j+" "+i);
		            }
		            return;
		        }
		    }
		}

	}
	public static boolean bfs(int[][] adj,int i,int j){
	    LinkedList<Integer> q = new LinkedList<Integer>();
	    q.add(i);
	    boolean visited[]=new boolean[51];
	    while(q.isEmpty()){
	        Integer cur=q.remove();
	        if(cur==j) return true;
	        if(visited[cur]) continue;
	        visited[cur]=true;
	        for(int x=1;x<=50;x++){
	            if(x==cur) continue;
	            if(adj[x][i]==1) q.add(x);
	        }
	    }
	    return false;
	}
}


 import java.io.*; import java.math.BigInteger; import java.math.RoundingMode; import java.text.DecimalFormat; import java.util.*;
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.LinkedList;

public class Main {
static double eps=(double)1e-7;
static long mod=(int)1e9+7;
//ArrayList<Integer> v=new ArrayList<Integer>();
public static void main(String args[]){
	Scanner sc = new Scanner(System.in);
	int n=sc.nextInt();
	int a[][]=new int[n][n];
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			a[i][j]=0;
	int len=(n)*(n-1)/2;
	Graph gf=new Graph(n+1);
	for(int i=0;i<len-1;i++){
		int x=sc.nextInt();
		int y=sc.nextInt();
		a[x-1][y-1]=1;
		a[y-1][x-1]=1;
		gf.AddEdge(x, y);
	}
	int c1=-1;
	int c2=-1;
	int f=1;
	for(int i=0;i<n;i++){

		for(int j=0;j<n;j++)
			if(a[i][j]==0&&i!=j){
		      c1=i+1;
		      c2=j+1;
		      f=0;
	           break;
			}
		if(f==0)
			break;
	}
	//gf.display();
	if(gf.dfs(c1, c2)==1)
		System.out.println(c1+" "+c2);
	else
		System.out.println(c2+" "+c1);
}
}

class Graph {
private int V;
private ArrayList<Integer> adj[];
//static boolean set[];
Graph(int v)
{
	V=v+1;
	adj=new ArrayList[V];
	for(int i=0;i<V;i++)
		adj[i]=new ArrayList<Integer>();
	//set=new boolean[V];
}
public void AddEdge(int a,int b){
	adj[a].add(b);
	//adj[b].add(a);
}
public int dfs(int x,int val)
{
	boolean visited[]=new boolean[V];
	int m=DFS(x,visited,val);
    return m;
}
/*public void display(){
	for(int i=1;i<V;i++){
		System.out.print(i+" ");
		for(int j=0;j<adj[i].size();j++){
			System.out.print(adj[i].get(j)+" ");
		}
		System.out.println();
	}
}*/
private int DFS(int x, boolean[] visited,int val) {
	visited[x]=true;
	if(x==val)
		return 1;
	for(int i=0;i<adj[x].size();i++){

		if(!visited[adj[x].get(i)]){
			if(DFS(adj[x].get(i),visited,val)==1)
				return 1;

		}
	}
	return 0;
}
/*public void ConnectedComponents(){
	boolean visited[]=new boolean[V];
	for(int v=0;v<V;v++){
		if(visited[v]==false){
			DFS(v,visited);
			System.out.println();
		}
	}
}*/
public int Solve(int p[],int from)
{
	if(dfs(from,p[from])!=1)
	{
		return 0;
	}
	return 1;
}

}


 import java.io.*; import java.math.BigInteger; import java.math.RoundingMode; import java.text.DecimalFormat; import java.util.*;
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.LinkedList;

public class Main {
static double eps=(double)1e-7;
static long mod=(int)1e9+7;
//ArrayList<Integer> v=new ArrayList<Integer>();
public static void main(String args[]){
	Scanner sc = new Scanner(System.in);
	int n=sc.nextInt();
	int a[][]=new int[n][n];
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			a[i][j]=0;
	int len=(n)*(n-1)/2;
	for(int i=0;i<len-1;i++){
		int x=sc.nextInt();
		int y=sc.nextInt();
		a[x-1][y-1]=1;
		a[y-1][x-1]=1;
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++)
			if(a[i][j]==0&&i!=j){
		       System.out.println((i+1)+" "+(j+1));
	            return;
			}
	}
	//gf.display();
}
}


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

public class Main {

    FastScanner in;
    PrintWriter out;

    static class FastScanner {

        BufferedReader br;
        StringTokenizer st;

        FastScanner(InputStream in) {
            br = new BufferedReader(new InputStreamReader(in));
            st = null;
        }

        String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        String nextLine() throws IOException {
            if (st == null || !st.hasMoreTokens())
                return br.readLine();
            StringBuilder result = new StringBuilder(st.nextToken());
            while (st.hasMoreTokens()) {
                result.append(" ");
                result.append(st.nextToken());
            }
            return result.toString();
        }

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

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

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

    }

    void run() throws IOException {
        in = new FastScanner(System.in);
        out = new PrintWriter(System.out, false);
        solve();
        out.close();
    }

    public static void main(String[] args) throws IOException{
        new Main().run();
    }

    public void printArr(int[] arr){
        for(int i = 0; i < arr.length; i++){
            out.print(arr[i] + " ");
        }
        out.println();
    }

    public long gcd(long a, long b){
        if(a == 0) return b;
        return gcd(b % a, a);
    }

    public void solve() throws IOException{

        int n = in.nextInt();
        int t = n * (n - 1) / 2;
        int[] games = new int[n + 1];
        int[] won = new int[n + 1];
        for(int i = 0; i < t - 1; i++){
            int w = in.nextInt();
            int l = in.nextInt();
            games[w]++; games[l]++; won[w]++;
        }

        List<Integer> remain = new ArrayList<>();
        for(int i = 1; i <= n; i++){
            if(games[i] != n - 1) remain.add(i);
        }

        int p1 = remain.get(0);
        int p2 = remain.get(1);

        out.println( won[p1] >= won[p2] ? (p1 + " " + p2) : (p2 + " " + p1));

        return;

    }

}


import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n=in.nextInt();
		int[]p=new int[n],g=new int[n];
		for (int i=1;i<n*(n-1)/2;i++) {
			int x=in.nextInt()-1,y=in.nextInt()-1;
			p[x]=p[y]+1;
			g[x]++;g[y]++;
		}
		int a=-1,b=-1;
		for (int i=0;i<n;i++) {
			if (g[i]!=n-1) {
				if (a==-1) {
					a=i;
				} else {
					b=i;
					break;
				}
			}
		}
		if (p[a]>p[b]) {
			System.out.println(String.valueOf(a+1)+" "+String.valueOf(b+1));
		} else {
			System.out.println(String.valueOf(b+1)+" "+String.valueOf(a+1));
		}
		in.close();
	}
}


import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n=in.nextInt();
		int[]p=new int[n],g=new int[n];
		for (int i=1;i<n*(n-1)/2;i++) {
			int x=in.nextInt()-1,y=in.nextInt()-1;
			p[x]++;
			g[x]++;g[y]++;
		}
		int a=-1,b=-1;
		for (int i=0;i<n;i++) {
			if (g[i]!=n-1) {
				if (a==-1) {
					a=i;
				} else {
					b=i;
					break;
				}
			}
		}
		if (p[a]>p[b]) {
			System.out.println(String.valueOf(a+1)+" "+String.valueOf(b+1));
		} else {
			System.out.println(String.valueOf(b+1)+" "+String.valueOf(a+1));
		}
		in.close();
	}
}


import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Tournament implements Closeable {

    private InputReader in = new InputReader(System.in);
    private PrintWriter out = new PrintWriter(System.out);

    public void solve() {
        int n = in.ni(), max = (n * (n - 1)) / 2;
        int[] inDegree = new int[n + 1];
        int[] outDegree = new int[n + 1];
        for (int i = 0; i < max - 1; i++) {
            int u = in.ni(), v = in.ni();
            outDegree[u]++;
            inDegree[v]++;
        }
        int[] result = new int[2];
        int idx = 0;
        for (int i = 1; i <= n; i++) {
            if (inDegree[i] + outDegree[i] < n - 1) {
                result[idx++] = i;
            }
        }
        if (inDegree[result[0]] <= inDegree[result[1]]) {
            out.println(result[0] + " " + result[1]);
        } else {
            out.println(result[1] + " " + result[0]);
        }
    }

    @Override
    public void close() throws IOException {
        in.close();
        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int ni() {
            return Integer.parseInt(next());
        }

        public long nl() {
            return Long.parseLong(next());
        }

        public void close() throws IOException {
            reader.close();
        }
    }

    public static void main(String[] args) throws IOException {
        try (Tournament instance = new Tournament()) {
            instance.solve();
        }
    }
}


//package codeforces;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Random;
import java.util.Set;
import java.util.StringTokenizer;

public class A implements Closeable {
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    PrintWriter writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

    A() throws IOException {
//        reader = new BufferedReader(new FileReader("input.txt"));
//        writer = new PrintWriter(new FileWriter("output.txt"));
    }

    StringTokenizer stringTokenizer;

    String next() throws IOException {
        while (stringTokenizer == null || !stringTokenizer.hasMoreTokens()) {
            stringTokenizer = new StringTokenizer(reader.readLine());
        }
        return stringTokenizer.nextToken();
    }

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

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

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

    private int MOD = 1000 * 1000 * 1000 + 7;

    int sum(int a, int b) {
        a += b;
        return a >= MOD ? a - MOD : a;
    }

    int product(int a, int b) {
        return (int) (1l * a * b % MOD);
    }

    int pow(int x, int k) {
        int result = 1;
        while (k > 0) {
            if (k % 2 == 1) {
                result = product(result, x);
            }
            x = product(x, x);
            k /= 2;
        }
        return result;
    }

    int inv(int x) {
        return pow(x, MOD - 2);
    }

    void solve() throws IOException {
        int n = nextInt();
        int[][] g = new int[n + 1][n + 1];
        for(int i = 1; i < n * (n - 1) / 2; i++) {
            int u = nextInt(), v = nextInt();
            g[u][v] = 1;
            g[v][u] = -1;
        }
        for(int u = 1; u <= n; u++) {
            for(int v = u + 1; v <= n; v++) {
                if(g[u][v] == 0) {
                    for(int k = 1; k <= n; k++) {
                        if(k !=u && k != v && g[k][u] != g[k][v]) {
                            if(g[k][u] == 1) {
                                writer.println(v + " " + u);
                            } else {
                                writer.println(u + " " + v);
                            }
                            return;
                        }
                    }
                    writer.println(u + " " + v);
                    return;
                }
            }
        }
    }

    public static void main(String[] args) throws IOException {
        try (A a = new A()) {
            a.solve();
        }
    }

    @Override
    public void close() throws IOException {
        reader.close();
        writer.close();
    }
}


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

public class Main27B
{
  static PrintWriter out=new PrintWriter(System.out);
  static Vector<Integer>[] graph;
  static boolean isCycle=false;
  static boolean marked[];
  static boolean onStack[];

  static boolean cycle()
  {
    marked=new boolean[graph.length];
    onStack=new boolean[graph.length];

    for(int i=0;i<graph.length;i++)
    {
      if(!marked[i]&&!isCycle)
        dfs(i);
    }
    if(isCycle)
      return true;
    return false;
  }
  static void dfs(int v)
  {
    marked[v]=true;
    onStack[v]=true;
    for(int w:graph[v])
    {
      if(!marked[w])
      {
        dfs(w);
      }
      else if(onStack[w])
      {
        isCycle=true;
        break;
      }
    }
    onStack[v]=false;
  }

  public static void main(String[] args) throws IOException
  {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    graph=(Vector<Integer>[]) new Vector[n];
    int[] a=new int[n];

    for(int i=0;i<n;i++)
      graph[i]=new Vector<Integer>();
    for(int i=0;i<(n*(n-1))/2-1;i++)
    {
      int x=sc.nextInt();
      int y=sc.nextInt();
      x-=1;
      y-=1;
      graph[x].add(y);
      a[x]++;
      a[y]++;
    }
    int[] v=new int[2];
    int k=0;
    for(int i=0;i<n;i++)
    {
      if(a[i]==n-2)
        v[k++]=i;
    }
    //out.println(cycle());
    graph[v[0]].add(v[1]);
    if(!cycle())
      out.println((v[0]+1)+" "+(v[1]+1));
    else
      out.println((v[1]+1)+" "+(v[0]+1));
    out.flush();

  }
  static class Scanner
  {
    BufferedReader br;
    StringTokenizer tk=new StringTokenizer("");
    public Scanner(InputStream is)
        {
      br=new BufferedReader(new InputStreamReader(is));
    }
        public int nextInt() throws IOException
        {
          if(tk.hasMoreTokens())
                return Integer.parseInt(tk.nextToken());
          tk=new StringTokenizer(br.readLine());
          return nextInt();
        }
        public long nextLong() throws IOException
        {
            if(tk.hasMoreTokens())
              return Long.parseLong(tk.nextToken());
            tk=new StringTokenizer(br.readLine());
            return nextLong();
        }
        public String next() throws IOException
        {
          if(tk.hasMoreTokens())
            return (tk.nextToken());
            tk=new StringTokenizer(br.readLine());
            return next();
        }
        public String nextLine() throws IOException
        {
          tk=new StringTokenizer("");
          return br.readLine();
        }
        public double nextDouble() throws IOException
        {
            if(tk.hasMoreTokens())
              return Double.parseDouble(tk.nextToken());
            tk=new StringTokenizer(br.readLine());
            return nextDouble();
        }
        public char nextChar() throws IOException
        {
            if(tk.hasMoreTokens())
              return (tk.nextToken().charAt(0));
            tk=new StringTokenizer(br.readLine());
            return nextChar();
        }
        public int[] nextIntArray(int n) throws IOException
        {
            int a[]=new int[n];
            for(int i=0;i<n;i++)
              a[i]=nextInt();
            return a;
        }
        public long[] nextLongArray(int n) throws IOException
        {
          long a[]=new long[n];
            for(int i=0;i<n;i++)
              a[i]=nextLong();
            return a;
        }
        public int[] nextIntArrayOneBased(int n) throws IOException
        {
          int a[]=new int[n+1];
            for(int i=1;i<=n;i++)
              a[i]=nextInt();
            return a;
        }
        public long[] nextLongArrayOneBased(int n) throws IOException
        {
          long a[]=new long[n+1];
          for(int i=1;i<=n;i++)
                a[i]=nextLong();
          return a;
        }
  }
}


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

public class Main27B
{
  static PrintWriter out=new PrintWriter(System.out);
  static Vector<Integer>[] graph;
  static boolean isCycle=false;
  static boolean marked[];

  static boolean cycle()
  {
    marked=new boolean[graph.length];
    for(int i=0;i<graph.length;i++)
      dfs(i,-1);
    if(isCycle)
      return true;
    return false;
  }
  static void dfs(int v,int u)
  {
    marked[v]=true;
    for(int w:graph[v])
    {
      if(!marked[w])
      {
        dfs(w,v);
      }
      else
      {
        isCycle=true;
        break;
      }
    }
  }

  public static void main(String[] args) throws IOException
  {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    graph=(Vector<Integer>[]) new Vector[n];
    int[] a=new int[n];

    for(int i=0;i<n;i++)
      graph[i]=new Vector<Integer>();
    for(int i=0;i<(n*(n-1))/2-1;i++)
    {
      int x=sc.nextInt();
      int y=sc.nextInt();
      x-=1;
      y-=1;
      graph[x].add(y);
      a[x]++;
      a[y]++;
    }
    int[] v=new int[2];
    int k=0;
    for(int i=0;i<n;i++)
    {
      if(a[i]==n-2)
        v[k++]=i;
    }
    graph[v[0]].add(v[1]);
    if(!cycle())
      out.println((v[0]+1)+" "+(v[1]+1));
    else
      out.println((v[1]+1)+" "+(v[0]+1));
    out.flush();

  }
  static class Scanner
  {
    BufferedReader br;
    StringTokenizer tk=new StringTokenizer("");
    public Scanner(InputStream is)
        {
      br=new BufferedReader(new InputStreamReader(is));
    }
        public int nextInt() throws IOException
        {
          if(tk.hasMoreTokens())
                return Integer.parseInt(tk.nextToken());
          tk=new StringTokenizer(br.readLine());
          return nextInt();
        }
        public long nextLong() throws IOException
        {
            if(tk.hasMoreTokens())
              return Long.parseLong(tk.nextToken());
            tk=new StringTokenizer(br.readLine());
            return nextLong();
        }
        public String next() throws IOException
        {
          if(tk.hasMoreTokens())
            return (tk.nextToken());
            tk=new StringTokenizer(br.readLine());
            return next();
        }
        public String nextLine() throws IOException
        {
          tk=new StringTokenizer("");
          return br.readLine();
        }
        public double nextDouble() throws IOException
        {
            if(tk.hasMoreTokens())
              return Double.parseDouble(tk.nextToken());
            tk=new StringTokenizer(br.readLine());
            return nextDouble();
        }
        public char nextChar() throws IOException
        {
            if(tk.hasMoreTokens())
              return (tk.nextToken().charAt(0));
            tk=new StringTokenizer(br.readLine());
            return nextChar();
        }
        public int[] nextIntArray(int n) throws IOException
        {
            int a[]=new int[n];
            for(int i=0;i<n;i++)
              a[i]=nextInt();
            return a;
        }
        public long[] nextLongArray(int n) throws IOException
        {
          long a[]=new long[n];
            for(int i=0;i<n;i++)
              a[i]=nextLong();
            return a;
        }
        public int[] nextIntArrayOneBased(int n) throws IOException
        {
          int a[]=new int[n+1];
            for(int i=1;i<=n;i++)
              a[i]=nextInt();
            return a;
        }
        public long[] nextLongArrayOneBased(int n) throws IOException
        {
          long a[]=new long[n+1];
          for(int i=1;i<=n;i++)
                a[i]=nextLong();
          return a;
        }
  }
}


import java.io.BufferedWriter;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.ObjectInputStream.GetField;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Random;
import java.util.Scanner;
import java.util.Stack;
import java.util.TreeMap;
import java.util.TreeSet;

		public 	class Q2 {

				static long MOD = 1000000009;
				static boolean b1,b[],bc[];
				static boolean boo[][][];
				static int ans1 = -1,ans2 = -1, root;
				static ArrayList<Integer>[] amp,amp1;
				static ArrayList<Pair>[] pmp;
				static int sum[],dist[],cnt[],ans[],size[],col[][];
				static int p = 0,cnt1 =0 ,cnt2 = 0;
				//static ArrayList<Pair3>[][][] pmp;
				static FasterScanner sc = new FasterScanner(System.in);
				static Queue<Integer> q = new LinkedList<>();
				static int arr[],start[],end[],color[],parent[];
				static PriorityQueue<Integer> pq;
				//static ArrayList<Integer> parent = new ArrayList<>();
				static LinkedList<Integer> fa;
				static BufferedWriter log;
				static TreeMap<Integer,Integer> tm = new TreeMap<>();
			//	static HashMap<Integer,Pair> hs;
				static Stack<Integer> stack = new Stack<>();
				static Pair prr[];
				static int dp[][];
				static long parent1[],parent2[],size1[],size2[],value[];
				static long Ans;
				public static void main(String[] args) throws Exception {
					/*new Thread(null, new Runnable() {
						public void run() {
							try {
								soln();
							} catch (Exception e) {
								System.out.println(e);
							}
						}
					}, "1", 1 << 26).start();*/
					soln();
			    }
				static int MAX = 1000005;
				static int n , m ,k, max, x1, x2;
				static HashSet<Pair> hs;
				public static void soln() throws IOException {
					//FasterScanner in = new FasterScanner(new FileInputStream("C:\\Users\\Admin\\Desktop\\QAL.txt"));
					//PrintWriter out = new PrintWriter("C:\\Users\\Admin\\Desktop\\A1.txt");
					log = new BufferedWriter(new OutputStreamWriter(System.out));
					int n = sc.nextInt();
					int temp = 0;
					hs = new HashSet<>();
					int arr[] = new int[n+1];
					amp = (ArrayList<Integer>[]) new ArrayList[n+1];
					for(int i = 0; i<=n;i++) amp[i] = new ArrayList<>();
					buildGraph((n*(n-1))/2-1);
					b = new boolean[n+1];
					for(int i = 1;i<=n;i++){
						for(int j = i+1;j<=n;j++){
							if(!hs.contains(new Pair(i,j))){
								dfs(i);
								if(b[j]){
									System.out.println(i+" "+j);
									return;
								}
								else{
									System.out.println(j+" "+i);return;
								}
							}
						}
					}
					log.close();
					//out.close();
				}
				public static class FenwickTree {
				    int[] array; // 1-indexed array, In this array We save cumulative information to perform efficient range queries and updates
				    public FenwickTree(int size) {
				        array = new int[size + 1];
				    }
				    public int rsq(int ind) {
				        assert ind > 0;
				        int sum = 0;
				        while (ind > 0) {
				            sum += array[ind];ind -= ind & (-ind);
				        }
				        return sum;
				    }
				    public int rsq(int a, int b) {
				        assert b >= a && a > 0 && b > 0;
				        return rsq(b) - rsq(a - 1);
				    }
				    public void update(int ind, int value) {
				        assert ind > 0;
				        while (ind < array.length) {
				            array[ind] += value; ind += ind & (-ind);
				        }
				    }
				    public int size() {
				        return array.length - 1;
				    }
				}
				public static void dfs(int x){
					b[x] = true;
					for(int e:amp[x]){
						if(!b[e]){
							dfs(e);
						}
					}
				}
				public static void bfs(int x){
					b[x] = true;
					q = new LinkedList<Integer>();
					q.add(x);
					while(!q.isEmpty()){
						//System.out.println(q);
						int y = q.poll();
							for(int i:amp[y]){
							if(!b[i]){
								q.add(i);
								dist[i] = Math.max(dist[i], dist[y]+1);
								if(dist[i]>max){
									max = dist[i];
									k = i;
								}
								b[i]= true;
							}
						}
					}
				}
				static class Pair implements Comparable<Pair> {
					int u;
					int v;
					public Pair(){
						u = 0;
						v = 0;
					}
					public Pair(int u, int v) {
						this.u = u;
						this.v = v;
					}
					public int hashCode() {
						int hu = (int) (u ^ (u >>> 32));
						int hv = (int) (v ^ (v >>> 32));
						return 31*hu + hv;
					}

					public boolean equals(Object o) {
						Pair other = (Pair) o;
						return (u == other.u && v == other.v);
					}

					public int compareTo(Pair other) {
						return Long.compare(u, other.u) != 0 ? (Long.compare(u, other.u)) : (Long.compare(v, other.v));
					}

					public String toString() {
						return "[u=" + u + ", v=" + v + "]";
					}
				}

				public static int gcd(int n, int m){
					if(m!=0) return gcd(m,n%m);
					else return n;
				}

				static int CeilIndex(int A[], int l, int r, int key)
			    {
			        while (r - l > 1)
			        {
			            int m = l + (r - l)/2;
			            if (A[m]>=key)
			                r = m;
			            else
			                l = m;
			        }

			        return r;
			    }
			/*	public static Pair recur(int N, int K, int C){
					if(K>k) return new Pair(Long.MAX_VALUE/2,-1);
					if(N>=n && k<K) return new Pair(Long.MAX_VALUE/2,-1);
					if(N>=n && k==K) return new Pair(0,k);
					if(N>=n) return new Pair(0,0);
					if(dp[N][C][K]!=null){
						//System.out.println(dp[N][C][K]);
						return dp[N][C][K];
					}
					Pair ans = new Pair(Long.MAX_VALUE/2,-1);
					if(arr[N]>0){
						Pair p;
						if(arr[N]==C) p = recur(N+1,K,arr[N]);
						else p = recur(N+1,K+1,arr[N]);
						if((p.u)<ans.u){
							ans = p;
						}
						if(p.u==ans.u){
							if(p.v>ans.v){
								ans = p;
							}
						}
					}
					else{
					for(int i = 1 ;i <= m; i++){
						Pair p;
						if(i==C)
						p = recur(N+1,K,i);
						else p = recur(N+1,K+1,i);
						p.u+=col[N][i-1];
						if((p.u)<ans.u){
							ans = p;
						}
						if(p.u==ans.u){
							if(p.v>ans.v){
								ans = p;
							}
						}
					}
					//System.out.println(ans);
					}
					return dp[N][C][K] = ans;
				}*/
				public static void mergeSort(int[] arr2, int l ,int r){
					if((r-l)>=1){
						int mid = (l+r)/2;
						mergeSort(arr2,l,mid);
						mergeSort(arr2,mid+1,r);
						merge(arr2,l,r,mid);
						//System.out.println(Ans);
					}
				}
				public static void merge(int arr[], int l, int r, int mid){
					int n1 = (mid-l+1), n2 = (r-mid);
					int left[] = new int[n1];
					int right[] = new int[n2];
					for(int i =0 ;i<n1;i++) left[i] = arr[l+i];
					for(int i =0 ;i<n2;i++) right[i] = arr[mid+1+i];
					int i =0, j =0, k = l;
					while(i<n1 && j<n2){
						if(left[i]>right[j]){
							cnt[right[j]]+=(n1-i);
							arr[k++] = right[j++];
						}
						else{
							arr[k++] = left[i++];
						}
					}
					while(i<n1) arr[k++] = left[i++];
					while(j<n2) arr[k++] = right[j++];
				}
				public static void buildGraph(int n){
					for(int i =0;i<n;i++){
						int x = sc.nextInt(), y = sc.nextInt();
						amp[x].add(y);
						hs.add(new Pair(x,y));
						hs.add(new Pair(y,x));
					}
				}

				public static int getParent(int x){
					while(parent[x]!=x){
						parent[x] = parent[ parent[x]];
						x = parent[ x];
					}
					return x;
				}

				static int min(int a, int b, int c){
					if(a<b && a<c) return a;
					if(b<c) return b;
					return c;
				}
				private static void permutation(String prefix, String str) {
				    int n = str.length();
				    if (n == 0); //hs.add(prefix);
				    else {
				        for (int i = 0; i < n; i++)
				            permutation(prefix + str.charAt(i), str.substring(0, i) + str.substring(i+1, n));
				    }
				}
				static class Graph{
					int vertex;
					long weight;
				}
				public static void buildTree(int n){
					int arr[] = sc.nextIntArray(n);
					for(int i = 0;i<n;i++){
						int x = arr[i]-1;
						amp[i+1].add(x);
						amp[x].add(i+1);
					}
				}/*
				static class SegmentTree {
					Pair st[];
				//	long lazy[];
					SegmentTree(int n) {
						int size = 8 * n;
						st = new Pair[size];
						for(int i = 0; i< size;i++) st[i] = new Pair();
					//	lazy = new long[size];
						build(0, n - 1, 1);
					}
					Pair build(int ss, int se, int si) {
						if (ss == se) {
							st[si] = new Pair();
							if(arr[ss]==0){
								st[si].u = 1;
							}
							st[si].v = (se-ss+1)-st[si].u;
							st[si].z = 0;
							return st[si];
						}
						int mid = (ss + se) / 2;
						Pair temp1 = build(ss, mid, 2*si), temp2 = build(mid+1, se, si*2+1);
						long a1 = temp1.u+temp2.u, a2 = temp1.v+temp2.v, a3 = temp1.z+temp2.z+temp1.u*temp2.u+temp1.v*temp2.v;
						return st[si] = new Pair(a1,a2,a3);
					}

					void update(int si, int ss, int se, int idx, int val) {
						if (ss == se) {
							st[si] = new Pair();
							arr[idx] = val;
							if(arr[idx]==0){
								st[si].u = 1;
							}
							st[si].v = (se-ss+1)-st[si].u;
							st[si].z = 0;
						}
						else {
							int mid = (ss + se) / 2;
							if(ss <= idx && idx <= mid)
					        {
					             update(2*si, ss, mid, idx, val);
					        }
					        else
					        { update(2*si+1, mid+1, se, idx, val);
					        }
							long a1 = st[si*2].u+st[si*2+1].u, a2 = st[si*2].v+st[si*2+1].v, a3 = st[si*2].z+st[si*2+1].z+st[si*2+1].u*st[si*2].u+st[si*2+1].v*st[si*2].v;
							st[si] = new Pair(a1,a2,a3);
						}
					}
					Pair get(int qs, int qe, int ss, int se, int si){
						if(qs>se || qe<ss){
							return new Pair(0,0,0);
						}
						if (qs <= ss && qe >= se) {
							return st[si];
						}
						int mid = (ss+se)/2;
						Pair temp1 = get(qs, qe, ss, mid, si * 2), temp2 = get(qs, qe, mid + 1, se, si * 2 + 1);
						long a1 = temp1.u+temp2.u, a2 = temp1.v+temp2.v, a3 = temp1.z+temp2.z+temp1.u*temp2.u+temp1.v*temp2.v;
						st[si] = new Pair(a1,a2,a3);
						return st[si];
					}
					/*void updateRange(int node, int start, int end, int l, int r, long val)
					{
					    if(lazy[node] != 0)
					    {
					        // This node needs to be updated
					        st[node] += (end - start + 1) * lazy[node];    // Update it
					        if(start != end)
					        {
					            lazy[node*2] += lazy[node];                  // Mark child as lazy
					            lazy[node*2+1] += lazy[node];                // Mark child as lazy
					        }
					        lazy[node] = 0;                                  // Reset it
					    }
					    if(start > end || start > r || end < l)              // Current segment is not within range [l, r]
					        return;
					    if(start >= l && end <= r)
					    {
					        // Segment is fully within range
					        st[node] += (end - start + 1) * val;
					        if(start != end)
					        {
					            // Not leaf node
					            lazy[node*2] += val;
					            lazy[node*2+1] += val;
					        }
					        return;
					    }
					    int mid = (start + end) / 2;
					    updateRange(node*2, start, mid, l, r, val);        // Updating left child
					    updateRange(node*2 + 1, mid + 1, end, l, r, val);   // Updating right child
					    st[node] = st[node*2] + st[node*2+1];        // Updating root with max value
					}

					long queryRange(int node, int start, int end, int l, int r)
					{
					    if(start > end || start > r || end < l)
					        return 0L;         // Out of range
					    if(lazy[node] != 0)
					    {
					        // This node needs to be updated
					        st[node] += (end - start + 1) * lazy[node];            // Update it
					        if(start != end)
					        {
					            lazy[node*2] += lazy[node];         // Mark child as lazy
					            lazy[node*2+1] += lazy[node];    // Mark child as lazy
					        }
					        lazy[node] = 0L;                 // Reset it
					    }
					    if(start >= l && end <= r)             // Current segment is totally within range [l, r]
					        return  st[node];
					    int mid = (start + end) / 2;
					    long p1 = queryRange(node*2, start, mid, l, r);         // Query left child
					    long p2 = queryRange(node*2 + 1, mid + 1, end, l, r); // Query right child
					    return (p1 + p2);
					}
					void print() {
						for (int i = 0; i < st.length; i++) {
							System.out.print(st[i].u+" "+st[i].v+" "+st[i].z+"\n");
						}
						System.out.println();
					}
				}*/
				static class Tree {
					ArrayList<Integer>[] g ;
					int T[]; // parent
					int L[]; // level
					int P[][]; // P[i][j] = 2^j th parent of i

					public Tree(int n) {
						T = new int[n];
						L = new int[n];
						P = new int[n][log2(n) + 1];
						g = (ArrayList<Integer>[])new ArrayList[n];
						L[0] = 0;
						T[0] = -1;
						for (int i = 0; i < n; i++) {
							g[i] = new ArrayList<>();
						}
						for (int i = 0; i < n ; i++) {
							int a = sc.nextInt();
							for(int j = 0; j<a; j++){
								int b = sc.nextInt()-1;
								g[i].add(b);
								g[b].add(i);
							}
						}
						dfs(0, -1);
						for (int j = 0; (1 << j) <= n; j++)
							pre(0, j,-1);
					}

					public int log2(int n) {
						return (int) (Math.log10(n) / Math.log10(2));
					}

					public void dfs(int node, int p) {
						for (int k : g[node]) {
							if (k != p) {
								T[k] = node;
								L[k] = L[node] + 1;
								dfs(k, node);
							}
						}
					}
					public void pre(int node, int j,int p) {
						if (j == 0) {
							P[node][j] = T[node];
						} else {
							P[node][j] = P[P[node][j - 1]][j - 1];
						}
						for (int k : g[node]) {
							if(k!=p)
								pre(k, j,node);
						}
					}
					public int lca(int u, int v) {
						if (L[u] > L[v]) {
							int temp = u;
							u = v;
							v = temp;
						}
						int log;
						for (log = 0; (1 << log) <= L[v]; log++)
							; // convert level into log
						log--;

						for (int i = log; i >= 0; i--) {
							if ((1 << i) <= L[v] - L[u]) // make both node's level same
								v = P[v][i];
						}
						if (u == v)
							return u;
						for (int i = log; i >= 0; i--) {
							if (P[u][i] != -1 && P[u][i] != P[v][i]) // shift up both u and v
							{
								u = P[u][i];
								v = P[v][i];
							}
						}
						return T[u];
					}
				}
				public static long max(long x, long y, long z){
					if(x>=y && x>=z) return x;
					if(y>=x && y>=z) return y;
					return z;
				}

				public static void seive(long n){
					b = new boolean[(int) (n+1)];
					Arrays.fill(b, true);
					for(int i = 2;i*i<=n;i++){
						if(b[i]){
							for(int p = 2*i;p<=n;p+=i){
								b[p] = false;
							}
						}
					}
				}
				static long modInverse(long a, long mOD2){
				            return  power(a, mOD2-2, mOD2);
				}
				static long power(long x, long y, long m)
				{
				    if (y == 0)
				        return 1;
				    long p = power(x, y/2, m) % m;
				    p = (p * p) % m;

				    return (y%2 == 0)? p : (x * p) % m;
				}
				static long d,x,y;
				public static void extendedEuclidian(long a, long b){
					if(b == 0) {
				        d = a;
				        x = 1;
				        y = 0;
				    }
				    else {
				        extendedEuclidian(b, a%b);
				        int temp = (int) x;
				        x = y;
				        y = temp - (a/b)*y;
				    }
				}

				static class FasterScanner {

					private final InputStream stream;
					private final byte[] buf = new byte[8192];
					private int curChar, snumChars;
					private SpaceCharFilter filter;
					public int read() {
						if (snumChars == -1)
							throw new InputMismatchException();
						if (curChar >= snumChars) {
							curChar = 0;
							try {
								snumChars = System.in.read(buf);
							} catch (IOException e) {
								throw new InputMismatchException();
							}
							if (snumChars <= 0)
								return -1;
						}
						return buf[curChar++];
					}
					public FasterScanner(InputStream stream) {
						this.stream = stream;
					}
					public String nextString() {
						int c = read();
						while (isSpaceChar(c))
							c = read();
						StringBuilder res = new StringBuilder();
						do {
							res.appendCodePoint(c);
							c = read();
						} while (!isSpaceChar(c));
						return res.toString();
					}
					public int snext() {
						if (snumChars == -1)
							throw new InputMismatchException();
						if (curChar >= snumChars) {
							curChar = 0;
							try {
								snumChars = stream.read(buf);
							} catch (IOException e) {
								throw new InputMismatchException();
							}
							if (snumChars <= 0)
								return -1;
						}
						return buf[curChar++];
					}

					public int nextInt() {
						int c = snext();
						while (isSpaceChar(c)) {
							c = snext();
						}
						int sgn = 1;
						if (c == '-') {
							sgn = -1;
							c = snext();
						}
						int res = 0;
						do {
							if (c < '0' || c > '9')
								throw new InputMismatchException();
							res *= 10;
							res += c - '0';
							c = snext();
						} while (!isSpaceChar(c));
						return res * sgn;
					}

					public long nextLong() {
						int c = snext();
						while (isSpaceChar(c)) {
							c = snext();
						}
						int sgn = 1;
						if (c == '-') {
							sgn = -1;
							c = snext();
						}
						long res = 0;
						do {
							if (c < '0' || c > '9')
								throw new InputMismatchException();
							res *= 10;
							res += c - '0';
							c = snext();
						} while (!isSpaceChar(c));
						return res * sgn;
					}

					public int[] nextIntArray(int n) {
						int a[] = new int[n];
						for (int i = 0; i < n; i++) {
							a[i] = nextInt();
						}
						return a;
					}

					public long[] nextLongArray(int n) {
						long a[] = new long[n];
						for (int i = 0; i < n; i++) {
							a[i] = nextInt();
						}
						return a;
					}

					public String readString() {
						int c = snext();
						while (isSpaceChar(c)) {
							c = snext();
						}
						StringBuilder res = new StringBuilder();
						do {
							res.appendCodePoint(c);
							c = snext();
						} while (!isSpaceChar(c));
						return res.toString();
					}

					public String nextLine() {
						int c = snext();
						while (isSpaceChar(c))
							c = snext();
						StringBuilder res = new StringBuilder();
						do {
							res.appendCodePoint(c);
							c = snext();
						} while (!isEndOfLine(c));
						return res.toString();
					}

					public boolean isSpaceChar(int c) {
						if (filter != null)
							return filter.isSpaceChar(c);
						return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
					}

					private boolean isEndOfLine(int c) {
						return c == '\n' || c == '\r' || c == -1;
					}

					public interface SpaceCharFilter {
						public boolean isSpaceChar(int ch);
					}
				}
			}