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

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

l = A("l")
i = B("i")
c = B("c")
h = B("h")
m = A("m")
n = B("n")

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

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

l = A("l")
i = B("i")
c = B("c")
h = B("h")
m = A("m")
n = B("n")

l.z = i
i.u = m
i.o = c
c.u = m
c.o = i
h.u = l
h.o = c
m.z = i
n.u = l
n.o = h
assert m.z.u.z.u.txt == "m"