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

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

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

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

f.s = a
f.z = a
l.s = i
e.u = a
i.s = a
i.z = l
h.s = l
h.z = a
a.s = f
assert h.s.s.s.s.z.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.z: B = None
        self.txt = txt

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

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

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

f.s = a
f.z = a
l.s = i
e.u = a
i.s = a
i.z = l
h.s = l
h.z = a
a.s = f
assert h.s.s.s.s.z.txt == "a"