class A:
    def __init__(self, txt: str):
        self.q: E = None
        self.y: C = None
        self.u: A = None
        self.z: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.p: C = None
        self.w: E = 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.y: E = None
        self.z: B = None
        self.txt = txt

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

c = A("c")
b = B("b")
e = C("e")
h = D("h")
d = E("d")
m = C("m")
i = A("i")

c.q = d
c.y = e
c.u = i
c.z = m
b.p = e
b.w = d
e.p = h
h.y = d
h.z = b
d.o = h
m.p = h
i.q = d
i.y = m
i.z = m
i.u = c
assert e.p.y.o.y.o.z.w.txt == "
class A:
    def __init__(self, txt: str):
        self.q: E = None
        self.y: C = None
        self.u: A = None
        self.z: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.p: C = None
        self.w: E = 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.y: E = None
        self.z: B = None
        self.txt = txt

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

c = A("c")
b = B("b")
e = C("e")
h = D("h")
d = E("d")
m = C("m")
i = A("i")

c.q = d
c.y = e
c.u = i
c.z = m
b.p = e
b.w = d
e.p = h
h.y = d
h.z = b
d.o = h
m.p = h
i.q = d
i.y = m
i.z = m
i.u = c
assert e.p.y.o.y.o.z.w.txt == "d"