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

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

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

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

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

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

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

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

i.y = g
i.z = g
i.r = m
g.v = d
g.o = d
g.x = i
d.r = m
d.w = g
m.r = d
m.w = g
assert i.r.w.x.z.txt == "g"