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

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

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

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

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

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

e.p = j
h.t = j
h.u = l
l.p = h
j.t = h
j.u = e
assert l.p.u.p.u.txt == "l"