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

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

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

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

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

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

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

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

n.t = i
n.z = j
i.p = a
j.x = a
j.p = a
a.x = j
a.p = j
assert n.t.p.x.x.txt == "a"