class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.u: D = None
        self.p: E = None
        self.z: E = None
        self.s: E = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.x: D = None
        self.r: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.p: D = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.o: E = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.s: C = None
        self.txt = txt

l = A("l")
c = B("c")
g = C("g")
h = D("h")
i = E("i")
d = E("d")

l.y = h
l.u = h
l.p = i
l.z = d
l.s = d
c.x = h
c.r = g
g.p = h
h.o = d
i.s = g
d.s = g
assert h.o.s.p.o.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.u: D = None
        self.p: E = None
        self.z: E = None
        self.s: E = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.x: D = None
        self.r: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.p: D = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.o: E = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.s: C = None
        self.txt = txt

l = A("l")
c = B("c")
g = C("g")
h = D("h")
i = E("i")
d = E("d")

l.y = h
l.u = h
l.p = i
l.z = d
l.s = d
c.x = h
c.r = g
g.p = h
h.o = d
i.s = g
d.s = g
assert h.o.s.p.o.txt == "d"