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

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

a = A("a")
i = B("i")
e = B("e")

a.p = i
i.u = a
e.u = a
assert i.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.u: A = None
        self.txt = txt

a = A("a")
i = B("i")
e = B("e")

a.p = i
i.u = a
e.u = a
assert i.u.p.u.txt == "a"