
/*

Перепись

*/



import java.util.Scanner;

public class first {

    public static void main(String[] args) {

      int n, v, v1, s, s1, j;

      Scanner sc = new Scanner(System.in);
      n = sc.nextInt();
      v = sc.nextInt();
      s = sc.nextInt();
      int i = 2;
      j = -1;
      if(s == 1) { j = 1; }

      while (i <= n){
        v1 = sc.nextInt();
        s1 = sc.nextInt();
        if((s1 == 1) && (v1 > v)){ j = i; }
        i++;
        v = v1;
        s = s1;
      }

      System.out.println(j);

    }
}




