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

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

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

m.u = l
m.o = h
a.z = h
h.u = g
h.o = l
j.z = m
e.z = g
l.u = g
l.o = h
g.u = h
g.o = l
n.z = l
assert a.z.u.o.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.o: A = None
        self.txt = txt

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

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

m.u = l
m.o = h
a.z = h
h.u = g
h.o = l
j.z = m
e.z = g
l.u = g
l.o = h
g.u = h
g.o = l
n.z = l
assert a.z.u.o.txt == "l"