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

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

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

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

e.w = f
e.p = g
l.v = g
f.w = g
f.x = g
f.q = c
g.w = b
g.p = e
b.w = e
b.x = g
b.q = m
m.v = g
c.v = g
assert f.q.v.w.x.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.p: A = None
        self.txt = txt

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

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

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

e.w = f
e.p = g
l.v = g
f.w = g
f.x = g
f.q = c
g.w = b
g.p = e
b.w = e
b.x = g
b.q = m
m.v = g
c.v = g
assert f.q.v.w.x.txt == "g"