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

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

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

a = A("a")
j = B("j")
g = C("g")

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

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

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

a = A("a")
j = B("j")
g = C("g")

a.z = j
j.x = a
j.p = g
g.t = a
assert g.t.z.p.txt == "g"