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

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

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

j = A("j")
d = B("d")
i = C("i")
g = B("g")

j.s = d
j.r = d
j.o = i
d.z = g
d.o = i
i.y = j
g.z = d
g.o = i
assert j.o.y.s.z.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.o: C = None
        self.r: B = None
        self.txt = txt

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

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

j = A("j")
d = B("d")
i = C("i")
g = B("g")

j.s = d
j.r = d
j.o = i
d.z = g
d.o = i
i.y = j
g.z = d
g.o = i
assert j.o.y.s.z.txt == "g"