class A:
    def __init__(self, txt: str):
        self.v: D = None
        self.txt = txt

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

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

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

f = A("f")
d = B("d")
e = C("e")
c = D("c")
k = C("k")

f.v = c
d.v = c
e.u = k
c.z = k
k.u = e
assert f.v.z.u.txt == "
class A:
    def __init__(self, txt: str):
        self.v: D = None
        self.txt = txt

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

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

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

f = A("f")
d = B("d")
e = C("e")
c = D("c")
k = C("k")

f.v = c
d.v = c
e.u = k
c.z = k
k.u = e
assert f.v.z.u.txt == "e"