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.t: B = None
        self.txt = txt

k = A("k")
m = B("m")
a = B("a")

k.t = m
k.z = m
m.s = k
m.t = a
a.s = k
a.t = m
assert k.z.t.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.t: B = None
        self.txt = txt

k = A("k")
m = B("m")
a = B("a")

k.t = m
k.z = m
m.s = k
m.t = a
a.s = k
a.t = m
assert k.z.t.t.txt == "m"