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

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

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

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

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

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

l.z = c
c.o = n
c.q = l
k.o = n
k.q = n
n.z = b
b.o = m
b.q = n
i.o = n
i.q = n
m.z = b
h.o = n
h.q = l
f.o = n
f.q = l
assert b.o.z.o.z.o.txt == "m"