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

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

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

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

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

f.s = j
j.r = f
j.q = f
l.z = f
l.u = f
l.s = a
a.y = j
a.o = l
a.z = f
assert l.u.s.r.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

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

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

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

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

f.s = j
j.r = f
j.q = f
l.z = f
l.u = f
l.s = a
a.y = j
a.o = l
a.z = f
assert l.u.s.r.txt == "f"