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

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

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

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

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

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

e.u = i
e.p = i
j.p = i
j.w = l
i.u = e
i.p = l
l.u = e
l.p = i
assert e.u.u.p.u.txt == "e"