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

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

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

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

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

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

c.w = i
c.q = a
c.s = e
a.s = c
e.v = a
e.p = c
i.p = c
i.w = g
i.z = a
g.o = c
g.v = c
g.t = e
assert a.s.q.s.s.p.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.q: B = None
        self.s: C = None
        self.txt = txt

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

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

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

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

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

c.w = i
c.q = a
c.s = e
a.s = c
e.v = a
e.p = c
i.p = c
i.w = g
i.z = a
g.o = c
g.v = c
g.t = e
assert a.s.q.s.s.p.txt == "c"