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

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

h = A("h")
e = B("e")
g = B("g")
l = A("l")
c = B("c")
i = B("i")
a = B("a")
m = A("m")

h.z = i
e.w = h
e.x = h
g.w = l
g.x = h
l.z = a
c.w = l
c.x = h
i.w = h
i.x = h
a.w = l
a.x = h
m.z = e
assert e.x.z.x.z.w.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

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

h = A("h")
e = B("e")
g = B("g")
l = A("l")
c = B("c")
i = B("i")
a = B("a")
m = A("m")

h.z = i
e.w = h
e.x = h
g.w = l
g.x = h
l.z = a
c.w = l
c.x = h
i.w = h
i.x = h
a.w = l
a.x = h
m.z = e
assert e.x.z.x.z.w.z.txt == "i"