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

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

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

e = A("e")
k = B("k")
b = C("b")
c = B("c")
m = B("m")

e.r = b
k.o = m
k.r = e
k.q = b
b.y = e
b.u = e
c.o = m
c.r = e
c.q = b
m.o = c
m.r = e
m.q = b
assert m.o.o.o.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.txt = txt

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

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

e = A("e")
k = B("k")
b = C("b")
c = B("c")
m = B("m")

e.r = b
k.o = m
k.r = e
k.q = b
b.y = e
b.u = e
c.o = m
c.r = e
c.q = b
m.o = c
m.r = e
m.q = b
assert m.o.o.o.r.r.txt == "b"