class A:
    def __init__(self, txt: str):
        self.x: D = None
        self.t: B = None
        self.txt = txt

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

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

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

i = A("i")
k = B("k")
f = C("f")
b = D("b")

i.x = b
i.t = k
k.w = i
k.z = i
f.y = i
f.r = b
f.z = k
b.x = f
b.t = k
assert b.x.r.t.z.txt == "
class A:
    def __init__(self, txt: str):
        self.x: D = None
        self.t: B = None
        self.txt = txt

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

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

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

i = A("i")
k = B("k")
f = C("f")
b = D("b")

i.x = b
i.t = k
k.w = i
k.z = i
f.y = i
f.r = b
f.z = k
b.x = f
b.t = k
assert b.x.r.t.z.txt == "i"