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

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

i = A("i")
m = B("m")
c = B("c")

i.t = c
i.w = m
m.v = i
c.v = i
assert i.w.v.w.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.w: B = None
        self.txt = txt

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

i = A("i")
m = B("m")
c = B("c")

i.t = c
i.w = m
m.v = i
c.v = i
assert i.w.v.w.txt == "m"