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

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

e = A("e")
j = B("j")
b = B("b")
m = A("m")
l = B("l")
n = B("n")
f = B("f")
i = B("i")

e.x = m
j.w = e
b.w = m
m.x = e
l.w = e
n.w = e
f.w = m
i.w = e
assert e.x.x.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.txt = txt

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

e = A("e")
j = B("j")
b = B("b")
m = A("m")
l = B("l")
n = B("n")
f = B("f")
i = B("i")

e.x = m
j.w = e
b.w = m
m.x = e
l.w = e
n.w = e
f.w = m
i.w = e
assert e.x.x.x.x.x.txt == "m"