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

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

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

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

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

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

n.z = l
f.y = b
l.z = j
m.y = l
a.y = l
b.z = l
j.z = b
assert b.z.z.z.z.txt == "l"