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

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

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

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

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

m = A("m")
f = B("f")
h = C("h")
a = D("a")
c = E("c")
d = C("d")

m.u = h
m.z = f
f.r = a
h.v = c
a.z = h
a.o = f
c.w = h
d.v = c
assert a.o.r.z.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.z: B = None
        self.txt = txt

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

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

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

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

m = A("m")
f = B("f")
h = C("h")
a = D("a")
c = E("c")
d = C("d")

m.u = h
m.z = f
f.r = a
h.v = c
a.z = h
a.o = f
c.w = h
d.v = c
assert a.o.r.z.txt == "h"