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

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

m = A("m")
n = B("n")
a = A("a")
i = A("i")
l = B("l")
d = A("d")
f = A("f")
h = A("h")

m.z = d
m.w = d
n.u = f
n.o = f
a.z = h
a.w = d
i.z = h
i.w = a
l.u = m
l.o = h
d.z = i
d.w = h
f.z = a
f.w = h
h.z = f
h.w = d
assert l.o.z.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.w: A = None
        self.txt = txt

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

m = A("m")
n = B("n")
a = A("a")
i = A("i")
l = B("l")
d = A("d")
f = A("f")
h = A("h")

m.z = d
m.w = d
n.u = f
n.o = f
a.z = h
a.w = d
i.z = h
i.w = a
l.u = m
l.o = h
d.z = i
d.w = h
f.z = a
f.w = h
h.z = f
h.w = d
assert l.o.z.w.w.txt == "d"