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

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

j = A("j")
i = B("i")
n = B("n")
d = A("d")
l = B("l")
c = A("c")

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

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

j = A("j")
i = B("i")
n = B("n")
d = A("d")
l = B("l")
c = A("c")

j.x = c
i.p = c
n.p = c
d.x = c
l.p = d
c.x = j
assert j.x.x.x.txt == "c"