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

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

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

n = A("n")
d = B("d")
j = C("j")
f = A("f")

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

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

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

n = A("n")
d = B("d")
j = C("j")
f = A("f")

n.o = d
d.r = j
j.x = n
j.p = f
f.o = d
assert n.o.r.x.txt == "n"