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

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

k = A("k")
l = B("l")
a = B("a")
i = B("i")

k.w = a
l.t = i
l.z = k
a.t = i
a.z = k
i.t = l
i.z = k
assert l.t.t.z.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.txt = txt

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

k = A("k")
l = B("l")
a = B("a")
i = B("i")

k.w = a
l.t = i
l.z = k
a.t = i
a.z = k
i.t = l
i.z = k
assert l.t.t.z.txt == "k"