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

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

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

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

i = A("i")
f = B("f")
l = C("l")
j = D("j")
a = C("a")

i.x = j
f.o = a
l.z = j
l.x = j
j.w = i
a.z = j
a.x = j
assert f.o.z.w.txt == "
class A:
    def __init__(self, txt: str):
        self.x: D = None
        self.txt = txt

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

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

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

i = A("i")
f = B("f")
l = C("l")
j = D("j")
a = C("a")

i.x = j
f.o = a
l.z = j
l.x = j
j.w = i
a.z = j
a.x = j
assert f.o.z.w.txt == "i"