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

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

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

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

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

g = A("g")
f = B("f")
d = C("d")
c = D("c")
a = E("a")

g.w = f
g.p = a
g.x = a
g.q = d
f.o = a
f.q = a
f.w = c
f.v = d
d.o = a
d.p = f
c.t = d
c.r = a
c.u = a
c.y = f
a.r = g
assert g.w.v.p.v.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.p: E = None
        self.q: C = None
        self.x: E = None
        self.txt = txt

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

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

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

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

g = A("g")
f = B("f")
d = C("d")
c = D("c")
a = E("a")

g.w = f
g.p = a
g.x = a
g.q = d
f.o = a
f.q = a
f.w = c
f.v = d
d.o = a
d.p = f
c.t = d
c.r = a
c.u = a
c.y = f
a.r = g
assert g.w.v.p.v.txt == "d"