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

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

n = A("n")
d = B("d")
i = B("i")
k = A("k")
l = B("l")
c = B("c")
b = B("b")
e = A("e")
f = B("f")

n.z = l
d.x = n
i.x = e
k.z = i
l.x = k
c.x = n
b.x = e
e.z = b
f.x = e
assert b.x.z.x.z.x.z.x.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

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

n = A("n")
d = B("d")
i = B("i")
k = A("k")
l = B("l")
c = B("c")
b = B("b")
e = A("e")
f = B("f")

n.z = l
d.x = n
i.x = e
k.z = i
l.x = k
c.x = n
b.x = e
e.z = b
f.x = e
assert b.x.z.x.z.x.z.x.txt == "e"