import java.util.*; class Main { static Scanner sc = new Scanner(System.in); public static void main(String[] args) { int n = sc.nextInt(); for (int i=1; i<=n; i++) { String s = sc.next(); String t = sc.next(); if (!s.equals(t) || n==1) { System.out.println(i); System.out.println(s); System.out.println(t); return; } } } }