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

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

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

e.v = m
e.x = a
a.s = e
a.u = e
b.v = a
b.x = m
m.s = b
m.u = b
assert a.u.x.u.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.x: B = None
        self.txt = txt

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

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

e.v = m
e.x = a
a.s = e
a.u = e
b.v = a
b.x = m
m.s = b
m.u = b
assert a.u.x.u.txt == "e"