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

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

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

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

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

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

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