class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.t: B = None
        self.p: E = None
        self.z: B = None
        self.txt = txt

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

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

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

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

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

f.w = h
f.t = h
f.z = h
f.p = c
h.z = f
d.v = c
d.y = c
j.s = d
c.u = j
a.v = c
a.y = c
assert d.y.u.s.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.t: B = None
        self.p: E = None
        self.z: B = None
        self.txt = txt

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

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

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

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

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

f.w = h
f.t = h
f.z = h
f.p = c
h.z = f
d.v = c
d.y = c
j.s = d
c.u = j
a.v = c
a.y = c
assert d.y.u.s.txt == "d"