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

class B:
    def __init__(self, txt: str):
        self.p: E = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.o: E = None
        self.s: D = None
        self.txt = txt

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

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

f = A("f")
g = B("g")
m = C("m")
d = D("d")
e = E("e")

f.v = d
f.r = m
g.p = e
m.o = e
m.s = d
d.q = g
d.w = m
e.u = g
e.x = g
e.o = m
e.v = m
assert g.p.v.s.w.txt == "
class A:
    def __init__(self, txt: str):
        self.v: D = None
        self.r: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.p: E = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.o: E = None
        self.s: D = None
        self.txt = txt

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

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

f = A("f")
g = B("g")
m = C("m")
d = D("d")
e = E("e")

f.v = d
f.r = m
g.p = e
m.o = e
m.s = d
d.q = g
d.w = m
e.u = g
e.x = g
e.o = m
e.v = m
assert g.p.v.s.w.txt == "m"