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

class B:
    def __init__(self, txt: str):
        self.p: A = None
        self.x: C = None
        self.txt = txt

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

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

k.z = l
k.p = d
d.p = f
d.x = e
e.t = l
f.z = e
f.p = d
a.z = l
a.p = d
l.t = e
assert l.t.t.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.p: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.p: A = None
        self.x: C = None
        self.txt = txt

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

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

k.z = l
k.p = d
d.p = f
d.x = e
e.t = l
f.z = e
f.p = d
a.z = l
a.p = d
l.t = e
assert l.t.t.t.t.t.txt == "e"