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

class B:
    def __init__(self, txt: str):
        self.u: E = None
        self.q: E = None
        self.r: D = None
        self.z: E = None
        self.x: D = None
        self.txt = txt

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

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

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

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

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

class B:
    def __init__(self, txt: str):
        self.u: E = None
        self.q: E = None
        self.r: D = None
        self.z: E = None
        self.x: D = None
        self.txt = txt

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

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

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

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

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