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

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

j = A("j")
e = B("e")
b = A("b")
i = B("i")

j.x = e
j.p = e
e.t = b
e.s = j
b.x = e
b.p = i
i.t = j
i.s = b
assert j.p.s.x.t.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.p: B = None
        self.txt = txt

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

j = A("j")
e = B("e")
b = A("b")
i = B("i")

j.x = e
j.p = e
e.t = b
e.s = j
b.x = e
b.p = i
i.t = j
i.s = b
assert j.p.s.x.t.txt == "b"