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

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

class C:
    def __init__(self, txt: str):
        self.u: A = None
        self.r: A = None
        self.s: A = None
        self.txt = txt

j = A("j")
h = B("h")
e = C("e")
g = A("g")

j.z = h
j.p = g
h.p = j
h.x = g
e.u = g
e.r = g
e.s = j
g.z = h
g.p = j
assert g.p.z.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.p: A = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.u: A = None
        self.r: A = None
        self.s: A = None
        self.txt = txt

j = A("j")
h = B("h")
e = C("e")
g = A("g")

j.z = h
j.p = g
h.p = j
h.x = g
e.u = g
e.r = g
e.s = j
g.z = h
g.p = j
assert g.p.z.p.p.txt == "g"