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

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

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

h.z = f
b.z = j
a.z = f
n.z = j
j.z = n
i.z = f
f.z = m
m.z = i
assert b.z.z.z.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.z: B = None
        self.txt = txt

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

h.z = f
b.z = j
a.z = f
n.z = j
j.z = n
i.z = f
f.z = m
m.z = i
assert b.z.z.z.z.z.z.z.txt == "j"