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

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

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

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

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

a.r = f
l.z = b
l.u = f
l.p = a
b.y = l
b.w = l
b.u = l
b.o = a
f.s = l
assert f.s.p.r.s.txt == "
class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.txt = txt

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

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

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

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

a.r = f
l.z = b
l.u = f
l.p = a
b.y = l
b.w = l
b.u = l
b.o = a
f.s = l
assert f.s.p.r.s.txt == "l"