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

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

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

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

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

b = A("b")
g = B("g")
l = C("l")
m = D("m")
a = E("a")

b.v = a
g.y = m
g.t = m
l.z = m
l.q = b
l.w = b
l.y = b
m.s = g
m.o = g
a.x = b
a.w = g
a.q = g
a.v = l
assert a.v.z.s.t.o.txt == "
class A:
    def __init__(self, txt: str):
        self.v: E = None
        self.txt = txt

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

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

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

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

b = A("b")
g = B("g")
l = C("l")
m = D("m")
a = E("a")

b.v = a
g.y = m
g.t = m
l.z = m
l.q = b
l.w = b
l.y = b
m.s = g
m.o = g
a.x = b
a.w = g
a.q = g
a.v = l
assert a.v.z.s.t.o.txt == "g"