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

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

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

a = A("a")
f = B("f")
n = C("n")
l = C("l")
h = A("h")
e = A("e")

a.p = f
f.t = n
f.r = l
f.z = a
n.t = l
n.u = l
n.y = a
l.t = n
l.u = n
l.y = e
h.p = f
e.p = f
assert f.r.u.y.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.txt = txt

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

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

a = A("a")
f = B("f")
n = C("n")
l = C("l")
h = A("h")
e = A("e")

a.p = f
f.t = n
f.r = l
f.z = a
n.t = l
n.u = l
n.y = a
l.t = n
l.u = n
l.y = e
h.p = f
e.p = f
assert f.r.u.y.p.txt == "f"