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

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

b = A("b")
h = B("h")
a = B("a")
l = A("l")
j = A("j")
e = A("e")
c = B("c")

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

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

b = A("b")
h = B("h")
a = B("a")
l = A("l")
j = A("j")
e = A("e")
c = B("c")

b.z = h
h.p = j
h.s = c
a.p = j
a.s = h
l.z = a
j.z = a
e.z = a
c.p = l
c.s = a
assert b.z.s.p.z.s.s.txt == "c"