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

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

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

b = A("b")
g = B("g")
f = C("f")
e = C("e")
j = C("j")
m = C("m")

b.y = g
g.w = b
g.t = b
f.y = b
f.q = g
f.z = g
e.y = b
e.q = g
e.z = g
j.y = b
j.q = g
j.z = g
m.y = b
m.q = g
m.z = g
assert m.q.w.y.w.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

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

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

b = A("b")
g = B("g")
f = C("f")
e = C("e")
j = C("j")
m = C("m")

b.y = g
g.w = b
g.t = b
f.y = b
f.q = g
f.z = g
e.y = b
e.q = g
e.z = g
j.y = b
j.q = g
j.z = g
m.y = b
m.q = g
m.z = g
assert m.q.w.y.w.txt == "b"