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

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

class C:
    def __init__(self, txt: str):
        self.q: C = None
        self.z: A = None
        self.r: A = None
        self.txt = txt

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

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

m = A("m")
f = B("f")
l = C("l")
b = D("b")
n = E("n")
i = C("i")
c = A("c")
g = D("g")

m.p = n
f.q = n
l.q = i
l.z = c
l.r = c
b.y = g
b.q = l
b.w = l
b.p = l
b.s = m
n.y = b
n.w = i
i.q = l
i.z = m
i.r = c
c.p = n
g.y = b
g.q = l
g.w = l
g.p = i
g.s = c
assert i.r.p.w.txt == "
class A:
    def __init__(self, txt: str):
        self.p: E = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.q: C = None
        self.z: A = None
        self.r: A = None
        self.txt = txt

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

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

m = A("m")
f = B("f")
l = C("l")
b = D("b")
n = E("n")
i = C("i")
c = A("c")
g = D("g")

m.p = n
f.q = n
l.q = i
l.z = c
l.r = c
b.y = g
b.q = l
b.w = l
b.p = l
b.s = m
n.y = b
n.w = i
i.q = l
i.z = m
i.r = c
c.p = n
g.y = b
g.q = l
g.w = l
g.p = i
g.s = c
assert i.r.p.w.txt == "i"