class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.v: D = None
        self.w: E = None
        self.z: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.y: A = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.t: A = None
        self.o: C = None
        self.u: C = None
        self.txt = txt

h = A("h")
g = B("g")
k = C("k")
f = D("f")
e = E("e")

h.o = g
h.z = g
h.v = f
h.w = e
g.y = h
k.w = h
k.z = h
f.z = k
f.y = g
f.r = e
e.t = h
e.o = k
e.u = k
assert f.r.u.z.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.v: D = None
        self.w: E = None
        self.z: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.y: A = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.t: A = None
        self.o: C = None
        self.u: C = None
        self.txt = txt

h = A("h")
g = B("g")
k = C("k")
f = D("f")
e = E("e")

h.o = g
h.z = g
h.v = f
h.w = e
g.y = h
k.w = h
k.z = h
f.z = k
f.y = g
f.r = e
e.t = h
e.o = k
e.u = k
assert f.r.u.z.txt == "h"