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

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

m = A("m")
l = B("l")
i = A("i")
e = B("e")
a = A("a")
c = B("c")

m.x = c
m.p = a
l.u = c
l.w = m
i.x = c
i.p = a
e.u = c
e.w = i
a.x = c
a.p = m
c.u = e
c.w = m
assert m.x.u.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.p: A = None
        self.txt = txt

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

m = A("m")
l = B("l")
i = A("i")
e = B("e")
a = A("a")
c = B("c")

m.x = c
m.p = a
l.u = c
l.w = m
i.x = c
i.p = a
e.u = c
e.w = i
a.x = c
a.p = m
c.u = e
c.w = m
assert m.x.u.u.u.u.txt == "c"