class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.s: E = None
        self.w: B = None
        self.r: C = None
        self.v: B = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.s: D = None
        self.t: A = None
        self.txt = txt

m = A("m")
n = B("n")
g = C("g")
d = D("d")
e = E("e")

m.y = d
m.s = e
m.w = n
m.v = n
m.r = g
n.u = g
g.u = m
g.o = m
g.w = d
d.s = e
d.p = g
e.s = d
e.t = m
assert n.u.w.p.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.s: E = None
        self.w: B = None
        self.r: C = None
        self.v: B = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.s: D = None
        self.t: A = None
        self.txt = txt

m = A("m")
n = B("n")
g = C("g")
d = D("d")
e = E("e")

m.y = d
m.s = e
m.w = n
m.v = n
m.r = g
n.u = g
g.u = m
g.o = m
g.w = d
d.s = e
d.p = g
e.s = d
e.t = m
assert n.u.w.p.txt == "g"