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

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

f = A("f")
c = B("c")
m = B("m")
l = A("l")
n = B("n")
b = A("b")
g = A("g")
a = A("a")

f.z = g
f.o = b
c.z = m
m.z = c
l.z = f
l.o = f
n.z = c
b.z = a
b.o = g
g.z = l
g.o = f
a.z = f
a.o = b
assert b.z.o.z.z.z.o.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.o: A = None
        self.txt = txt

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

f = A("f")
c = B("c")
m = B("m")
l = A("l")
n = B("n")
b = A("b")
g = A("g")
a = A("a")

f.z = g
f.o = b
c.z = m
m.z = c
l.z = f
l.o = f
n.z = c
b.z = a
b.o = g
g.z = l
g.o = f
a.z = f
a.o = b
assert b.z.o.z.z.z.o.txt == "f"