class A:
    def __init__(self, txt: str):
        self.u: 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.v: B = None
        self.q: B = None
        self.txt = txt

a = A("a")
f = B("f")
l = C("l")
e = A("e")
j = B("j")
d = B("d")
k = B("k")
c = B("c")

a.u = j
f.r = d
l.v = f
l.q = c
e.u = d
j.r = d
d.r = f
k.r = d
c.r = d
assert k.r.r.r.r.r.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.u: 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.v: B = None
        self.q: B = None
        self.txt = txt

a = A("a")
f = B("f")
l = C("l")
e = A("e")
j = B("j")
d = B("d")
k = B("k")
c = B("c")

a.u = j
f.r = d
l.v = f
l.q = c
e.u = d
j.r = d
d.r = f
k.r = d
c.r = d
assert k.r.r.r.r.r.r.r.r.txt == "f"