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

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

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

g = A("g")
c = B("c")
d = C("d")
b = B("b")

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

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

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

g = A("g")
c = B("c")
d = C("d")
b = B("b")

g.y = b
g.o = d
g.s = c
c.x = d
c.r = d
c.z = b
d.v = c
d.r = c
b.x = d
b.r = d
b.z = c
assert c.x.r.r.txt == "d"