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

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

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

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

b.u = e
b.p = e
b.r = i
i.o = m
c.w = k
c.z = e
e.u = b
e.p = b
e.r = m
k.o = i
m.o = i
assert b.r.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.p: A = None
        self.r: B = None
        self.txt = txt

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

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

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

b.u = e
b.p = e
b.r = i
i.o = m
c.w = k
c.z = e
e.u = b
e.p = b
e.r = m
k.o = i
m.o = i
assert b.r.o.o.o.txt == "m"