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

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

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

l = A("l")
f = B("f")
n = C("n")
b = A("b")
j = B("j")
g = A("g")
a = C("a")
e = A("e")

l.t = f
f.r = j
n.u = a
n.q = f
b.t = f
j.r = f
g.t = f
a.u = n
a.q = j
e.t = j
assert j.r.r.r.r.r.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

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

l = A("l")
f = B("f")
n = C("n")
b = A("b")
j = B("j")
g = A("g")
a = C("a")
e = A("e")

l.t = f
f.r = j
n.u = a
n.q = f
b.t = f
j.r = f
g.t = f
a.u = n
a.q = j
e.t = j
assert j.r.r.r.r.r.r.r.r.txt == "j"