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

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

c = A("c")
k = B("k")
a = A("a")
f = B("f")
i = A("i")

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

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

c = A("c")
k = B("k")
a = A("a")
f = B("f")
i = A("i")

c.z = i
c.v = f
k.z = i
k.s = f
a.z = c
a.v = f
f.z = i
f.s = k
i.z = c
i.v = f
assert f.s.s.s.s.txt == "f"