class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.t: C = 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.r: C = None
        self.txt = txt

n = A("n")
d = B("d")
f = C("f")
a = B("a")
g = A("g")
c = C("c")
k = A("k")

n.z = f
n.t = f
d.r = a
f.r = c
a.r = d
g.z = f
g.t = f
c.r = f
k.z = f
k.t = f
assert c.r.r.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.t: C = 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.r: C = None
        self.txt = txt

n = A("n")
d = B("d")
f = C("f")
a = B("a")
g = A("g")
c = C("c")
k = A("k")

n.z = f
n.t = f
d.r = a
f.r = c
a.r = d
g.z = f
g.t = f
c.r = f
k.z = f
k.t = f
assert c.r.r.r.r.r.txt == "f"