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

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

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

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

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

f.w = l
f.s = b
l.v = b
l.y = b
l.z = k
b.w = f
k.r = b
assert k.r.w.s.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.s: C = None
        self.txt = txt

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

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

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

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

f.w = l
f.s = b
l.v = b
l.y = b
l.z = k
b.w = f
k.r = b
assert k.r.w.s.txt == "b"