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

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

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

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

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

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

n.x = i
n.v = i
n.r = c
n.w = d
c.z = i
c.w = d
c.o = b
d.y = i
d.s = j
d.w = n
d.q = n
d.o = c
i.s = m
i.y = n
i.p = d
i.q = d
j.z = d
j.u = d
j.y = b
j.t = b
j.v = m
b.s = m
b.y = n
b.p = d
b.q = d
m.z = b
m.w = d
m.o = i
assert c.z.q.q.r.w.q.w.txt == "
class A:
    def __init__(self, txt: str):
        self.x: D = None
        self.v: D = None
        self.r: B = None
        self.w: C = None
        self.txt = txt

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

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

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

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

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

n.x = i
n.v = i
n.r = c
n.w = d
c.z = i
c.w = d
c.o = b
d.y = i
d.s = j
d.w = n
d.q = n
d.o = c
i.s = m
i.y = n
i.p = d
i.q = d
j.z = d
j.u = d
j.y = b
j.t = b
j.v = m
b.s = m
b.y = n
b.p = d
b.q = d
m.z = b
m.w = d
m.o = i
assert c.z.q.q.r.w.q.w.txt == "d"