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

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

l = A("l")
d = B("d")
n = A("n")
e = A("e")
m = A("m")
f = A("f")
a = B("a")

l.s = d
d.z = e
n.s = a
e.s = d
m.s = d
f.s = a
a.z = e
assert n.s.z.s.z.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

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

l = A("l")
d = B("d")
n = A("n")
e = A("e")
m = A("m")
f = A("f")
a = B("a")

l.s = d
d.z = e
n.s = a
e.s = d
m.s = d
f.s = a
a.z = e
assert n.s.z.s.z.txt == "e"