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

class B:
    def __init__(self, txt: str):
        self.y: A = None
        self.w: D = None
        self.s: B = None
        self.p: A = None
        self.txt = txt

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

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

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

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

m.w = g
m.s = g
m.t = n
m.x = n
m.r = e
j.y = m
j.p = m
j.w = n
j.s = g
i.z = n
i.w = g
n.w = m
e.x = g
g.y = m
g.p = m
g.w = b
g.s = j
d.z = n
d.w = g
b.w = m
assert i.z.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.t: D = None
        self.s: B = None
        self.x: D = None
        self.r: E = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.y: A = None
        self.w: D = None
        self.s: B = None
        self.p: A = None
        self.txt = txt

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

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

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

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

m.w = g
m.s = g
m.t = n
m.x = n
m.r = e
j.y = m
j.p = m
j.w = n
j.s = g
i.z = n
i.w = g
n.w = m
e.x = g
g.y = m
g.p = m
g.w = b
g.s = j
d.z = n
d.w = g
b.w = m
assert i.z.w.w.w.txt == "b"