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

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

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

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

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

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

c.o = m
c.x = e
e.v = m
m.o = c
m.x = e
assert c.o.x.v.txt == "m"