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

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

h = A("h")
c = B("c")
e = B("e")
i = B("i")
f = B("f")
l = B("l")
k = B("k")
b = A("b")
m = B("m")
a = A("a")

h.y = b
c.w = b
c.z = e
e.w = h
e.z = m
i.w = h
i.z = k
f.w = h
f.z = l
l.w = a
l.z = i
k.w = a
k.z = l
b.y = h
m.w = h
m.z = i
a.y = h
assert e.w.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.txt = txt

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

h = A("h")
c = B("c")
e = B("e")
i = B("i")
f = B("f")
l = B("l")
k = B("k")
b = A("b")
m = B("m")
a = A("a")

h.y = b
c.w = b
c.z = e
e.w = h
e.z = m
i.w = h
i.z = k
f.w = h
f.z = l
l.w = a
l.z = i
k.w = a
k.z = l
b.y = h
m.w = h
m.z = i
a.y = h
assert e.w.y.y.y.y.txt == "h"