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

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

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

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

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

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

h.z = l
a.r = j
a.s = c
e.z = l
j.z = n
l.r = m
l.s = c
c.z = a
n.r = m
n.s = m
m.z = n
assert e.z.s.z.r.z.r.txt == "m"