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

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

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

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

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

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

b.p = i
i.o = j
i.t = a
j.p = i
a.o = b
a.t = i
assert j.p.o.p.txt == "i"