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

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

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

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

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

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

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

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

j.p = n
j.o = n
n.t = f
f.x = n
assert n.t.x.t.txt == "f"