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

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

c = A("c")
k = B("k")
f = B("f")
j = A("j")
h = A("h")
i = A("i")
n = B("n")

c.z = j
k.s = n
f.s = n
j.z = h
h.z = i
i.z = c
n.s = k
assert f.s.s.s.s.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.txt = txt

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

c = A("c")
k = B("k")
f = B("f")
j = A("j")
h = A("h")
i = A("i")
n = B("n")

c.z = j
k.s = n
f.s = n
j.z = h
h.z = i
i.z = c
n.s = k
assert f.s.s.s.s.s.s.s.txt == "n"