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

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

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

g = A("g")
l = B("l")
d = C("d")

g.y = d
g.z = l
l.z = d
d.z = l
d.p = l
d.u = g
assert g.y.u.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.z: B = None
        self.txt = txt

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

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

g = A("g")
l = B("l")
d = C("d")

g.y = d
g.z = l
l.z = d
d.z = l
d.p = l
d.u = g
assert g.y.u.y.txt == "d"