class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.p: 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.t: B = None
        self.txt = txt

j = A("j")
l = B("l")
b = C("b")

j.z = b
j.p = l
l.x = j
b.t = l
assert j.p.x.p.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.p: 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.t: B = None
        self.txt = txt

j = A("j")
l = B("l")
b = C("b")

j.z = b
j.p = l
l.x = j
b.t = l
assert j.p.x.p.txt == "l"