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

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

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

e.x = h
d.s = e
d.t = h
h.s = e
h.t = d
assert d.t.s.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

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

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

e.x = h
d.s = e
d.t = h
h.s = e
h.t = d
assert d.t.s.x.txt == "h"