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

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

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

b = A("b")
l = B("l")
e = C("e")
d = A("d")
g = C("g")
k = A("k")

b.z = e
l.o = b
l.w = g
l.p = k
e.x = g
e.s = k
e.v = l
d.z = g
g.x = e
g.s = d
g.v = l
k.z = g
assert b.z.v.w.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.txt = txt

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

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

b = A("b")
l = B("l")
e = C("e")
d = A("d")
g = C("g")
k = A("k")

b.z = e
l.o = b
l.w = g
l.p = k
e.x = g
e.s = k
e.v = l
d.z = g
g.x = e
g.s = d
g.v = l
k.z = g
assert b.z.v.w.txt == "g"