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

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

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

i.p = l
i.u = a
a.y = l
a.s = l
l.p = i
l.u = a
h.y = l
h.s = i
assert a.y.p.u.txt == "
class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.u: B = None
        self.txt = txt

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

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

i.p = l
i.u = a
a.y = l
a.s = l
l.p = i
l.u = a
h.y = l
h.s = i
assert a.y.p.u.txt == "a"