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

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

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

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

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

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

e.p = j
l.u = j
l.x = h
h.u = j
h.x = l
j.p = e
i.p = j
a.u = i
a.x = l
assert i.p.p.p.p.p.p.txt == "e"