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

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

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

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

k = A("k")
m = B("m")
n = C("n")
b = D("b")

k.x = n
k.s = n
k.o = b
k.t = m
m.q = b
n.z = m
n.q = b
b.o = m
assert m.q.o.q.o.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.o: D = None
        self.s: C = None
        self.t: B = None
        self.txt = txt

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

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

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

k = A("k")
m = B("m")
n = C("n")
b = D("b")

k.x = n
k.s = n
k.o = b
k.t = m
m.q = b
n.z = m
n.q = b
b.o = m
assert m.q.o.q.o.txt == "m"