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

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

m = A("m")
e = B("e")
j = A("j")
i = B("i")

m.u = i
m.w = j
e.o = i
j.u = i
j.w = m
i.o = e
assert e.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.w: A = None
        self.txt = txt

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

m = A("m")
e = B("e")
j = A("j")
i = B("i")

m.u = i
m.w = j
e.o = i
j.u = i
j.w = m
i.o = e
assert e.o.o.o.txt == "i"