while gets
    board = $_.chomp.scan(/./)
    def board.judge ( x, y, z )
        (r=self.values_at(x,y,z).uniq).size==1 ? r[0] : nil
    end
    puts (r=[[0,1,2],[3,4,5],[6,7,8],[0,3,6],[1,4,7],[2,5,8],[0,4,8],[2,4,6]].map{|x| board.judge(x[0],x[1],x[2])}.reject{|x|x==nil}.uniq[0])==nil ? 'd':r
end