import java.util.*; class Pare implements Comparable{ int moto; int lcm; Pare(int moto,int lcm){ this.moto=moto; this.lcm=lcm; } @Override public int compareTo(Pare o) { int res = this.lcm-o.lcm; if(res==0) return this.moto-o.moto; return res; } } public class Main { static int gcd(int a,int b){ if(a>b){ int temp; temp=a; a=b; b=temp; } while(a != 0){ int temp=a; a = b%a; b=temp; } return b; } static int lcm(int a,int b){ return (a*b)/gcd(a,b); } public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); Pare[] a = new Pare[n]; for(int i=0;i