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

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

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

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

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

n = A("n")
k = B("k")
m = C("m")
f = D("f")
a = E("a")
c = C("c")
e = B("e")
d = D("d")
h = D("h")
g = D("g")

n.x = m
n.z = m
n.w = e
n.r = c
k.p = m
m.x = f
m.q = e
m.y = n
m.z = h
f.s = h
f.t = e
f.r = a
f.o = n
a.r = c
a.v = h
a.y = d
c.x = d
c.z = d
c.q = k
c.y = n
e.p = c
d.s = g
d.t = k
d.r = a
d.o = n
h.s = d
h.t = e
h.r = a
h.o = n
g.s = f
g.t = e
g.r = a
g.o = n
assert f.t.p.x.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.z: C = None
        self.w: B = None
        self.r: C = None
        self.txt = txt

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

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

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

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

n = A("n")
k = B("k")
m = C("m")
f = D("f")
a = E("a")
c = C("c")
e = B("e")
d = D("d")
h = D("h")
g = D("g")

n.x = m
n.z = m
n.w = e
n.r = c
k.p = m
m.x = f
m.q = e
m.y = n
m.z = h
f.s = h
f.t = e
f.r = a
f.o = n
a.r = c
a.v = h
a.y = d
c.x = d
c.z = d
c.q = k
c.y = n
e.p = c
d.s = g
d.t = k
d.r = a
d.o = n
h.s = d
h.t = e
h.r = a
h.o = n
g.s = f
g.t = e
g.r = a
g.o = n
assert f.t.p.x.r.r.txt == "c"