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

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

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

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

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

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

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

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

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

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

k.s = f
k.u = f
k.r = b
f.z = k
f.r = a
b.v = a
a.v = b
a.q = b
assert a.v.v.q.v.txt == "a"