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

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

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

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

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

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

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

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

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

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

k.s = b
a.o = b
a.v = c
a.t = k
b.r = a
b.q = a
b.z = k
c.o = a
c.r = k
assert k.s.q.t.s.txt == "b"