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

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

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

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

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

g = A("g")
j = B("j")
k = C("k")
l = D("l")
d = E("d")

g.o = j
g.q = j
g.v = k
g.p = d
j.w = d
k.v = l
k.s = j
k.o = d
l.y = g
l.o = k
d.z = g
d.p = k
d.o = l
assert d.p.v.y.o.w.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.v: C = None
        self.q: B = None
        self.p: E = None
        self.txt = txt

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

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

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

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

g = A("g")
j = B("j")
k = C("k")
l = D("l")
d = E("d")

g.o = j
g.q = j
g.v = k
g.p = d
j.w = d
k.v = l
k.s = j
k.o = d
l.y = g
l.o = k
d.z = g
d.p = k
d.o = l
assert d.p.v.y.o.w.txt == "d"