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

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

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

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

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

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

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

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

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

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

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

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

e.v = b
e.s = b
e.p = g
b.o = a
a.x = e
g.y = e
c.v = b
c.y = b
assert e.s.o.x.txt == "e"