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

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

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

b = A("b")
a = B("a")
n = C("n")
m = A("m")
g = A("g")
c = B("c")
j = C("j")
h = B("h")
e = A("e")
l = C("l")

b.r = e
a.t = h
a.z = l
n.q = j
m.r = g
g.r = e
c.t = h
c.z = j
j.q = n
h.t = c
h.z = l
e.r = b
l.q = n
assert e.r.r.r.r.r.r.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.txt = txt

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

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

b = A("b")
a = B("a")
n = C("n")
m = A("m")
g = A("g")
c = B("c")
j = C("j")
h = B("h")
e = A("e")
l = C("l")

b.r = e
a.t = h
a.z = l
n.q = j
m.r = g
g.r = e
c.t = h
c.z = j
j.q = n
h.t = c
h.z = l
e.r = b
l.q = n
assert e.r.r.r.r.r.r.r.r.r.txt == "b"