s = ['X.O', 'XX.', 'XOO']
str1 = s[0]
str2 = s[1]
str3 = s[2]
s1 = str1[0] + str2[0] + str3[0]
s2 = str1[1] + str2[1] + str3[1]
s3 = str1[2] + str2[2] + str3[2]
s4 = str1
s5 = str2
s6 = str3
s7 = str1[0] + str2[1] + str3[2]
s8 = str1[2] + str2[1] + str3[0]
if s1 == "XXX":
    otvet = "X"
    print(otvet)
    raise SystemExit
elif s1 == "OOO":
    otvet = "O"
    print(otvet)
    raise SystemExit
else:
    otvet = "D"
if s2 == "XXX":
    otvet = "X"
    print(otvet)
    raise SystemExit
elif s2 == "OOO":
    otvet = "O"
    print(otvet)
    raise SystemExit
else:
    otvet = "D"
if s3 == "XXX":
    otvet = "X"
    print(otvet)
    raise SystemExit
elif s3 == "OOO":
    otvet = "O"
    print(otvet)
    raise SystemExit
else:
    otvet = "D"
if s4 == "XXX":
    otvet = "X"
    print(otvet)
    raise SystemExit
elif s4 == "OOO":
    otvet = "O"
    print(otvet)
    raise SystemExit
else:
    otvet = "D"
if s5 == "XXX":
    otvet = "X"
    print(otvet)
    raise SystemExit
elif s5 == "OOO":
    otvet = "O"
    print(otvet)
    raise SystemExit
else:
    otvet = "D"
if s6 == "XXX":
    otvet = "X"
    print(otvet)
    raise SystemExit
elif s6 == "OOO":
    otvet = "O"
    print(otvet)
    raise SystemExit
else:
    otvet = "D"
if s7 == "XXX":
    otvet = "X"
    print(otvet)
    raise SystemExit
elif s7 == "OOO":
    otvet = "O"
    print(otvet)
    raise SystemExit
else:
    otvet = "D"
if s8 == "XXX":
    otvet = "X"
    print(otvet)
    raise SystemExit
elif s8 == "OOO":
    otvet = "O"
    print(otvet)
    raise SystemExit
else:
    otvet = "D"
print(otvet)

#s2 = str2[0:2]
#s3 = str3[0:2]
#print(s2)
#print(s3)

#s4
#s5
#s6
#s7
#s8