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

class B:
    def __init__(self, txt: str):
        self.p: B = None
        self.s: C = None
        self.y: C = None
        self.r: C = None
        self.txt = txt

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

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

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

g = A("g")
c = B("c")
m = C("m")
a = D("a")
f = E("f")
j = B("j")
i = D("i")

g.w = f
c.p = j
c.s = m
c.y = m
c.r = m
m.t = f
m.v = f
m.y = j
m.z = g
a.w = i
a.x = m
a.z = g
f.r = m
f.p = m
f.s = c
f.w = i
j.p = c
j.s = m
j.y = m
j.r = m
i.w = a
i.x = m
i.z = g
assert f.s.s.y.p.y.txt == "
class A:
    def __init__(self, txt: str):
        self.w: E = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.p: B = None
        self.s: C = None
        self.y: C = None
        self.r: C = None
        self.txt = txt

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

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

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

g = A("g")
c = B("c")
m = C("m")
a = D("a")
f = E("f")
j = B("j")
i = D("i")

g.w = f
c.p = j
c.s = m
c.y = m
c.r = m
m.t = f
m.v = f
m.y = j
m.z = g
a.w = i
a.x = m
a.z = g
f.r = m
f.p = m
f.s = c
f.w = i
j.p = c
j.s = m
j.y = m
j.r = m
i.w = a
i.x = m
i.z = g
assert f.s.s.y.p.y.txt == "m"