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

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

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

m = A("m")
i = B("i")
a = C("a")
f = A("f")
n = B("n")
k = C("k")
d = A("d")
e = A("e")
c = C("c")

m.q = c
m.u = d
i.r = c
a.y = n
f.q = a
f.u = e
n.r = a
k.y = n
d.q = a
d.u = e
e.q = a
e.u = f
c.y = n
assert n.r.y.r.y.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.u: A = None
        self.txt = txt

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

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

m = A("m")
i = B("i")
a = C("a")
f = A("f")
n = B("n")
k = C("k")
d = A("d")
e = A("e")
c = C("c")

m.q = c
m.u = d
i.r = c
a.y = n
f.q = a
f.u = e
n.r = a
k.y = n
d.q = a
d.u = e
e.q = a
e.u = f
c.y = n
assert n.r.y.r.y.txt == "n"