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

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

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

m = A("m")
k = B("k")
h = C("h")
b = C("b")

m.t = b
m.o = k
k.y = b
k.w = m
h.q = m
h.s = m
b.q = m
b.s = m
assert k.y.q.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.o: B = None
        self.txt = txt

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

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

m = A("m")
k = B("k")
h = C("h")
b = C("b")

m.t = b
m.o = k
k.y = b
k.w = m
h.q = m
h.s = m
b.q = m
b.s = m
assert k.y.q.t.txt == "b"