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

l = A("l")
k = B("k")
j = B("j")
c = B("c")

l.z = c
k.s = l
j.s = l
c.s = l
assert j.s.z.s.z.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

l = A("l")
k = B("k")
j = B("j")
c = B("c")

l.z = c
k.s = l
j.s = l
c.s = l
assert j.s.z.s.z.txt == "c"