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

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

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

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

d = A("d")
c = B("c")
i = C("i")
f = D("f")

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

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

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

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

d = A("d")
c = B("c")
i = C("i")
f = D("f")

d.z = f
c.u = i
i.y = d
f.u = i
assert d.z.u.y.z.txt == "f"