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

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

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

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

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

m = A("m")
d = B("d")
f = C("f")
n = D("n")
l = E("l")

m.r = l
m.y = d
m.v = d
m.z = d
m.w = f
d.v = f
d.o = f
d.p = l
d.q = n
d.x = n
f.v = m
f.r = d
n.v = f
n.w = f
n.p = m
n.o = m
l.r = d
assert m.r.r.p.r.q.txt == "
class A:
    def __init__(self, txt: str):
        self.r: E = None
        self.y: B = None
        self.v: B = None
        self.z: B = None
        self.w: C = None
        self.txt = txt

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

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

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

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

m = A("m")
d = B("d")
f = C("f")
n = D("n")
l = E("l")

m.r = l
m.y = d
m.v = d
m.z = d
m.w = f
d.v = f
d.o = f
d.p = l
d.q = n
d.x = n
f.v = m
f.r = d
n.v = f
n.w = f
n.p = m
n.o = m
l.r = d
assert m.r.r.p.r.q.txt == "n"