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

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

b = A("b")
e = B("e")
k = B("k")

b.p = k
e.p = b
e.u = k
k.p = b
k.u = e
assert b.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.txt = txt

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

b = A("b")
e = B("e")
k = B("k")

b.p = k
e.p = b
e.u = k
k.p = b
k.u = e
assert b.p.p.p.txt == "k"