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

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

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

m = A("m")
a = B("a")
f = C("f")
n = A("n")
b = C("b")
k = A("k")
c = B("c")

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

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

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

m = A("m")
a = B("a")
f = C("f")
n = A("n")
b = C("b")
k = A("k")
c = B("c")

m.o = b
m.x = f
m.q = f
a.u = c
f.r = a
n.o = b
n.x = f
n.q = f
b.r = c
k.o = b
k.x = b
k.q = b
c.u = a
assert n.o.r.u.u.u.u.u.txt == "a"