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

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

h = A("h")
a = B("a")
n = A("n")
m = B("m")
b = A("b")
c = A("c")
i = B("i")
l = A("l")

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

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

h = A("h")
a = B("a")
n = A("n")
m = B("m")
b = A("b")
c = A("c")
i = B("i")
l = A("l")

h.s = m
a.p = i
a.z = b
n.s = a
m.p = a
m.z = b
b.s = m
c.s = i
i.p = a
i.z = c
l.s = i
assert h.s.p.z.s.p.z.txt == "b"