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

class B:
    def __init__(self, txt: str):
        self.r: A = None
        self.u: E = None
        self.w: A = None
        self.y: A = None
        self.o: A = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.x: D = None
        self.q: D = None
        self.u: B = None
        self.o: D = None
        self.txt = txt

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

g.s = f
g.r = a
g.x = a
e.r = g
e.w = g
e.y = g
e.o = g
e.u = d
a.z = g
a.s = e
a.w = e
f.w = d
f.p = d
d.x = f
d.q = f
d.o = f
d.u = e
assert f.p.q.w.txt == "
class A:
    def __init__(self, txt: str):
        self.s: D = None
        self.r: C = None
        self.x: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.r: A = None
        self.u: E = None
        self.w: A = None
        self.y: A = None
        self.o: A = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.x: D = None
        self.q: D = None
        self.u: B = None
        self.o: D = None
        self.txt = txt

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

g.s = f
g.r = a
g.x = a
e.r = g
e.w = g
e.y = g
e.o = g
e.u = d
a.z = g
a.s = e
a.w = e
f.w = d
f.p = d
d.x = f
d.q = f
d.o = f
d.u = e
assert f.p.q.w.txt == "d"