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

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

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

n = A("n")
m = B("m")
b = C("b")
f = B("f")
l = A("l")

n.x = m
m.x = n
b.p = f
b.r = l
f.x = n
l.x = m
assert n.x.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

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

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

n = A("n")
m = B("m")
b = C("b")
f = B("f")
l = A("l")

n.x = m
m.x = n
b.p = f
b.r = l
f.x = n
l.x = m
assert n.x.x.x.x.txt == "n"