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

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

j = A("j")
n = B("n")
i = B("i")

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

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

j = A("j")
n = B("n")
i = B("i")

j.x = n
j.o = i
n.p = j
i.p = j
assert n.p.x.p.txt == "j"