import java.io.* ; public class ttt { static int[] cross = new int[] { 1, 1, 4, 1, 7, 1, 3, 3, 4, 3, 5, 3, 4, 4, 4, 2 } ; public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)) ; while (true) { String s = br.readLine() ; if (s.startsWith("end")) return ; int exes = 0 ; int ohs = 0 ; for (int i=0; i<9; i++) if (s.charAt(i) == 'X') exes++ ; else if (s.charAt(i) == 'O') ohs++ ; boolean win[] = new boolean[128] ; for (int i=0; i