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

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

n = A("n")
a = B("a")
e = B("e")
i = B("i")
f = B("f")

n.z = f
a.o = f
a.s = f
e.o = a
e.s = i
i.o = f
i.s = e
f.o = e
f.s = i
assert i.o.s.s.o.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: B = None
        self.s: B = None
        self.txt = txt

n = A("n")
a = B("a")
e = B("e")
i = B("i")
f = B("f")

n.z = f
a.o = f
a.s = f
e.o = a
e.s = i
i.o = f
i.s = e
f.o = e
f.s = i
assert i.o.s.s.o.o.txt == "f"