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

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

b = A("b")
n = B("n")
f = A("f")

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

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

b = A("b")
n = B("n")
f = A("f")

b.t = n
b.z = n
n.s = b
f.t = n
f.z = n
assert f.z.s.t.txt == "n"