readlines.each do |l|
  a = l.chomp.scan(/.{3}/).map(&:chars)
  puts(%w(o x).find do |c|
    a.any?{|i| i.all?{|j| j==c}} ||
    a.transpose.any?{|i| i.all?{|j| j==c}} ||
    [a[0][0], a[1][1], a[2][2]].all?{|i| i==c} ||
    [a[2][0], a[1][1], a[0][2]].all?{|i| i==c}
  end || "d")
end