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

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

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

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

class E:
    def __init__(self, txt: str):
        self.x: A = None
        self.y: A = None
        self.o: D = None
        self.z: A = None
        self.txt = txt

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

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

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

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

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

class E:
    def __init__(self, txt: str):
        self.x: A = None
        self.y: A = None
        self.o: D = None
        self.z: A = None
        self.txt = txt

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

e.w = k
e.r = g
g.v = k
a.y = m
a.x = d
m.w = g
d.x = e
d.y = e
d.z = e
d.o = m
k.w = g
assert m.w.v.w.v.w.txt == "g"