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

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

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

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

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

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

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

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

l.o = m
l.t = b
k.s = m
k.w = m
k.u = m
m.q = k
b.o = m
b.t = l
assert l.o.q.s.q.txt == "k"