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

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

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

h = A("h")
i = B("i")
g = C("g")
c = C("c")
a = A("a")
l = C("l")
b = A("b")

h.s = b
i.p = b
i.z = c
g.s = i
g.t = i
g.z = h
c.s = i
c.t = i
c.z = h
a.s = b
l.s = i
l.t = i
l.z = a
b.s = a
assert a.s.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.txt = txt

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

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

h = A("h")
i = B("i")
g = C("g")
c = C("c")
a = A("a")
l = C("l")
b = A("b")

h.s = b
i.p = b
i.z = c
g.s = i
g.t = i
g.z = h
c.s = i
c.t = i
c.z = h
a.s = b
l.s = i
l.t = i
l.z = a
b.s = a
assert a.s.s.s.s.txt == "a"