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

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

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

f = A("f")
a = B("a")
h = C("h")
m = B("m")
i = C("i")
b = A("b")

f.o = b
f.t = i
f.q = i
a.x = b
a.r = b
a.o = f
h.u = a
m.x = f
m.o = f
m.r = b
i.u = m
b.o = f
b.t = h
b.q = i
assert a.r.o.o.t.u.r.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.t: C = None
        self.q: C = None
        self.txt = txt

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

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

f = A("f")
a = B("a")
h = C("h")
m = B("m")
i = C("i")
b = A("b")

f.o = b
f.t = i
f.q = i
a.x = b
a.r = b
a.o = f
h.u = a
m.x = f
m.o = f
m.r = b
i.u = m
b.o = f
b.t = h
b.q = i
assert a.r.o.o.t.u.r.txt == "b"