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

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

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

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

d = A("d")
j = B("j")
f = C("f")
i = D("i")
b = D("b")

d.u = i
j.p = f
f.y = d
f.z = d
f.s = d
f.w = b
i.t = j
i.s = b
i.z = f
b.t = j
b.s = i
b.z = f
assert b.z.z.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: D = None
        self.txt = txt

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

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

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

d = A("d")
j = B("j")
f = C("f")
i = D("i")
b = D("b")

d.u = i
j.p = f
f.y = d
f.z = d
f.s = d
f.w = b
i.t = j
i.s = b
i.z = f
b.t = j
b.s = i
b.z = f
assert b.z.z.u.txt == "i"