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

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

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

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

l = A("l")
b = B("b")
h = C("h")
d = D("d")

l.w = d
l.o = b
l.s = h
b.y = h
h.s = d
d.z = l
d.v = l
assert d.v.s.s.z.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.o: B = None
        self.s: C = None
        self.txt = txt

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

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

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

l = A("l")
b = B("b")
h = C("h")
d = D("d")

l.w = d
l.o = b
l.s = h
b.y = h
h.s = d
d.z = l
d.v = l
assert d.v.s.s.z.txt == "l"