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

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

c = A("c")
h = B("h")
b = B("b")

c.p = b
h.t = c
b.t = c
assert b.t.p.t.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.txt = txt

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

c = A("c")
h = B("h")
b = B("b")

c.p = b
h.t = c
b.t = c
assert b.t.p.t.txt == "c"