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

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

i = A("i")
k = B("k")
f = A("f")
a = A("a")
d = A("d")
h = B("h")

i.z = k
k.s = a
f.z = h
a.z = k
d.z = k
h.s = i
assert i.z.s.z.s.z.s.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

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

i = A("i")
k = B("k")
f = A("f")
a = A("a")
d = A("d")
h = B("h")

i.z = k
k.s = a
f.z = h
a.z = k
d.z = k
h.s = i
assert i.z.s.z.s.z.s.txt == "a"