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

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

l = A("l")
h = B("h")
j = A("j")
b = B("b")
g = B("g")
a = B("a")

l.z = a
h.z = g
j.z = g
b.z = a
g.z = b
a.z = g
assert j.z.z.z.z.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

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

l = A("l")
h = B("h")
j = A("j")
b = B("b")
g = B("g")
a = B("a")

l.z = a
h.z = g
j.z = g
b.z = a
g.z = b
a.z = g
assert j.z.z.z.z.z.z.txt == "a"