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

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

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

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

class E:
    def __init__(self, txt: str):
        self.y: B = None
        self.u: A = None
        self.p: A = None
        self.x: D = None
        self.o: C = None
        self.txt = txt

b = A("b")
e = B("e")
g = C("g")
i = D("i")
a = E("a")

b.y = e
b.s = i
e.z = b
g.x = e
i.z = e
i.v = b
i.q = g
a.y = e
a.u = b
a.p = b
a.x = i
a.o = g
assert b.s.v.s.z.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.s: D = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.y: B = None
        self.u: A = None
        self.p: A = None
        self.x: D = None
        self.o: C = None
        self.txt = txt

b = A("b")
e = B("e")
g = C("g")
i = D("i")
a = E("a")

b.y = e
b.s = i
e.z = b
g.x = e
i.z = e
i.v = b
i.q = g
a.y = e
a.u = b
a.p = b
a.x = i
a.o = g
assert b.s.v.s.z.txt == "e"