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

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

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

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

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

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

d.y = e
d.t = h
h.p = e
h.u = l
e.y = d
e.t = l
l.p = d
l.u = h
assert e.t.p.t.p.txt == "e"