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

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

e = A("e")
f = B("f")
j = B("j")
b = B("b")

e.s = f
f.z = e
j.z = e
b.z = e
assert e.s.z.s.z.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

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

e = A("e")
f = B("f")
j = B("j")
b = B("b")

e.s = f
f.z = e
j.z = e
b.z = e
assert e.s.z.s.z.txt == "e"