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

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

b = A("b")
m = B("m")
c = B("c")
e = A("e")

b.z = m
b.t = e
m.o = e
m.v = c
c.o = e
c.v = m
e.z = m
e.t = b
assert e.z.o.t.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.t: A = None
        self.txt = txt

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

b = A("b")
m = B("m")
c = B("c")
e = A("e")

b.z = m
b.t = e
m.o = e
m.v = c
c.o = e
c.v = m
e.z = m
e.t = b
assert e.z.o.t.txt == "b"