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

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

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

m.y = e
m.v = l
e.z = m
e.u = l
l.y = e
l.v = m
assert e.u.v.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.v: A = None
        self.txt = txt

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

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

m.y = e
m.v = l
e.z = m
e.u = l
l.y = e
l.v = m
assert e.u.v.y.txt == "e"